Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the default Windows kit (SDK) version?

Tags:

c++

windows

I used to use Windows 8.1 SDK for my C++ application, and everything's working fine. Today I installed the Windows 10 SDK and I can't find a way to make it the default one.

I can hard-code the new SDK path in the Visual Studio project settings, but that is highly undesirable. I want the new kit to be used by default for every new project. There's no environment variable for the SDK, and I can't find anything in the registry, either.
More precisely, there are Windows SDK entries in the registry, but what I need - the C++ includes and libraries - is called the Windows Kit (located in C:\Program Files (x86)\Windows Kits).

like image 399
Violet Giraffe Avatar asked Jan 06 '16 11:01

Violet Giraffe


People also ask

Can I use Windows 11 SDK on Windows 10?

The Windows App SDK provides a unified set of APIs and tools that are decoupled from the OS and released to developers via NuGet packages. These APIs and tools can be used in a consistent way by any desktop app on Windows 11 and downlevel to Windows 10, version 1809.

Do I need Windows 10 SDK for C++?

Well, technically, you don't need the SDK. The most important pieces it offers you - API declarations, import libraries, etc, can be coded/obtained manually on an as-needed basis. The SDK simply provides the hard work already done for you. But it does offer access to a LOT of things out of the box.

How do I find the Windows 10 SDK?

If you run the Visual Studio installer, and click modify on the version that you have installed. On the right hand side, there will be a summary of the currently installed components. Just look for any Windows 10 SDKs with selected check boxes next to it, and that will be the version that is installed.


2 Answers

Ok, it seems not a lot of people face thist problem, but i'll still post a workaround to set default sdk version. It worked with Visual Studio 2017 Communtity. Consider the following situation:

  • You've got a solution with projects you must not retarget

  • You had older VS installed earlier on your PC

  • When you open the solution, VS sets SDK version as 8.1 for some reason, while you use Windows SDK 10

  • When you try to build you have the following:

Error MSB8036 The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution".

because SDK 8.1 is not installed properly on your PC, and reinstalling it somewhy does not solve the problem.

  • Others on your team don't have such a problem as the projects don't have Windows SDK version explicitly defined inside *.vcxproj files.

So, obviusly, MS build system with multiple SDKs installed has some kind of confusion, and the worst part is that it results in defining corruptly installed SDK as your default. I used the following workaround to set default windows SDK explicitly:

  • Go to [VS installment path]\Common7\IDE\VC\VCTargets ,example:

C:\Program Files (x86)\Microsoft Visual Studio\2017\WDExpress\Common7\IDE\VC\VCTargets\Microsoft.Cpp.WindowsSDK.props)

  • Open file Microsoft.Cpp.WindowsSDK.props as an administrator
  • Find line
    <DefaultWindowsSDKVersion Condition="'$(DefaultWindowsSDKVersion)' == ''
    and '$(AppContainerApplication)' != 'true'">8.1</DefaultWindowsSDKVersion>

change 8.1 to the SDK version you're sure you have properly installed, then save the file. In my case it was 10.0.17763.0, so the final line was

    <DefaultWindowsSDKVersion Condition="'$(DefaultWindowsSDKVersion)' == ''
    and '$(AppContainerApplication)' != 'true'">10.0.17763.0</DefaultWindowsSDKVersion>

Now reopen your solution and try to build it. Should work fine.

like image 199
Jeembo Jones Avatar answered Sep 18 '22 12:09

Jeembo Jones


My first troubleshooting tips would be to uninstall all the Visual Studio stuff you have, then reboot. Then install the latest version of Visual Studio. Then install any other SDKs that you need via the Visual Studio installer wizard. If you require to have Visual Studio 2015 and 2019 installed, go ahead and install 2015 before you install 2019.

If you want to change the project templates, you can in fact do that. The folder for the default templates is here:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\ProjectTemplates\VC\WindowsDesktop\

Let's say you want to modify the ConsoleApplication template. Create a new project, in this new project edit the Project Property "SDK version" to be 8.1. Save the project and then go to Project->Export Template. Export the template. It will be a zip file in Documents\Visual Studio 2019\My Exported Templates. Unzip it.

You will notice the .vstemplate file in this folder which is similar to the found in the directory above. You will see in the node it will reference a .vcxproj file. In this .vcxproj file you will find the property:

<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>

Therefore in order to modify the default templates to match the template you just exported you will need to add the necessary files and lines XML from the My Exported Templates files and overwrite the defaults in Program Files. These will probably be overwritten each time you update VS tho.

Alternatively just extract the zip file of template you exported to the folder:

ProjectTemplates\VC\WindowsDesktop\

And you will find it in your templates after you reload visual studio

like image 41
GuidedHacking Avatar answered Sep 18 '22 12:09

GuidedHacking