Exclude folder from site build with MSBuild
We use MSBuild to build our solutions through CruiseControl. We have multiple assemblies and a website as part of the solution. VS2008 is building successfully. However, in the build window, we get the following error.
ASPNETCOMPILER (,):
errorASPCONFIG: The CodeDom provider type "Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" could not be located.
The reason for this is that we have a couple of .java files in the scripts folder on the website. We don't want these files to be created. Indeed, we don't need anything in the scripts folder.
Is there a way to exclude the possibility of creating a folder or extension from a website project? Or tell MSBuild to follow the same rules that VS2008 uses to decide what to compile?
source to share
You can use Web Deployment Projects for this . In WDP, you can use the ExcludeFromBuild element to exclude these files. See http://msdn.microsoft.com/en-us/library/aa479568.aspx for more information .
source to share
You can delete entire folders with the Remove Item element attribute ( quick introduction on MSDN ).
For example, if you have elements defined like this:
<ItemGroup>
...
<Compile Include="Tests\Test1.cs" />
<Compile Include="Tests\SubTests\SubTest1.cs" />
...
</ItemGroup>
and you want to exclude all classes from the Tests folder, you can define a task at the end of your project:
...
<PropertyGroup>
<CoreCompileDependsOn>$(CoreCompileDependsOn);ExcludeTestsFolder</CoreCompileDependsOn>
</PropertyGroup>
<Target Name="ExcludeTestsFolder">
<ItemGroup>
<Compile Remove="Tests\**\*.cs" />
</ItemGroup>
</Target>
</Project>
It is also helpful to define such a task in an external file and import it using the Import element ( explained in detail in another thread ).
source to share
Inside the assembly file, there will be a group of items with matching items. Just edit the file to exclude this element.
For example :
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Res Include = "Strings.fr.resources" >
<Culture>fr</Culture>
</Res>
<Res Include = "Dialogs.fr.resources" >
<Culture>fr</Culture>
</Res>
<CodeFiles Include="**\*.cs" Exclude="**\generated\*.cs" />
<CodeFiles Include="..\..\Resources\Constants.cs" />
</ItemGroup>
...
</Project>
Edit: Correction for answering comment.
If you only have a sln file, can you create a meta msbuild script that moves the files aside, invokes a task to build your solution, and then returns them?
source to share