Create only one project in a command line solution

I have a solution with many folders with many C # projects.

How to create / rebuild only one of these projects from the command line?

I assume there is a way to do this with msbuild , but I don't know anything about msbuild.

Thank!

+28
c # visual-studio-2010 msbuild
Apr 05 '11 at 20:26
source share
4 answers

You can just call msbuild and pass it the project file .csproj / .vbproj that you want to build, and it will only do this.

So something like:

 cd \MySolution msbuild .\Project1\Project1.csproj 
+17
Apr 05 2018-11-21T00:
source share
— -

Given the solution file with the projects in it, and you want to build / rebuild one project.

This MSDN webpage lists exactly what you need to do:

http://msdn.microsoft.com/en-us/library/ms171486.aspx

So, the given mysolution.sln solution file with projects:

  • foo.vcxproj
  • bar.vcxproj
  • baz.vcxproj

where they all depend on each other in the lower and upper order. So baz is the most independent, bar depends on baz and foo depends on bar .

If you want to build foo, then you do:

 MSBuild mysolution.sln /target:foo 

Other answers here did not account for dependencies. Of course, msbuild.exe will build one project file (i.e. Foo.vcxproj), but it will not work if the bar and the base have not been built yet. To build several projects and first create independent projects, you need to transfer the solution to the file (after the OP mentioned that it is part of the solution file). Then pass the project name and the target, separated by a colon.

 MSBuild mysolution.sln /target:foo:Rebuild 

Great guess here. I assume that the project name $ (project_name) matches the project name.

Edit (from comment ) . If there are periods (.) In the project name, you will need to replace them with an underscore (_).

+70
May 23 '13 at 17:33
source share

You can refer to this link to learn more about using MSBuild from the command line. Here is an example of what you need:

 MSBuild.exe MyProject.proj /t:rebuild 
+2
Apr 05 2018-11-11T00:
source share

Publishing Information to Future Seekers

set MSBuildEmitSolution = 1

stack overflow

+1
Nov 02 '16 at 5:20
source share



All Articles