How do I specify "any Windows SDK version greater than 10.0" in a Visual Studio c++ project?
Asked Answered
C

2

11

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. Is there a way to do this?

enter image description here

In the vcxproj file:

<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
Compendious answered 10/1, 2019 at 17:51 Comment(0)
A
15

For Visual Studio 2017, you must use a specific SDK version number in your vcxproj file. 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

<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. For example:

<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
Atropos answered 16/10, 2019 at 19:17 Comment(2)
The hint with 10.0 is nice, but unfortunately it doesn't work with VS2019 (16.5.3) when v140 toolset is invoked - the following error is shown: ...\PlatformToolsets\v140\Toolset.targets(34,5): error MSB8036: The Windows SDK version 10.0 was not found. ...Decretory
Moreover the toolset v140 isn't smart enough to strip surrounding whitespaces (line feeds, tabs, spaces, etc.) in the auto-detected platform version, so you'll have to rewrite the snippet so each MSBuild variable with its value sits in one line. And it finally works as expected, which is great! :)Decretory
P
3

The current design requires your vcxproj contain a specific version number.

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. 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.

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.

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.

Pathe answered 10/1, 2019 at 18:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.