14
votes

I am working on a solution in Visual Studio that contains a number of projects:

Solution.sln:

  • -> ProjectInc1.csproj
  • -> ProjectInc2.csproj
  • -> ProjectExc1.csproj
  • -> ProjectExc1.csproj

I work on all projects and when I make a push on my VCS (Github in my case) it triggers a build configuration on a CI server (TeamCity in my case). TeamCity server uses MSBuild, that takes the Solution.sln as parameter and builds it. However I want certain projects (e.g. ProjectExc1.csproj, ProjectExc2.csproj) to be ignored from build. I can do this step if I remove the project references from Solution.sln file, but I think there must be a better way to exclude from build certain project.

Does anyone know how to configure MSBuild or the Solution itself to ignore these projects when building the solution on the CI Server?

1
possible duplicate of How to exclude project from build in MSBUILD? - so either you create a new solution containing only the projects you need, or you write an msbuild script that builds just those you needstijn
Yes, on the first run that solution did not worked but after checking the dependencies carefully it worked.Tamas Ionut

1 Answers

18
votes

In Visual Studio create a new build configuration (from http://msdn.microsoft.com/en-us/library/jj676765.aspx):

To create a solution configuration that excludes a project On the menu bar, choose Build, Configuration Manager. In the Active solution configuration list, choose . In the Name box, enter a name for the solution configuration. In the Copy settings from list, choose the solution configuration on which you want to base the new configuration (for example, Debug), and then choose the OK button. In the Configuration Manager dialog box, clear the check box in the Build column for the project that you want to exclude, and then choose the Close button. On the Standard toolbar, verify that the new solution configuration is the active configuration in the Solution Configurations box. On the menu bar, choose Build, Rebuild Solution.

Then in TeamCity, instead of building in Debug/Release set the configuration to build with your new build configuration name.

If you are calling from an MsBuild script, the same applies. Just change the configuration you are calling.