Where is WindowsSDK_IncludePath defined?
Asked Answered
U

5

23

The macro $(WindowsSDK_IncludePath) has the values shown in the picture.

I'd like to know where those values are defined, they must be defined in some files.

The picture was taken from Visual Studio 2013.

enter image description here

Unstoppable answered 1/9, 2015 at 3:14 Comment(7)
Build the project file on the command line with /preprocess to find out (msbuild /preprocess myproject.vcxproj, then search the output to find where the property is defined).Extravascular
@JamesMcNellis Hm?! I got Command line warning D9002: ignoring unknown option '/preprocess'? Did you mean put /preprocess inside Configuration Properties > C/C++ > Command Line > Additional Options?Unstoppable
Open the Developer Command Prompt (it's in the "Visual Studio Tools' folder on the Start Menu), change to the directory in which your project is located, then run that command. That will run MSBuild from the command line to preprocess the project file and allow you to see the entire project that will be built, with all imported files included.Extravascular
Ok, great, thanks, it worked. But all output goes in the console window, can I output it to a text file?Unstoppable
@JamesMcNellis By the way, after doing this build, I can find out a place writing something like, $(WindowsSDK_IncludePath) = C:\Program Files (x86)\Windows Kits\8.1\Include\um + ..., right? I just wanted to know a place that defines these macros and their values :pUnstoppable
@JamesMcNellis I see many imports with .targets files, but haven't seen any macro definition yet, not sure where to find them.Unstoppable
@JamesMcNellis Microsoft.Cpp.targets looks relative, but still not the correct place!Unstoppable
A
5

I see the data in file sdk.props in folder C:\Program Files (x86)\Windows Kits\8.0\build\CommonConfiguration\Neutral

<PropertyGroup>
     <WindowsSdkDir Condition="'$(WindowsSdkDir)' == ''">$([MSBUILD]::GetDirectoryNameOfFileAbove('$(MSBUILDTHISFILEDIRECTORY)', 'sdkmanifest.xml'))</WindowsSdkDir>
  </PropertyGroup>

  <PropertyGroup>    <WindowsSDK_IncludePath>$(WindowsSdkDir)Include\um;$(WindowsSdkDir)Include\shared;$(WindowsSdkDir)Include\winrt;</WindowsSDK_IncludePath>
  </PropertyGroup>

I use a Win8 + VS2012, so it should be in folder 8.1 for your VS2013 + 8.1 SDK.

Avigation answered 1/9, 2015 at 4:15 Comment(5)
Awesome! That's it! By the way, do you know how visual studio read this file?Unstoppable
To offer some info, 8.1 has the file at C:\Program Files (x86)\Windows Kits\8.1\DesignTime\CommonConfiguration\Neutral\Windows.propsUnstoppable
I have the same SDKs (8.0, 8.1, 10.0), and none of them has the "build" subfolder.Gotten
@VioletGiraffe look at the comment of Marson Mao, the 8.1 version is stored under DesignTime, not build.Avigation
@VioletGiraffe: Uninstall the other (newer?) SDKs that you're not using for this build, then repair the used SDK (from Control Panel - Programs and Features - select the Windows Sofrware Development Kit... - Change - Repair).Swathe
I
8

In my case, the WindowsSDK_IncludePath variable was correctly defined and in fact it worked perfectly in Visual Studio 2013. So I even uninstalled and reinstalled VS2015. Then I found thanks to this link that the preset macro variables can be modified by specific user settings. These user settings are stored in C:\Users\<user>\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props which in my case read as follows:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets">
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);C:\Program Files (x86)\CodeSynthesis XSD 4.0\include;</IncludePath>
    <LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);C:\Program Files (x86)\CodeSynthesis XSD 4.0\lib\vc-12.0;</LibraryPath>
    <ExecutablePath>C:\Program Files (x86)\CodeSynthesis XSD 4.0\bin;$(VC_ExecutablePath_x86);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
  </PropertyGroup>
  <ItemDefinitionGroup />
  <ItemGroup />
</Project>

Somehow the <IncludePath> sentence made it impossible for VS2015 to find the correct value. In my laptop computer where everything worked correctly, the file was basically empty:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets">
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
  </PropertyGroup>
  <ItemDefinitionGroup />
  <ItemGroup />
</Project>

After setting my file just like the one in my laptop, everything worked normally. Of course I lost the execution preference of CodeSynthesis XSD but right now I am not working on any project that use it. I will continue experimenting with different variants of this file.

Infamy answered 5/8, 2016 at 19:11 Comment(1)
Thanks, this solved my problem. In my case I use VS2013, then I install VS2017 but after that I uninstalled VS2017. But later I found out it breaks the VS2013 msbuild.Leeland
I
6

For me it was the file Microsoft.Cpp.Common.props in folder C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140, where I had to change the hardcoded Windows 10 SDK version from 10.0.10240.0 to 10.0.10586.0.

<!-- 10.0.10240.0 is the hardcoded checked-in version of uCRT that we use in case we target 8.1 SDK -->
<TargetUniversalCRTVersion Condition="'$(TargetUniversalCRTVersion)' == ''  and ('$(TargetPlatformVersion)' == '8.1' or '$(DefineWindowsSDK_71A)' == 'true')">10.0.10586.0</TargetUniversalCRTVersion>

I'm using VS2015 on Windows 10 and wasn't able to compile against Windows 8.1 SDK because of missing include files. Installing the standalone Windows 10 SDK didn't help either (because it doesn't contain ucrt files for 10.0.10240 like ctype.h a.s.o.).

Impedance answered 19/7, 2016 at 8:39 Comment(1)
This worked for me, except the file was Microsoft.Cpp.WindowsSDK.props and the path to the file was C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160Bourguiba
A
5

I see the data in file sdk.props in folder C:\Program Files (x86)\Windows Kits\8.0\build\CommonConfiguration\Neutral

<PropertyGroup>
     <WindowsSdkDir Condition="'$(WindowsSdkDir)' == ''">$([MSBUILD]::GetDirectoryNameOfFileAbove('$(MSBUILDTHISFILEDIRECTORY)', 'sdkmanifest.xml'))</WindowsSdkDir>
  </PropertyGroup>

  <PropertyGroup>    <WindowsSDK_IncludePath>$(WindowsSdkDir)Include\um;$(WindowsSdkDir)Include\shared;$(WindowsSdkDir)Include\winrt;</WindowsSDK_IncludePath>
  </PropertyGroup>

I use a Win8 + VS2012, so it should be in folder 8.1 for your VS2013 + 8.1 SDK.

Avigation answered 1/9, 2015 at 4:15 Comment(5)
Awesome! That's it! By the way, do you know how visual studio read this file?Unstoppable
To offer some info, 8.1 has the file at C:\Program Files (x86)\Windows Kits\8.1\DesignTime\CommonConfiguration\Neutral\Windows.propsUnstoppable
I have the same SDKs (8.0, 8.1, 10.0), and none of them has the "build" subfolder.Gotten
@VioletGiraffe look at the comment of Marson Mao, the 8.1 version is stored under DesignTime, not build.Avigation
@VioletGiraffe: Uninstall the other (newer?) SDKs that you're not using for this build, then repair the used SDK (from Control Panel - Programs and Features - select the Windows Sofrware Development Kit... - Change - Repair).Swathe
C
5
I find Reason that : Windows Registry
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots]
"KitsRoot10"="C:\\Program Files\\Windows Kits\\10\\"

but in Actually 
"KitsRoot10"="C:\\Program Files (x86)\\Windows Kits\\10\\"
"AppVerifier64BitAutomationRoot"="C:\\Program Files\\Application Verifier\\"
"KitsRoot81"="C:\\Program Files (x86)\\Windows Kits\\8.1\\"
Consonant answered 12/1, 2022 at 8:11 Comment(1)
VS2022 (released in 2024) may go crazy when installed in the environment where you already had installed Windows 10 SDK (VS2022 is bundled with Windows 11 SDK , which you can't discard). So the solution (a kind of workaround): after installing VS2022 uninstall Windows 11 SDK, and reinstall Windows 10 SDK.Pertussis
B
1

Search for *.props in C:\Program Files (x86)\Windows Kits\

In my case the file causing the problem was UAP.props. Editing the file and changing 4.7.1 to 4.6.1 solved the issue.

<PropertyGroup>
    <WindowsSdkDir Condition="'$(WindowsSdkDir)' == ''">$([MSBUILD]::GetDirectoryNameOfFileAbove('$(MSBUILDTHISFILEDIRECTORY)', 'sdkmanifest.xml'))\</WindowsSdkDir>
    <DotNetSdkRoot Condition="'$(DotNetSdkRoot)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.7.1@KitsInstallationFolder)</DotNetSdkRoot>
    <DotNetSdkRoot Condition="'$(DotNetSdkRoot)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.7.1@KitsInstallationFolder)</DotNetSdkRoot>
  </PropertyGroup>
Boylan answered 25/10, 2017 at 3:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.