我的设置如下:
Windows 8.1,Microsoft Visual Studio 2012
我希望针对Windows 8.1 SDK进行构build。 我的应用程序是c + +,没有Windows运行时组件或类似的东西。
我已经安装了Windows 8.1 SDK,但Visual Studio正在针对Windows 7 SDK进行构build,因此要切换目标,请修改指向当前SDK版本的registry项:
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Microsoft SDKs \ Windows
但是,当我检查Visual Studio中的macros,它现在是build立在Windows SDK 8.0而不是8.1。
任何人都可以解释为什么这是发生? 我没有能够与我的设置对Windows 8.1 SDK的构build,是不是可以使用Visual Studio 2012? 我找不到任何确凿的信息来告诉我是否支持。
这是怎么回事
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
至于在这个博客中描述:
VS 2010/2012用户:您可以使用最初用于VS 2010 + Windows 8.0 SDK的Visual C ++ Team博客文章中描述的Windows 8.1 SDK的属性表技术。 对于VS 2010,只需将路径中的“8.0”/“win8”更改为“8.1”/“winv6.3”,否则使用所有这些指令。 对于VS 2012,您可以简化所有路径,只需在每个变量的现有值之前添加8.1路径即可。 更新后的.props附在这篇博文中。 这应该只用于Win32桌面应用程序开发。
在进行这些更改之后,您应该得到一个属性表(也作为附件提供给同一个博客 ),这对于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所需的所有路径,但它不会更改WindowSdkDir
和相关的宏,它们仍将指向Windows 8.0 SDK。 如果使用这些宏定义项目属性,这可能会导致构建不一致。
最后,请注意,Visual Studio 2013附带Windows 8.1 SDK,相应地,它是与默认的“Visual Studio 2013(v120)”平台工具集属性一起使用的SDK。 所以如果升级到VS2013是一个选项,那可能会为您节省一些麻烦。