Monday, March 11, 2013

MSBuild copying all files in folder to destination folder

Typical task as for me, after build I want to copy some files from one location to other. All files that exist in folder. The not working approach looks like:
I would think that it should work, but it doesn't
<Target Name="AfterBuild">
<Copy SourceFiles="Foo\*.*" DestinationFolder="$(OutputPath)" ContinueOnError="true" />
</Target>
The working solution is below
<ItemGroup>
    <_CopyDeployableAssemblies Include="Foo\*.*" />
</ItemGroup>
<Target Name="AfterBuild">
<Copy SourceFiles="@(_CopyDeployableAssemblies)" DestinationFolder="$(OutputPath)" ContinueOnError="true" />
</Target>
It will copy all files from folder Foo to Bin folder.

No comments: