views:

63

answers:

2

Hi,

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 (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?

A: 

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

Filburt
+2  A: 

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>
Marcel Gosselin
I just reread Filburt's answer and this should also work but inthis case if you have files with the same extensions (dll, exe, pdc, config) in other folders, they will also be picked up.
Marcel Gosselin
So there is a meaning in the recursion wildcard "**" because some people claim that it doesn't make any difference if they'd use MyApp\*\*.ashx or MayApp\**\*.ashx.
Filburt
I've never seen triple star `***` but the meaning of `**` is match anything *including* sub-folders and `*` is match anything in the same folder (do not recurse in sub-folders). The `%(ReleaseFiles.RecursiveDir)` meta-data will contain the path starting at the path segment in your `Include` attribute that contains either `*` or `**`.
Marcel Gosselin
Dang it ... never mind the triple star. I didn't escape the slashes. The comment should read "MyApp"[slash][star][star][slash][star]".ashx".
Filburt