Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build visual studio solution file .sln command line with selected project

I have .sln file which has around 352 projects. I have created batch file below "C:/Windows/Microsoft.NET/Framework/v4.0.30319/msbuild.exe myproj.sln /nologo /t:Build /p:Configuration="Debug" /property:Platform="Win32" pause"

But this builds all the projects from solution. I have configured "Configuration Manager" to unselect unwanted projects or unload project and used above batch file to build but that did not serve the purpose.

I have searched MSBuild options but could not find exact answer.

Can anyone help me in this ?

like image 358
void Avatar asked Nov 01 '25 15:11

void


1 Answers

MSbuild accepts project name as part of "target" (/t) specification:

MSBuild /nologo /t:ProjectName:Build SolutionFile.sln

Or, if your project does not depend on the other projects in the solution, use project file directly with MSBuild:

MSBuild /nologo /t:Build ProjectFile.vcxproj

This trick works with Visual Studio 2010, 2012, 2013, 2015, 2017, 2019 and with the latest MSVS 2022.

like image 94
Karlson2k Avatar answered Nov 04 '25 02:11

Karlson2k



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!