20
votes

I am developing a command line application that creates a full Visual Studio 11 solution made of a single VC++ project and that tries to compile it in the end using MSBuild.

The problem I am facing is strange.

If I execute my command line program inside Visual Studio 11 it works; if I instead launch it outside the development environment it throws me the error:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(511,5): error MSB8008: Specified platform toolset (v110) is not installed or invalid. Please make sure that a supported PlatformToolset value is selected. [f:\ABC.vcxproj]

The command I am using is the following:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe f:\snake\W9A30040.vcxproj /property:PlatformToolset=v110;Configuration=Debug /v:quiet

But I have the feeling that PlatformToolset=v110 is ignored and MSBuild use v100 (Visual Studio 2010).

Do you have any suggestions how to tell MSBuild to compile for v110 Platform Toolset?

6

6 Answers

25
votes

I ran into the same problem as well with the full release of VS 2012. You can also set the VisualStudioVersion as a property with MSBuild as opposed to dealing with environment variables as mentioned in the accepted answer. For instance:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\myproject.vcxproj /p:VisualStudioVersion=11.0

The environment variables approach I'm sure work just as well, I honestly didn't try that as I was trying to stay away from having to modify the environment variables.

12
votes

Make sure that the top of your .SLN file looks like this:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012

When you double-click on the solution file, it's the # Visual Studio 2012 that controls which version of Visual Studio is loaded (and controls the icon displayed in Windows Explorer).

However, when you run MSBuild, it looks at the Format Version 12.00 part.

Confused?

This is confusing, since Visual Studio 2010 is version 10.0 and Visual Studio 2012 is version 11.0 (not 12.0), and using the version 12.0 solution file format causes MSBuild to (implicitly) set VisualStudioVersion to 11.0.

9
votes

I found a workaround for this issue; could be a problem of Visual Studio 11 Beta that will be resolved before official release.

Anyway, if you are interestedm just set the environment variable "VisualStudioVersion" equal to "11.0" before calling MSBuild.exe.

In batch files

set VisualStudioVersion=11.0

or in VB.NET

Environment.SetEnvironmentVariable("VisualStudioVersion", "11.0")
3
votes

Starting with Visual Studio 2013, MSBuild is now part of Visual Studio, and the correct path should be $(MSBuildToolsPath) (“C:\Program Files (x86)\MSBuild\12.0\Bin”). If you use msbuild.exe from the .Net framework folder (“C:\Windows\Microsoft.NET\Framework64\v4.0.30319”) it will not able to distinguish the vs2012 and vs2013 versions.

1
votes

Use the menu based options to do this. From VC++2010 Express: - Right click on the main file of the project (not the solution itself at the very top of the tree). - Click General. - Find Platform Toolset on the right side of the dialog, top half. - Change from v110 to v100. - Click OK.

----- Done ------

0
votes

Microsoft provides a batch file to set all the EnvVars You find it in the Start Menu under "Microsoft Visual Studio 2012/Visual Studio Tools" or in the Visual Studio folder ("C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat")