VS 2010 and 2013 side by side

Posted on
PL

I recently attempted to upgrade my aging install of VS 2010 to the latest 2013 (mostly because of an STL-heavy project that could really benefit from some C++11 range-based for).

Visual Studio 2012 changed the basic locations of include/library paths, and as a result solution properties need to be updated to point to these new paths. There is a chain of property files determining which include/library paths are loaded, and the SDK paths are contained in the systemwide %APPDATA%\Microsoft\MSBuild\v4.0\Microsoft.Cpp.{$arch}.user.props properties file. This file is by default inherited by all projects and is applied regardless of Platform Toolset.

However, this file is used by both 2010 and 2012/2013 versions of Visual Studio. When installing Visual Studio 2012/2013 while 2010 is still installed, the files are not updated; so projects in 2012/2013 still refer to the old paths; and as a result all projects using the v110/v120 toolchain will fail to build with e.g. LNK1104: cannot open file 'kernel32.lib' or something similar.

One good solution suggested in [3] below is to modify the property file to use conditional definitions in such a way that both 2010 and 2012/2013 toolchains can be supported.

For reference, the final contents of my Microsoft.Cpp.Win32.user.props file is as follows:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WindowsSDK_IncludePath Condition="$(WindowsSDK_IncludePath) == ''">$(WindowsSdkDir)include</WindowsSDK_IncludePath>
    <IncludePath>$(DXSDK_DIR)\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);$(FrameworkSDKDir)\include;</IncludePath>
  </PropertyGroup>
  <PropertyGroup>
    <WindowsSDK_LibraryPath_x86 Condition="$(WindowsSDK_LibraryPath_x86) == ''">$(WindowsSdkDir)lib</WindowsSDK_LibraryPath_x86>
    <LibraryPath>$(DXSDK_DIR)\lib\x86;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSDK_LibraryPath_x86);$(FrameworkSDKDir)\lib</LibraryPath>
  </PropertyGroup>
</Project>

Now new and existing projects build correctly using any installed toolchain (VS2010/v100, VS2010/SDK7.1, VS2013/v100, VS2013/SDK7.1 and VS2013/v120).

References

  1. “Visual Studio 2012 alongside 2010 - kernel32.lib, windows.h” http://stackoverflow.com/q/13426740
  2. “Include and Libraries Directories not setup correctly for C++ if VS2010 already installed” http://connect.microsoft.com/VisualStudio/feedback/details/762015/
  3. “Microsoft.Cpp.Win32.user property sheet file shared by both VS2010 and VS2012?” http://social.msdn.microsoft.com/forums/vstudio/en-US/4a63bf74-23d1-4f85-aee9-c83cc0f99dad