13

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

Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
  • Have you tried Project > Properties > General > Platform Toolset ? – mikedu95 Jan 06 '16 at 11:25
  • @mikedu95: the toolset has no relation to the Windows kit. – Violet Giraffe Jan 06 '16 at 11:29
  • Yes it does. See: http://bit.ly/1PMNvmy (VS2010 and the `Windows7.1SDK toolset`). The other "solution" would be to install VS2015. – mikedu95 Jan 06 '16 at 12:14
  • 3
    @mikedu95 - please, don't use url shortening services on SO. Post the actual url (a) so people know where they're going and (b) to remove a 'stepping-stone' which may at some stage be hacked. (c) Many employers block url shorteners, thus rendering the link dead. This has been discussed on Meta. For others, the url mike posted boils down to: https://msdn.microsoft.com/en-us/library/ff660764(v=vs.100).aspx – enhzflep Jan 06 '16 at 12:21
  • @mikedu95: nope. I already had VS 2015 and was using v140 toolset for a good while. VS 2015 DOES NOT include the Win 10 SDK. – Violet Giraffe Jan 06 '16 at 12:22
  • @mikedu95 - See the thread here: http://meta.stackoverflow.com/questions/313621/blacklist-the-use-of-common-link-shorteners-in-posts/313766#313766 – enhzflep Jan 06 '16 at 12:24
  • @mikedu95: the SDK path is acquired by the VS from the `WindowsSDK_IncludePath` variable, but it is unclear where it is stored physically. – Violet Giraffe Jan 06 '16 at 12:26
  • @VioletGiraffe I understand that what you want to do, if it was possible, is to modify these macros (Windows_SDK*). But I think you can't. However, the latest update of VS2015 includes the Windows 10 SDK. Dixit MS: https://www.visualstudio.com/news/vs2015-update1-vs – mikedu95 Jan 06 '16 at 12:30
  • @mikedu95: I have installed VS 2015, and then update 1 as soon as it came out. No Windows 10 SDK. – Violet Giraffe Jan 06 '16 at 12:31
  • Sorry In fact the link says that to update the paths, re-install VS2015 (re-run installation): *"If you don't already have Tools for Universal Windows Apps installed, you can enable them by modifying the Visual Studio 2015 installation (...)"*. Have you already done this ? – mikedu95 Jan 06 '16 at 12:35
  • @mikedu95: OK, I see the Win 10 SDK available deep down in the VS component selection tree. Trying to install that. It still doesn't explain why I can't use the SDK after installing it from a standalone installer that I downloaded from the MS site. – Violet Giraffe Jan 06 '16 at 12:48
  • @mikedu95: nope, installed the SDK via the Visual Studio setup, still no luck. – Violet Giraffe Jan 06 '16 at 13:05
  • 3
    If you had an install problem then it is certainly best to cut your wrist now, it ends the suffering sooner. Simplest possible explanation is that you just did not set the project's General > Target Platform Version property. It defaults to 8.1, the combobox should at least also show 10.0.10240.0 or 10.0.10586.0. Changing that default, fuggedaboudid. – Hans Passant Jan 06 '16 at 13:25
  • @HansPassant: yep, I certainly missed that combobox! I don't have 10586 available, though, only 10240. And I didn't have any installation problems, at least none that I were made aware of by the installers. – Violet Giraffe Jan 06 '16 at 13:43

2 Answers2

3

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.

1

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

GuidedHacking
  • 3,628
  • 1
  • 9
  • 59