I have the following item group:
<ItemGroup>
<ReleaseFiles Include="MyApp\*.ashx"/>
<ReleaseFiles Include="MyApp\*.config"/>
<ReleaseFiles Include="MyApp\bin\*.dll"/>
<ReleaseFiles Include="MyApp\bin\*.exe"/>
<ReleaseFiles Include="MyApp\bin\*.pdb"/>
<ReleaseFiles Include="MyApp\bin\*.config"/>
</ItemGroup>
and the following copy target:
<Copy SourceFiles="@(ReleaseFiles)" DestinationFiles="@(ReleaseFiles->'\\$(DeploymentMachine)\C$\Program Files\MyApp\%(RecursiveDir)%(Filename)%(Extension)')" />
but the problem is that the bin directory is not being preserved 开发者_如何学JAVA(all the files end up in the top level directory).
Please note that I need to use the same item group for creating the zipfile:
<Zip Files="@(ReleaseFiles)" ZipFileName="$(server)\$(BUILD_NUMBER).$(BUILD_VCS_NUMBER)\myApp.zip" WorkingDirectory="MyApp"/>
which works fine. How can I get the copy to work as well?
You need to make the MSBuild engine think that bin
is part of the recursive folder. In order to do that, add a *
after the bin folder like this:
<ItemGroup>
<ReleaseFiles Include="MyApp\*.ashx"/>
<ReleaseFiles Include="MyApp\*.config"/>
<ReleaseFiles Include="MyApp\bin*\*.dll"/>
<ReleaseFiles Include="MyApp\bin*\*.exe"/>
<ReleaseFiles Include="MyApp\bin*\*.pdb"/>
<ReleaseFiles Include="MyApp\bin*\*.config"/>
</ItemGroup>
It seems that mixing the path depth in your
<ReleaseFiles/>
breaks recursion.
Try this:
<ItemGroup>
<ReleaseFiles Include="MyApp\**\*.ashx" />
<ReleaseFiles Include="MyApp\**\*.config" />
<ReleaseFiles Include="MyApp\**\*.dll" />
<ReleaseFiles Include="MyApp\**\*.exe" />
<ReleaseFiles Include="MyApp\**\*.pdb" />
<ReleaseFiles Include="MyApp\**\*.config" />
</ItemGroup>
<Copy SorceFiles="@(ReleaseFiles)" DestinationFiles="@(ReleaseFiles->'\\$(DeploymentMachine)\C$\Program Files\MyApp\%(RecursiveDir)%(Filename)%(Extension)')" />
Hope this solves your problem.
UPDATE
I just read, that using UNC paths may also cause this issue ... but it should be fixed in 3.5
精彩评论