[英]How do I specify "any Windows SDK version greater than 10.0" in a Visual Studio c++ project?
Developers here have different SDKs installed, I want my Visual Studio projects to use any available SDK greater than 10.0, without the need to specify exactly which one.这里的开发人员安装了不同的 SDK,我希望我的 Visual Studio 项目使用任何大于 10.0 的可用 SDK,而无需确切指定是哪一个。 Is there a way to do this?
有没有办法做到这一点?
In the vcxproj file:在 vcxproj 文件中:
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
For Visual Studio 2017, you must use a specific SDK version number in your vcxproj file.对于 Visual Studio 2017,您必须在 vcxproj 文件中使用特定的 SDK 版本号。 However there is a workaround by Antonio Sanchez for the Windows 10 SDK in the comments of this post: https://developercommunity.visualstudio.com/comments/190992/view.html
但是,Antonio Sanchez 在这篇文章的评论中为 Windows 10 SDK 提供了一种解决方法: https : //developercommunity.visualstudio.com/comments/190992/view.html
<PropertyGroup Condition="'$(WindowsTargetPlatformVersion)'==''">
<!-- Latest Target Version property -->
<LatestTargetPlatformVersion>
$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))
</LatestTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)' == ''">
$(LatestTargetPlatformVersion)
</WindowsTargetPlatformVersion>
<TargetPlatformVersion>
$(WindowsTargetPlatformVersion)
</TargetPlatformVersion>
</PropertyGroup>
For Visual Studio 2019, you can specify the most recent version of the Windows 10 SDK by using a value of 10.0.对于 Visual Studio 2019,您可以使用值 10.0 指定最新版本的 Windows 10 SDK。 For example:
例如:
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
The current design requires your vcxproj contain a specific version number. 当前设计要求您的vcxproj包含特定版本号。
Since your project is for VS 2017 (based on the v141
platform toolset), there's no reason to use something as old as 15086. If someone installs a fresh copy of VS 2017 today (15.9 update), they will have the Windows 10 SDK (10.0.17763) by default. 由于您的项目是针对VS 2017(基于
v141
平台工具集),因此没有理由使用旧版本15086.如果有人今天安装了VS 2017的新副本(15.9更新),他们将拥有Windows 10 SDK( 10.0.17763)默认情况下。 The only time they would have 10.0.15806 installed by default is if they had installed VS 2017 (15.1 update) and never updated it. 他们默认安装10.0.15806的唯一一次是他们安装了VS 2017(15.1更新)并且从未更新过它。
The only time it makes sense to stick with an older Windows 10 SDK in a vcxproj is for VS 2015 projects because 10.0.14493 was the last release that officially supports VS 2015. 唯一一次在vcxproj中坚持使用旧的Windows 10 SDK是有意义的,因为10.0.14493是官方支持VS 2015的最后一个版本。
Remember also that for Win32 desktop applications, the Windows 10 SDK (17763) still targets the same versions of Windows that the Windows 10 SDK (15086) did: Windows 7 SP1, Windows 8.x, Windows 10. 还要记住,对于Win32桌面应用程序,Windows 10 SDK(17763)仍然针对Windows 10 SDK(15086)所执行的Windows版本:Windows 7 SP1,Windows 8.x,Windows 10。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.