简体   繁体   中英

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 (eg 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM