I need to exclude abc.Test.csproj
from the .sln
file during team build compilation.
I have tried using /ignoreprojectextensions=.Test.csproj
, but doesnt work for my purpose. Please help me in accomplishing this.
You would create a new Configuration (Debug and Release are the default ones) and in this new Configuration, you would not-build the specified .csproj.
Then you would build to that Configuration.
See:
Does Msbuild recognise any build configurations other than DEBUG|RELEASE
APPEND
WITHOUT doing a new/custom Configuration, this is the only solution I can reason.
Put the below xml'ish code .. in a file called "MyBuild.proj" , save it, and then call
msbuild.exe MyBuild.proj
..
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapped">
<PropertyGroup>
<WorkingDirectory>.</WorkingDirectory>
</PropertyGroup>
<Target Name="AllTargetsWrapped">
<CallTarget Targets="ShowReservedProperties" />
<CallTarget Targets="BuildOtherProjects" />
</Target>
<Target Name="BuildOtherProjects">
<ItemGroup>
<ProjectReferencesExcludes Include="$(WorkingDirectory)\UnitTests.csproj" />
<ProjectReferencesExcludes Include="$(WorkingDirectory)\SomeOtherProject.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReferences Include="$(WorkingDirectory)\**\*.*proj" Exclude="@(ProjectReferencesExcludes)" />
</ItemGroup>
<Message Text="List of projs to be built:"/>
<Message Text="@(ProjectReferences->'"%(fullpath)"' , '%0D%0A')"/>
<Message Text=" "/>
<Message Text=" "/>
<MSBuild
Projects="@(ProjectReferences)"
Targets="Build">
<Output
TaskParameter="TargetOutputs"
ItemName="AssembliesBuiltByChildProjects" />
</MSBuild>
<Message Text=" "/>
<Message Text=" "/>
<Message Text="List of AssembliesBuiltByChildProjects:"/>
<Message Text="@(AssembliesBuiltByChildProjects->'"%(fullpath)"' , '%0D%0A')"/>
<Message Text=" "/>
<Message Text=" "/>
</Target>
<Target Name="ShowReservedProperties">
<Message Text="MSBuild: $(MSBuild)"/>
<Message Text="MSBuildBinPath: $(MSBuildBinPath)"/>
<Message Text="MSBuildExtensionsPath: $(MSBuildExtensionsPath)"/>
<Message Text="MSBuildExtensionsPath32: $(MSBuildExtensionsPath32)"/>
<Message Text="MSBuildExtensionsPath64: $(MSBuildExtensionsPath64)"/>
<Message Text="MSBuildLastTaskResult: $(MSBuildLastTaskResult)"/>
<Message Text="MSBuildNodeCount: $(MSBuildNodeCount)"/>
<Message Text="MSBuildOverrideTasksPath: $(MSBuildOverrideTasksPath)"/>
<Message Text="MSBuildProgramFiles32: $(MSBuildProgramFiles32)"/>
<Message Text="MSBuildProjectDefaultTargets: $(MSBuildProjectDefaultTargets)"/>
<Message Text="MSBuildProjectDirectory: $(MSBuildProjectDirectory)"/>
<Message Text="MSBuildProjectDirectoryNoRoot: $(MSBuildProjectDirectoryNoRoot)"/>
<Message Text="MSBuildProjectExtension: $(MSBuildProjectExtension)"/>
<Message Text="MSBuildProjectFile: $(MSBuildProjectFile)"/>
<Message Text="MSBuildProjectFullPath: $(MSBuildProjectFullPath)"/>
<Message Text="MSBuildProjectName: $(MSBuildProjectName)"/>
<Message Text="MSBuildStartupDirectory: $(MSBuildStartupDirectory)"/>
<Message Text="MSBuildThisFile: $(MSBuildThisFile)"/>
<Message Text="MSBuildThisFileDirectory: $(MSBuildThisFileDirectory)"/>
<Message Text="MSBuildThisFileDirectoryNoRoot: $(MSBuildThisFileDirectoryNoRoot)"/>
<Message Text="MSBuildThisFileExtension: $(MSBuildThisFileExtension)"/>
<Message Text="MSBuildThisFileFullPath: $(MSBuildThisFileFullPath)"/>
<Message Text="MSBuildThisFileName: $(MSBuildThisFileName)"/>
<Message Text="MSBuildToolsPath: $(MSBuildToolsPath)"/>
<Message Text="MSBuildToolsVersion: $(MSBuildToolsVersion)"/>
</Target>
</Project>
Note, that if you put a csproj in the Exclude list BUT another csproj references/depends on it, it will be built (regardless of what you "exclude").