Force msbuild to create a project that is not selected in the solution configuration

I use msbuild on the command line to create the generated solution file:

msbuild /p:Configuration=Release /p:Platform=Win32 build\zlib\vc-9.0\x86\zlib.sln 

The problem is that the solution created by cmake has an INSTALL project, which is not created by default.

 minigzip: Die Datei "c:\Library\build\zlib\vc-9.0\x86\minigzip.tmp_Release_Win32.vcproj " wird gelöscht. ALL_BUILD: Die Datei "c:\Library\build\zlib\vc-9.0\x86\ALL_BUILD.tmp_Release_Win32.vcpro j" wird gelöscht. INSTALL: The project "INSTALL" is not selected for building in solution configuration "Release|Win32". Done Building Project "c:\Library\build\zlib\vc-9.0\x86\zlib.sln" (default targ ets). Build succeeded. 0 Warning(s) 0 Error(s) 

How can I make the target INSTALL build without manually opening the soul and set a checkbox for the configuration?

One solution is to directly call the vcproj file (as I am here)

 msbuild /p:Configuration=Release /p:Platform=Win32 build\zlib\vc-9.0\x86\INSTALL.vcproj 

but it displays a warning

 Microsoft (R)-Buildmodul, Version 3.5.30729.6387 [Microsoft .NET Framework, Version 2.0.50727.6400] Copyright (C) Microsoft Corporation 2007. Alle Rechte vorbehalten. Build started 06.07.2013 17:07:57. Project "c:\Library\build\zlib\vc-9.0\x86\INSTALL.vcproj" on node 0 (default ta rgets). c:\Library\build\zlib\vc-9.0\x86\INSTALL.vcproj : warning MSB4098: MSBuild is i nvoking VCBuild to build this project. Project-to-project references between VC ++ projects (.VCPROJ) and C#/VB/VJ# projects (.CSPROJ, .VBPROJ, .VJSPROJ) are n ot supported by the command-line build systems when building stand-alone VC++ p rojects. Projects that contain such project-to-project references will fail to build. Please build the solution file containing this project instead. Done Building Project "c:\Library\build\zlib\vc-9.0\x86\INSTALL.vcproj" (defaul t targets). Build succeeded. 

As you can see, the assembly was successful. I can ensure the correct assembly by first invoking the solution, but I want to force the solution to also create the INSTALL project.

Any ideas?

+8
visual-studio cmake msbuild
source share
3 answers

As far as I know, this is not possible. Considering the msbuild command line options and in the solution file, it is not supported. But since you are using cmake, you can use it to create everything for you without having to do it manually. I found this thread , which basically asks the same question as you, and has the correct syntax using the idea, I already added a comment:

 cmake --build . --target install 

Looking a little further, from the options devenv cmmand line, it seems they have the functionality that you use. This forces the build of this project, even if it is not included in Configuration Manager:

 devenv build\zlib\vc-9.0\x86\zlib.sln /Build Release /project INSTALL 
+9
source share

stijn answer is an “idiomatic” way to build goals through cmake.

Please note that MSbuild can create project and file files. Instead of calling msbuild zlib.sln you can also call msbuild ALL_BUILD.vcxproj .

Similarly, you can call msbuild INSTALL.vcxproj .

+3
source share

Using the solution generated by CMake version 3.2.2, it is really not possible to build the INSTALL target from msbuild through the solution. The main reason is that for the purpose of INSTALL, the solution contains only entries in the GlobalSection (ProjectConfigurationPlatforms) section:

  {11C4D30A-3B6A-4350-BD7D-B343F3A843C0}.Debug|Win32.ActiveCfg = Debug|Win32 

If you add these elements:

  {11C4D30A-3B6A-4350-BD7D-B343F3A843C0}.Debug|Win32.Build.0 = Debug|Win32 

Then it becomes possible to create an INSTALL target with the following command:

  msbuild <pathToProject>.sln /target:INSTALL 
+2
source share

All Articles