我想要命令行来使用 msbuild 构建解决方案的特定项目,就像我们对 devenv.com 所做的那样。在 devenv.com 中,我们可以使用以下命令行指定解决方案的项目
devenv.com /Build Release|x86 test.sln /project "testproject"
使用上面的命令行,我可以使用 devenv.com 在 test.sln 中构建 testproject。相同解决方案的 msbuild 命令行是什么。
谢谢
最佳答案
msbuild test.sln /t:project /p:Configuration="Release" /p:Platform="x86" /p:BuildProjectReferences=false
请注意,分配给/t
的是解决方案中的项目名称,它可以与项目文件名不同。
另外,如 How to: Build specific targets in solutions by using MSBuild.exe 中所述:
If the project name contains any of the characters
%
,$
,@
,;
,.
,(
,)
, or'
, replace them with an_
in the specified target name.
您也可以一次构建多个项目:
msbuild test.sln /t:project;project2 /p:Configuration="Release" /p:Platform="x86" /p:BuildProjectReferences=false
要重建或清理,请将 /t:project
更改为 /t:project:clean
或 /t:project:rebuild
https://stackoverflow.com/questions/13915636/