Note: This is related to the well known VS2010/VS2012 problem of, under certain circumstances, having to specify /p:VisualStudioVersion=11.0
when using MSBuild to build C++/CLI applications.
Problem: When building my VS2012 C++/CLI application using the MSBuild task referring to a C++/CLI project file I need to add /p:VisualStudioVersion=11.0
to the MSBuild command line, otherwise I get this error:
error MSB8008: Specified platform toolset (v110) is not installed or invalid. Please make sure that a supported PlatformToolset value is selected.
This only shows up when building on machines with both VS2010 and VS2012 installed, and even from a Developer Command Prompt for VS2012
or after calling %VS110COMNTOOLS%\vsvars32.bat
myself.
Obviously I know the workaround already, but I would like to get rid of the requirement of specifiying the same additional command-line argument all the time.
Some details: I have a .proj file that sets up the MSBuild task for building the C++/CLI application. Here's the meat of it (let's call it Foo.proj
):
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<CxxProjects
Include="$(MSBuildThisFileDirectory)src\**\*.vcxproj"
/>
</ItemGroup>
<Target Name="build">
<MSBuild Projects="@(CxxProjects)
Properties="VisualStudioVersion=11.0"/>
</Target>
</Project>
The above is not complete, it's just for illustration. The problem is that setting the property VisualStudioVersion for the MSBuild task as above doesn't help. I still get the same MSB8008 error. Unless ... yeah, using MSBuild Foo.proj /p:VisualStudioVersion=11.0
.
Is it possible to fix this somehow - am I missing something here? I could even go for editing the individual .vcxproj files themselves if I only knew how (I have tried already).