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

<pre><code>&lt;ItemGroup&gt; 
     &lt;LibraryFiles Include="$(LibrariesReleaseDir)\**\*.*" Exclude=".svn" /&gt;
&lt;/ItemGroup&gt;
</code></pre>

<p>At the moment, but this does not exclude anything!</p>

[{'answer_id': 72536, 'author': 'Kieran Benton', 'author_id': 5777, 'author_profile': 'https://Stackoverflow.com/users/5777', 'pm_score': 7, 'selected': True, 'text': '<p>Thanks for your help, managed to sort it as follows:</p>\n\n<pre><code>&lt;ItemGroup&gt;\n     &lt;LibraryFiles Include="$(LibrariesReleaseDir)\\**\\*.*" \n                   Exclude="$(LibrariesReleaseDir)\\**\\.svn\\**" /&gt;\n&lt;/ItemGroup&gt;\n</code></pre>\n\n<p>Turns out the pattern matching basically runs on files, so you have to exclude everything BELOW the <code>.svn</code> directories (<code>.svn\\\\**</code>) for MSBuild to exclude the <code>.svn</code> directory itself.</p>\n'}, {'answer_id': 380954, 'author': 'Dave Markle', 'author_id': 24995, 'author_profile': 'https://Stackoverflow.com/users/24995', 'pm_score': 2, 'selected': False, 'text': '<p>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:</p>\n\n<pre><code>&lt;LibraryFiles  \n    Include="$(LibrariesReleaseDir)**\\*.*"  \n    Exclude="$(LibrariesReleaseDir)**\\.svn\\**\\*.*"/&gt;\n</code></pre>\n'}, {'answer_id': 612742, 'author': 'abombss', 'author_id': 31029, 'author_profile': 'https://Stackoverflow.com/users/31029', 'pm_score': 4, 'selected': False, 'text': '<p>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.</p>\n\n<pre><code>&lt;CreateItem Include="$(MSBuildProjectDirectory)\\..\\Client\\Web\\Foo.Web.UI\\**\\*.*"\n            Exclude="$(MSBuildProjectDirectory)\\..\\Client\\Web\\Foo.Web.UI\\**\\.svn\\**"&gt;\n  &lt;Output TaskParameter="Include" ItemName="WebFiles" /&gt;\n&lt;/CreateItem&gt;\n</code></pre>\n\n<p>The following does not work:</p>\n\n<pre><code>&lt;PropertyGroup&gt;\n    &lt;WebProjectDir&gt;$(MSBuildProjectDirectory)\\..\\Client\\Web\\Foo.Web.UI&lt;/WebProjectDir&gt;\n&lt;/PropertyGroup&gt;\n&lt;CreateItem Include="$(WebProjectDir)\\**\\*.*"\n            Exclude="$(WebProjectDir)\\**\\.svn\\**"&gt;\n  &lt;Output TaskParameter="Include" ItemName="WebFiles" /&gt;\n&lt;/CreateItem&gt;\n</code></pre>\n\n<p>Very strange!  I just spent like 3 hrs on this one.</p>\n'}, {'answer_id': 10387041, 'author': 'Anton Backer', 'author_id': 419876, 'author_profile': 'https://Stackoverflow.com/users/419876', 'pm_score': 1, 'selected': False, 'text': '<p>I\'ve run into some glitches using the Include/Exclude approach, so here\'s something that\'s worked for me instead:\n</p>\n\n<pre><code>&lt;ItemGroup&gt;\n    &lt;MyFiles Include=".\\PathToYourStuff\\**" /&gt;\n    &lt;MyFiles Remove=".\\PathToYourStuff\\**\\.svn\\**" /&gt;\n&lt;/ItemGroup&gt;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/72153', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5777/']