Create a text file named "Microsoft.CppBuildEx.targets" that contains the following text:
<!--
***********************************************************************************************
Microsoft.CppBuildEx.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
This file modifies the steps/targets required to build Visual C++ projects.
Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Overrides existing "SetToGetNativeTargetPath" to set 'DesignTimeBuild_GetNativeTargetPath' flag for all C++ projects reference.
SetToGetNativeTargetPath is only called during design time build. -->
<Target Name="SetToGetNativeTargetPath" >
<ItemGroup>
<ProjectReference>
<AdditionalProperties Condition="'%(Extension)' == '.vcxproj'">DesignTimeBuild_GetNativeTargetPath=true</AdditionalProperties>
</ProjectReference>
</ItemGroup>
</Target>
<!-- Overrides existing "GetTargetPath" to return TargetPath if the project is managed or
returns TargetPath if DesignTimeBuild_GetNativeTargetPath is true. -->
<Target Name="GetTargetPath" DependsOnTargets="_DetermineManagedStateFromCL" Returns="@(ManagedTargetPath)" >
<ItemGroup>
<ManagedTargetPath Include="$(TargetPath)" Condition="'$(ManagedAssembly)' == 'true' or '$(DesignTimeBuild_GetNativeTargetPath)' == 'true'" />
</ItemGroup>
</Target>
</Project>
Add the Microsoft.CppBuildEx.targets file to each of these folders (create the folders if needed):
32-bit (x86) Windows:
%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Itanium\ImportAfter
%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\ImportAfter
%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\ImportAfter
64-bit (x64) Windows:
%ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Itanium\ImportAfter
%ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\ImportAfter
%ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\ImportAfter