Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude projects from solution during build in MSBuild on a CI server

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?

like image 572
Tamas Ionut Avatar asked Mar 14 '14 08:03

Tamas Ionut


1 Answers

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.

like image 196
infojolt Avatar answered Nov 18 '22 21:11

infojolt