Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

enter image description here

In the vcxproj file:

<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
like image 789
rec Avatar asked Jan 10 '19 17:01

rec


2 Answers

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>
like image 112
jkhines Avatar answered Sep 30 '22 12:09

jkhines


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.

like image 39
Chuck Walbourn Avatar answered Sep 30 '22 12:09

Chuck Walbourn