Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild ItemGroup, excluding .svn directories and files within

How can I construct a MSBuild ItemGroup to exclude .svn directories and all files within (recursively). I've got:

<ItemGroup> 
     <LibraryFiles Include="$(LibrariesReleaseDir)\**\*.*" Exclude=".svn" />
</ItemGroup>

At the moment, but this does not exclude anything!

like image 307
Kieran Benton Avatar asked Sep 16 '08 13:09

Kieran Benton


4 Answers

Thanks for your help, managed to sort it as follows:

<ItemGroup>
     <LibraryFiles Include="$(LibrariesReleaseDir)\**\*.*" 
                   Exclude="$(LibrariesReleaseDir)\**\.svn\**" />
</ItemGroup>

Turns out the pattern matching basically runs on files, so you have to exclude everything BELOW the .svn directories (.svn\\**) for MSBuild to exclude the .svn directory itself.

like image 181
Kieran Benton Avatar answered Nov 14 '22 12:11

Kieran Benton


So the issue is with chaining variables for some reason in msbuild. The following works for me, notice that I have to only use relative paths based on the MSBuildProjectDirectory variable.

<CreateItem Include="$(MSBuildProjectDirectory)\..\Client\Web\Foo.Web.UI\**\*.*"
            Exclude="$(MSBuildProjectDirectory)\..\Client\Web\Foo.Web.UI\**\.svn\**">
  <Output TaskParameter="Include" ItemName="WebFiles" />
</CreateItem>

The following does not work:

<PropertyGroup>
    <WebProjectDir>$(MSBuildProjectDirectory)\..\Client\Web\Foo.Web.UI</WebProjectDir>
</PropertyGroup>
<CreateItem Include="$(WebProjectDir)\**\*.*"
            Exclude="$(WebProjectDir)\**\.svn\**">
  <Output TaskParameter="Include" ItemName="WebFiles" />
</CreateItem>

Very strange! I just spent like 3 hrs on this one.

like image 23
abombss Avatar answered Nov 14 '22 10:11

abombss


Here's an even better way to do it, truly recursively. I can't seem to get your solution to go more than 1 level deep:

<LibraryFiles  
    Include="$(LibrariesReleaseDir)**\*.*"  
    Exclude="$(LibrariesReleaseDir)**\.svn\**\*.*"/>
like image 27
Dave Markle Avatar answered Nov 14 '22 11:11

Dave Markle


I've run into some glitches using the Include/Exclude approach, so here's something that's worked for me instead:

<ItemGroup>
    <MyFiles Include=".\PathToYourStuff\**" />
    <MyFiles Remove=".\PathToYourStuff\**\.svn\**" />
</ItemGroup>
like image 25
Anton Backer Avatar answered Nov 14 '22 10:11

Anton Backer