Skip to content

Commit

Permalink
Change the windows kits directory from regestry
Browse files Browse the repository at this point in the history
  • Loading branch information
JaynieBai committed May 9, 2023
1 parent 0809a23 commit 128e5b6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Build/Evaluation/Evaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ private void AddBuiltInProperties()
SetBuiltInProperty(ReservedPropertyNames.version, MSBuildAssemblyFileVersion.Instance.MajorMinorBuild);
SetBuiltInProperty(ReservedPropertyNames.fileVersion, CachedFileVersion);
SetBuiltInProperty(ReservedPropertyNames.semanticVersion, ProjectCollection.DisplayVersion);

SetBuiltInProperty(ReservedPropertyNames.windowsKitsPath, FrameworkLocationHelper.PathOfInstalledWindowsKits);
ValidateChangeWaveState();

SetBuiltInProperty(ReservedPropertyNames.msbuilddisablefeaturesfromversion, ChangeWaves.DisabledWave.ToString());
Expand Down
1 change: 1 addition & 0 deletions src/Build/Resources/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ internal static class ReservedPropertyNames
internal const string frameworkToolsRoot = "MSBuildFrameworkToolsRoot";
internal const string interactive = "MSBuildInteractive";
internal const string msbuilddisablefeaturesfromversion = "MSBuildDisableFeaturesFromVersion";
internal const string windowsKitsPath = "WindowsKitsDirectory";

/// <summary>
/// Lookup for reserved property names. Intentionally do not include MSBuildExtensionsPath* or MSBuildUserExtensionsPath in this list. We need tasks to be able to override those.
Expand Down
20 changes: 20 additions & 0 deletions src/Shared/FrameworkLocationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ internal static class FrameworkLocationHelper

#if FEATURE_WIN32_REGISTRY
private const string fallbackDotNetFrameworkSdkRegistryInstallPath = "SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows";
private const string windowsKitsInstalledRootsRegistryPath = "SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots";
#endif // FEATURE_WIN32_REGISTRY
internal const string fallbackDotNetFrameworkSdkInstallKeyValue = "CurrentInstallFolder";

Expand Down Expand Up @@ -622,6 +623,25 @@ private static string PathToV4ToolsInFallbackDotNetFrameworkSdk
}
}

private static string pathOfInstalledWindowsKits = null;

internal static string PathOfInstalledWindowsKits
{
get
{
#if FEATURE_WIN32_REGISTRY
if (FrameworkLocationHelper.pathOfInstalledWindowsKits == null)
{
FrameworkLocationHelper.pathOfInstalledWindowsKits = FindRegistryValueUnderKey(
windowsKitsInstalledRootsRegistryPath,
"KitsRoot10");
}
#endif

return FrameworkLocationHelper.pathOfInstalledWindowsKits;
}
}

#endregion // Static properties

#region Internal methods
Expand Down
2 changes: 1 addition & 1 deletion src/Tasks/Microsoft.Common.CurrentVersion.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2518,7 +2518,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<SDKReferenceRegistryRoot Condition="'$(SDKReferenceRegistryRoot)' == ''">Software\Microsoft\Microsoft SDKs</SDKReferenceRegistryRoot>
<SDKReferenceDirectoryRoot Condition="'$(SDKReferenceDirectoryRoot)' == ''">$(LocalAppData)\Microsoft SDKs;$(MSBuildProgramFiles32)\Microsoft SDKs</SDKReferenceDirectoryRoot>
<!-- Manifest driven extension SDK locations -->
<SDKExtensionDirectoryRoot Condition="'$(SDKExtensionDirectoryRoot)' == '' and '$(SDKIdentifier)' != ''">$(MSBuildProgramFiles32)\Microsoft SDKs\Windows Kits\10;$(MSBuildProgramFiles32)\Windows Kits\10</SDKExtensionDirectoryRoot>
<SDKExtensionDirectoryRoot Condition="'$(SDKExtensionDirectoryRoot)' == '' and '$(SDKIdentifier)' != ''">$(MSBuildProgramFiles32)\Microsoft SDKs\Windows Kits\10;$(WindowsKitsDirectory)</SDKExtensionDirectoryRoot>

<!-- UAP projects by default should support Windows 8.1 SDKs -->
<SupportWindows81SDKs Condition="'$(SupportWindows81SDKs)' == '' and '$(Support81SDKs)' != 'false' and '$(TargetPlatformIdentifier)' == 'UAP'">true</SupportWindows81SDKs>
Expand Down

0 comments on commit 128e5b6

Please sign in to comment.