Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build some project configurations with msbuild

The gtest's msvc directory has the gtest project file, and opening it with Visual Studio enables me to select the build out of 8 configurations(gtest/gtest_main/gtest_prod_test/gtest_unittest x release/debug) with Batch Build.

How can I do the same thing with msbuild tool? For example, how can I tell msbuild to build gtest/Debug or gtest_unittest/Release?

like image 837
prosseek Avatar asked Jan 12 '11 14:01

prosseek


People also ask

How do I create a project using MSBuild command line?

To build a specific target of a specific project in a solution. At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute.

How do I set properties in MSBuild?

MSBuild lets you set properties on the command line by using the -property (or -p) switch. These global property values override property values that are set in the project file. This includes environment properties, but does not include reserved properties, which cannot be changed.


2 Answers

MSBuild projectfile /property:Configuration=Debug 

http://msdn.microsoft.com/en-us/library/ms171452%28v=vs.80%29.aspx

like image 106
Kyle Alons Avatar answered Sep 23 '22 02:09

Kyle Alons


Kyle Alons's answer works fine. When I run solution file that has four projects, it generates the release version of each project.

msbuild gtest-md.sln /property:Configuration=Release 

I could run each project as follows, but the output names are based on solution name, so I need to modify to get correct results.

msbuild gtest-md.vcxproj /property:Configuration=Release 

The solution was to specify target as follows.

msbuild gtest-md.sln /target:gtest-md /property:Configuration=Release 
like image 43
prosseek Avatar answered Sep 22 '22 02:09

prosseek