How to invoke MSBuild.exe to target v110 platform toolset?
-
Monday, April 23, 2012 3:59 PMI 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.exe
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 uses by default v100 (Visual Studio 2010).
Do you have any suggestions how to force MSBuild to use v110 Platform Toolset?
All Replies
-
Tuesday, April 24, 2012 3:45 AMModerator
Hi,
I installed both VS11 and VS2010 on my machine, I can't repro your issue on my side. Both configuration build succeeded.
I suggest you reinstall your VS11 and see if it resolves your problem.
Regards,
Yi
Yi Feng Li [MSFT]
MSDN Community Support | Feedback to us
-
Tuesday, April 24, 2012 7:25 AM
I will try reinstall it if necessary; can you first give a look to MSBuild folder tree and compare it with your installation? It seems like v110 folder is not in the correct position.
-
Tuesday, April 24, 2012 9:34 AM
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 interested, just set the environment variable "VisualStudioVersion" equals to "11.0" before calling MSBuild.exe.
e.g.Environment.SetEnvironmentVariable("VisualStudioVersion", "11.0")
- Marked As Answer by marco.ragogna Tuesday, April 24, 2012 9:34 AM
-
Thursday, September 06, 2012 10:26 PM
I have a similar problem but the above thread doesn't seem to solve it. I have a Windows 7 box with both VS 2010 and VS 2012 installed. I have a VS 2010 solution file and related projects. If I open them in VS 2012 I am propmted to upgrade the solution filed and after doing that everything build fine.
However if I run "MSBuild /p:VisualStudioVersion=11.0 ....." pointing at the VS 2010 solution file it still uses the VS 2010 compiler not the VS 2012. I assume that this is because MSBuild won't dynamically upgrade the files. So my question is is there a separate command or some other way where I can use VS 2012 solution and property files but get MSBuild to use the VS 2012 compiler.
Note that diffing the VS 2010 and VS 2012 project files shows that the only change is to a couple of <PlatformToolset>v110</PlatformToolset> lines. I did try a /p:PlatformToolset=v110 on the MSBuild line but it says this toolset in unsupported, presumably because it's already decided is VS 2010.
As an update to the above
I suspect my issue may be related to the fact that the ".sln" solution file is not really an MSBuild file and seems to indicate what version you want to run in the first few lines that look like
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010I manually changed these to
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012and things seemed to work.
As I am a Jenkins user for builds, which build off the command line using MSBuild, I also started running
"%VS110COMNTOOLS%\..\IDE\devenv.exe" trunk\solution.sln /upgrade
on my project before running a normal build which did the trick for C++ projects but not for C# which remained targeting .NET 4.0. I noticed a few web sites moaning about this and requesting a way to upgrade a bunch of C# projects to a new .NET version. Anyway this can be worked around on a command line build by passing the arguments "/p:TargetFrameworkVersion=v4.5 /p:VisualStudioVersion=11.0" to MSBuild. I'm not really sure what VisualStudioVersion=11.0 does but it didn't seem to hurt.
- Edited by davidhunter22 Saturday, September 08, 2012 7:29 PM

