简体   繁体   English

如何在 Visual Studio c++ 项目中指定“任何大于 10.0 的 Windows SDK 版本”?

[英]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.

相关问题 用于检查Windows版本然后仅在版本10.0(2016或更高版本)上执行操作的脚本 - Script to check Windows version and then do action on only version 10.0 (2016 or greater) 任何Windows版本上的Visual Studio 2013:C应用程序 - Visual Studio 2013: C Application on any Windows version 如何在 Visual C++ 项目中定义和加载资源? - How do I define and load a resource in a Visual C++ project? 如何从 C++ 获取 Windows 上的驱动程序版本 - How do I get the version of a driver on Windows from C++ 如何为Windows C ++安装当前版本的OpenGL? - How do I install a current version of OpenGL for Windows C++? 在 Windows 主页上 Dockerize 一个 Visual Studio C++ 项目 - Dockerize a Visual Studio C++ project on Windows home 如何在 Windows 11 PC 上将 fltk 图形库与 Visual Studio(社区)2022 一起用于 C++ 项目 - How to use fltk graphic library with visual studio (community) 2022 for C++ project on Windows 11 PC 升级到 Windows 10 版本 1809 SDK 后,我无法编译使用 C++/WinRT 的项目 - I can't compile my project which uses C++/WinRT after upgrading to Windows 10, version 1809 SDK 如何安装Windows Store &#39;10 .0&#39;SDK - How to install Windows Store '10.0' SDK C ++ Windows,使用mingw编译为静态库,并包含在Visual Studio C ++项目中 - c++ windows, compile with mingw as static library and include in visual studio c++ project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM