I'm working on an MSBuild script whose job is to build a solution and then copy the build output from two projects into a unified directory. Simple enough.
I'm doing this with the Copy task. Like so:
<ItemGroup>
<OutputFiles1 Include="Project1\bin\Release\*.*" />
<OutputFiles2 Include="Project2\bin\Release\*.*" />
</ItemGroup>
<Target CopyOutput>
<Copy SourceFiles="@(OutputFiles1)" DestinationFolder="DeployOutput" />
<Copy SourceFiles="@(OutputFiles2)" DestinationFolder="DeployOutput" />
</Target>
The problem I'm experiencing is this: The two ItemGroup elements contain the contents of the directories when the build script starts, not the contents of the directories when the solution build finishes.
So, for example, if I add a reference in Project1 to a new assembly and then run the build, the DeployOutput directory does not contain that new assembly because it didn't existing in the project output directory when the build started. But if I run the build again the file is there and gets copied.
It seems like this behavior is by design, but I'm unsure how to accomplish my task without spawning to a batch file or something like that to do the copy.