views:

243

answers:

1

I added an ItemGroup for ExcludeFromBuild items in the PreBuild target in my Web Deployment project:

<ItemGroup>
  <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\Test\**\*.*" />
</ItemGroup>

After the build the assembly in the output still contains the compiled classes from the files in ~/Test. That's not what I expected.

Here is a snippet from Using Web Deployment Projects with Visual Studio 2005 on MSDN:

For example, by adding the following section to a Web Deployment project, you can exclude the Test and Images folder from the build process:

<ItemGroup>
 <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\Test\**\*.*"/>
 <ExcludeFromBuild  Include="$(SourceWebPhysicalPath)\Images\**\*.*"/>
</ItemGroup>

This is useful if you have test code in the Web site project that should not be included in the staging or release builds.

Seems not work that way for me though. Am I missing something obvious?

A: 

Never mind, I have found the problem. The ExcludeFromBuild item group is evaluated in the _CopyBeforeBuild target, which is called before the BeforeBuild target.

Doh!

michielvoo