10

I have a solution contains 10 projects and would like to exclude 1 or 2 projects when building the solution. The issue is that I'm building the solution in command line and would like to run it once partially (not all projects) and the next time it should run as is - all projects will be built. (I'm using MSBuild.exe)

Does any of you know of such a way to do it using command line (and not using VS interface)?

Are there any command line arguments to exclude these projects?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
ShaiO
  • 153
  • 1
  • 10
  • See also [this related SO question and answers](https://stackoverflow.com/questions/9778916/how-to-exclude-project-from-build-in-msbuild). – Uwe Keim Mar 17 '19 at 14:27

1 Answers1

10

You can use the /target or /t switch to specify which solutions you want to build.

For example to build two projects "WebApps\MyWebApp.vcproj" and "WebServices\MyWebService.vcproj" you can do:

msbuild.exe Solution.sln /t:WebApps\MyWebApp.vcproj:Build;WebServices\MyWebService.vcproj

Therefore to exclude 2 of 10 projects, you simply list the 8 you wish to build.

Ben
  • 34,935
  • 6
  • 74
  • 113