发生了什么
WindowsSdkDir 是一个 Visual Studio 内部变量,它源自基于“平台工具集”项目属性(在“配置属性/常规”下)的注册表项。对于“Visual Studio 2012 (v110)”平台工具集,注册表项如:
HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0
HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0
HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.0
HKCU\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.0
无论CurrentVersion 和CurrentInstallFolder 键如何使用。
如何使用 Visual Studio 2012 针对 Windows 8.1 SDK 进行构建
如this blog中所述:
VS 2010/2012 用户:您可以使用最初用于 VS 2010+Windows 8.0 SDK 的 Visual C++ Team blog post 中描述的 Windows 8.1 SDK 的属性表技术。对于 VS 2010,只需将带有“8.0”/“win8”的路径部分更改为“8.1”/“winv6.3”,否则使用所有这些说明。对于 VS 2012,您可以简化所有路径,只需在每个变量的现有值之前添加 8.1 路径。更新的 .props 附在这篇博文中。这应该只用于 Win32 桌面应用程序开发。
进行这些更改后,您应该得到一个属性表(也作为same blog 的附件提供),对于 x86,它看起来像:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<ExecutablePath>$(ProgramFiles)\Windows Kits\8.1\bin\x86;$(ExecutablePath)</ExecutablePath>
<IncludePath>$(ProgramFiles)\Windows Kits\8.1\Include\um;$(ProgramFiles)\Windows Kits\8.1\Include\shared;$(ProgramFiles)\Windows Kits\8.1\Include\winrt;$(IncludePath)</IncludePath>
<LibraryPath>$(ProgramFiles)\Windows Kits\8.1\lib\winv6.3\um\x86;$(LibraryPath)</LibraryPath>
<ExcludePath>$(ProgramFiles)\Windows Kits\8.1\Include\um;$(ProgramFiles)\Windows Kits\8.1\Include\shared;$(ProgramFiles)\Windows Kits\8.1\Include\winrt;$(ExcludePath)</ExcludePath>
</PropertyGroup>
<ItemDefinitionGroup />
</Project>
对于 x64 也是如此:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<ExecutablePath>$(ProgramFiles)\Windows Kits\8.1\bin\x64;$(ExecutablePath)</ExecutablePath>
<IncludePath>$(ProgramFiles)\Windows Kits\8.1\Include\um;$(ProgramFiles)\Windows Kits\8.1\Include\shared;$(ProgramFiles)\Windows Kits\8.1\Include\winrt;$(IncludePath)</IncludePath>
<LibraryPath>$(ProgramFiles)\Windows Kits\8.1\lib\winv6.3\um\x64;$(LibraryPath)</LibraryPath>
<ExcludePath>$(ProgramFiles)\Windows Kits\8.1\Include\um;$(ProgramFiles)\Windows Kits\8.1\Include\shared;$(ProgramFiles)\Windows Kits\8.1\Include\winrt;$(ExcludePath)</ExcludePath>
</PropertyGroup>
<ItemDefinitionGroup />
</Project>
但请注意。虽然这将定义针对 Windows 8.1 SDK 构建所需的所有路径,但它不会更改仍指向 Windows 8.0 SDK 的 WindowSdkDir 和相关宏。如果您使用这些宏来定义项目属性,这可能会导致构建不一致。
最后,请注意 Visual Studio 2013 附带 Windows 8.1 SDK,相应地,它是与默认“Visual Studio 2013 (v120)”平台工具集属性一起使用的 SDK。因此,如果可以选择升级到 VS2013,那可能会为您省去一些麻烦。