RationalGeek
RationalGeek

Reputation: 9599

MSBuild exclude syntax not working

I have a test file in MSBuild to create a ZIP. I need exclude certain folders. I have the following working.

<PropertyGroup>
  <TestZipPath>C:\path\to\my\folder\</TestZipPath>
  <ExcludeList>$(TestZipPath)\**\_svn\**;$(TestZipPath)\**\.svn\**;$(TestZipPath)\**\obj\**;$(TestZipPath)\**\*.config</ExcludeList>
</PropertyGroup>

<ItemGroup>
  <ZipFiles Include="$(TestZipPath)\**\*.*" Exclude="$(ExcludeList)"  />
</ItemGroup>

<Message Text="%(ZipFiles.FullPath)"/>

That seems hideously verbose to me. Ideally I would want the ExcludeList to be formatted like this:

<ExcludeList>**\_svn\**;**\.svn\**;**\obj\**;**\*.config</ExcludeList>

But it doesn't seem to work. Why do I need to include $(TestZipPath) before every exclude pattern? Is ** not intended to be used at the beginning of a path? Is there a better way to do this?

Upvotes: 3

Views: 1730

Answers (2)

RationalGeek
RationalGeek

Reputation: 9599

I figured out the problem. The issue is that I am trying to include files that are not relative to the msbuild file that I'm executing. MSBuild assumes that file paths are relative to this location and gives you no way to change that. Because of this, all of my paths have to be absolute and can't be relative.

Upvotes: 4

Ludwo
Ludwo

Reputation: 6173

Try to add '.\' before every include pattern. Like this:

 '.\**\obj\**'

Upvotes: 1

Related Questions