visual studio 2010 - Force project to always build using VS2012/VC11 when using MSBuild -
note: related well known vs2010/vs2012 problem of, under circumstances, having specify /p:visualstudioversion=11.0
when using msbuild build c++/cli applications.
problem: when building vs2012 c++/cli application using msbuild task referring c++/cli project file need add /p:visualstudioversion=11.0
msbuild command line, otherwise error:
error msb8008: specified platform toolset (v110) not installed or invalid. please make sure supported platformtoolset value selected.
this shows when building on machines both vs2010 , vs2012 installed, , developer command prompt vs2012
or after calling %vs110comntools%\vsvars32.bat
myself.
obviously know workaround already, rid of requirement of specifiying the same additional command-line argument time.
some details: have .proj file sets msbuild task building c++/cli application. here's meat of (let's call 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 not complete, it's illustration. problem setting property visualstudioversion msbuild task above doesn't help. still same msb8008 error. unless ... yeah, using msbuild foo.proj /p:visualstudioversion=11.0
.
is possible fix somehow - missing here? go editing individual .vcxproj files if knew how (i have tried already).
depends on level want fix it.
in microsoft.cpp.platform.targets there import statement can use:
<import condition="'$(_toolsetfound)' == 'true' , exists('$(_platformfolder)importafter')" project="$(_platformfolder)importafter\*.targets"/>
which imports *.targets files specific platform-dependent importafter folder. can define simplest file sets properties on global level (for .vcpproj files)
edit1 content of such file, can name way want, ensure matches above wildcard
*.targets.
has figure out correct path file (find what's path in$(_platformfolder)
property
<?xml version="1.0" encoding="utf-8"?> <project toolsversion="4.0" defaulttargets="build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <propertygroup><visualstudioversion>11.0</visualstudioversion></propertygroup> </project>
/edit1
or can use import microsoft.cpp.current.targets
<import condition=" '$(forceimportaftercpptargets)' != '' , exists('$(forceimportaftercpptargets)')" project="$(forceimportaftercpptargets)"/>
declare $(forceimportaftercpptargets)
property points single specific file override every platform.
edit2 approach better if want affect build script - have same (put file in edit1) , pass path file via
$(forceimportaftercpptargets)
property. build script have this:
<msbuild projects="@(cxxprojects) properties="forceimportaftercpptargets=path_to_my_targets"/>
/edit2
or can create corresponding environment variable - msbuild emits properties environment variables
hope helps.
ps: if can produce msbuild log /verbosity:diag
may , lot - mush easier see full , detailed log. 2 sets of logs - 1 successful build results , 1 failed more
Comments
Post a Comment