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!
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.
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.
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\**\*.*"/>
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With