22

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

JeffRSon
  • 10,404
  • 4
  • 26
  • 51
Marson Mao
  • 2,935
  • 6
  • 30
  • 45
  • 3
    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). – James McNellis Sep 01 '15 at 03:22
  • @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? – Marson Mao Sep 01 '15 at 03:25
  • 1
    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. – James McNellis Sep 01 '15 at 03:34
  • Ok, great, thanks, it worked. But all output goes in the console window, can I output it to a text file? – Marson Mao Sep 01 '15 at 03:39
  • @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 :p – Marson Mao Sep 01 '15 at 03:42
  • @JamesMcNellis I see many imports with `.targets` files, but haven't seen any macro definition yet, not sure where to find them. – Marson Mao Sep 01 '15 at 03:44
  • @JamesMcNellis `Microsoft.Cpp.targets` looks relative, but still not the correct place! – Marson Mao Sep 01 '15 at 03:47

5 Answers5

7

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.

Community
  • 1
  • 1
malopezmx
  • 89
  • 1
  • 5
  • 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. – dns Jun 18 '18 at 21:20
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.).

JeffRSon
  • 10,404
  • 4
  • 26
  • 51
  • 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\v160` – Warpspace Sep 20 '21 at 09:03
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.

magicandre1981
  • 27,895
  • 5
  • 86
  • 127
  • Awesome! That's it! By the way, do you know how visual studio read this file? – Marson Mao Sep 01 '15 at 04:19
  • 2
    To offer some info, 8.1 has the file at `C:\Program Files (x86)\Windows Kits\8.1\DesignTime\CommonConfiguration\Neutral\Windows.props` – Marson Mao Sep 01 '15 at 04:19
  • I have the same SDKs (8.0, 8.1, 10.0), and none of them has the "build" subfolder. – Violet Giraffe Jan 06 '16 at 12:41
  • 1
    @VioletGiraffe look at the comment of Marson Mao, the 8.1 version is stored under DesignTime, not build. – magicandre1981 Jan 06 '16 at 18:24
  • 1
    @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). – Seppo Jokinen Dec 07 '17 at 12:13
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\\"
高亚斌
  • 71
  • 1
  • 3
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>
Todd
  • 11
  • 2