public static void SetUseKitsRootForDevEnv(DevEnv devEnv, KitsRootEnum kitsRoot, Options.Vc.General.WindowsTargetPlatformVersion?windowsTargetPlatformVersion = null) { windowsTargetPlatformVersion = windowsTargetPlatformVersion ?? s_defaultKitsRootForDevEnv[devEnv].Item2; switch (kitsRoot) { case KitsRootEnum.KitsRoot: if (windowsTargetPlatformVersion.HasValue) { throw new Error("Unsupported setting: WindowsTargetPlatformVersion is not customizable for KitsRoot 8.0."); } break; case KitsRootEnum.KitsRoot81: if (windowsTargetPlatformVersion.HasValue && windowsTargetPlatformVersion.Value != Options.Vc.General.WindowsTargetPlatformVersion.v8_1) { throw new Error("Unsupported setting: WindowsTargetPlatformVersion is not customizable for KitsRoot 8.1."); } break; case KitsRootEnum.KitsRoot10: if (!windowsTargetPlatformVersion.HasValue) { throw new Error("KitsRoot10 needs to be set for " + devEnv + "."); } if (windowsTargetPlatformVersion == Options.Vc.General.WindowsTargetPlatformVersion.v8_1) { throw new Error("Inconsistent values detected: KitsRoot10 set for " + devEnv + ", but windowsTargetPlatform is set to 8.1"); } break; } s_useKitsRootForDevEnv[devEnv] = Tuple.Create(kitsRoot, windowsTargetPlatformVersion); }
public static string GetWindowsResourceCompiler(this DevEnv visualVersion, Platform platform) { KitsRootEnum kitsRoot = KitsRootPaths.GetUseKitsRootForDevEnv(visualVersion); string targetPlatform = (platform == Platform.win64) ? "x64" : "x86"; switch (kitsRoot) { case KitsRootEnum.KitsRoot: return(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot), "bin", targetPlatform, "rc.exe")); case KitsRootEnum.KitsRoot81: return(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81), "bin", targetPlatform, "rc.exe")); case KitsRootEnum.KitsRoot10: { string kitsRootPath; if (KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(visualVersion) <= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10240_0) { kitsRootPath = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81); } else { kitsRootPath = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10); } return(Path.Combine(kitsRootPath, "bin", targetPlatform, "rc.exe")); } default: throw new NotImplementedException("No WindowsResourceCompiler associated with " + kitsRoot); } }
public static string GetWindowsExecutablePath(this DevEnv visualVersion, Platform platform) { KitsRootEnum kitsRoot = KitsRootPaths.GetUseKitsRootForDevEnv(visualVersion); string targetPlatform = (platform == Platform.win64) ? "x64" : "x86"; var paths = new List <string>(); paths.Add(visualVersion.GetVisualStudioBinPath(platform)); switch (kitsRoot) { case KitsRootEnum.KitsRoot: paths.Add(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot), "bin", targetPlatform)); break; case KitsRootEnum.KitsRoot81: paths.Add(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81), "bin", targetPlatform)); break; case KitsRootEnum.KitsRoot10: paths.Add(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10), "bin", targetPlatform)); if (KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(visualVersion) <= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10240_0) { paths.Add(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81), "bin", targetPlatform)); } break; default: throw new NotImplementedException("No GetWindowsExecutablePath associated with " + kitsRoot); } paths.Add("$(PATH)"); return(string.Join(";", paths)); }
public static void SetUseKitsRootForDevEnv(DevEnv devEnv, KitsRootEnum kitsRoot, Options.Vc.General.WindowsTargetPlatformVersion?windowsTargetPlatformVersion = null) { s_useKitsRootForDevEnv[devEnv] = kitsRoot; switch (kitsRoot) { case KitsRootEnum.KitsRoot: if (windowsTargetPlatformVersion.HasValue) { throw new Error("Unsupported setting: WindowsTargetPlatformVersion is not customizable for KitsRoot 8.0."); } break; case KitsRootEnum.KitsRoot81: if (windowsTargetPlatformVersion.HasValue && windowsTargetPlatformVersion.Value != Options.Vc.General.WindowsTargetPlatformVersion.v8_1) { throw new Error("Unsupported setting: WindowsTargetPlatformVersion is not customizable for KitsRoot 8.1. Redundant setting will be discarded"); } break; case KitsRootEnum.KitsRoot10: if (!windowsTargetPlatformVersion.HasValue) { windowsTargetPlatformVersion = Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10586_0; } if (windowsTargetPlatformVersion.Value == Options.Vc.General.WindowsTargetPlatformVersion.v8_1) { throw new Error("Inconsistent values detected: KitsRoot10 set for " + devEnv + ", but windowsTargetPlatform is set to 8.1"); } WindowsTargetPlatformVersion = windowsTargetPlatformVersion.Value; break; } }
public static string GetWindowsIncludePath(this DevEnv visualVersion) { string visualStudioDir = Util.EnsureTrailingSeparator(visualVersion.GetVisualStudioVCRootPath()); string visualStudioInclude = string.Format(@"{0}include;{0}atlmfc\include", visualStudioDir); KitsRootEnum useKitsRoot = KitsRootPaths.GetUseKitsRootForDevEnv(visualVersion); switch (useKitsRoot) { case KitsRootEnum.KitsRoot: { string kitsRoot = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot)); return(String.Format(@"{0};{1}Include\shared;{1}Include\um;{1}Include\WinRT;", visualStudioInclude, kitsRoot)); } case KitsRootEnum.KitsRoot81: { string kitsRoot = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81)); return(String.Format(@"{0};{1}Include\shared;{1}Include\um;{1}Include\WinRT;", visualStudioInclude, kitsRoot)); } case KitsRootEnum.KitsRoot10: { string kitsRoot10 = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10)); Options.Vc.General.WindowsTargetPlatformVersion windowsTargetPlatformVersion = KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(visualVersion); string platformVersion = windowsTargetPlatformVersion.ToVersionString(); var paths = new List <string> { $@"{visualStudioInclude}", $@"{kitsRoot10}Include\{platformVersion}\um", // $(UM_IncludePath) $@"{kitsRoot10}Include\{platformVersion}\shared", // $(KIT_SHARED_IncludePath) $@"{kitsRoot10}Include\{platformVersion}\winrt", // $(WinRT_IncludePath) $@"{kitsRoot10}Include\{platformVersion}\ucrt", // $(UniversalCRT_IncludePath) }; if (windowsTargetPlatformVersion <= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10240_0) { // // Version 10.0.10240.0 and below only contain the UCRT libraries // and headers, not the usual Win32 stuff. So if we are using // version 10240 or older, also include the Windows 8.1 paths so we // have a complete Win32 support. // string kitsRoot81 = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81)); paths.AddRange(new[] { $@"{kitsRoot81}Include\um", $@"{kitsRoot81}Include\shared" }); } return(string.Join(";", paths)); } default: throw new NotImplementedException("No WindowsResourceCompiler associated with " + visualVersion); } }
public static string GetDefaultRoot(KitsRootEnum kitsRoot) { if (s_kitsRootsInstance == null) throw new Error(); if (s_defaultKitsRoots.ContainsKey(kitsRoot)) return s_defaultKitsRoots[kitsRoot]; throw new NotImplementedException("DefaultKitsRoots path was not set with " + kitsRoot); }
public static string GetRoot(KitsRootEnum kitsRoot) { if (s_kitsRootsInstance == null) throw new Error(); if (s_kitsRoots.ContainsKey(kitsRoot)) return s_kitsRoots[kitsRoot]; return GetDefaultRoot(kitsRoot); }
public static string GetRoot(KitsRootEnum kitsRoot) { if (s_kitsRootsInstance == null) { throw new Error(); } if (s_kitsRoots.ContainsKey(kitsRoot)) { return(s_kitsRoots[kitsRoot]); } return(GetDefaultRoot(kitsRoot)); }
public static string GetDefaultRoot(KitsRootEnum kitsRoot) { if (s_kitsRootsInstance == null) { throw new Error(); } if (s_defaultKitsRoots.ContainsKey(kitsRoot)) { return(s_defaultKitsRoots[kitsRoot]); } throw new NotImplementedException("No DefaultKitsRoots associated with " + kitsRoot.ToString()); }
public static string GetWindowsResourceCompiler(this DevEnv visualVersion, Platform platform) { KitsRootEnum kitsRoot = KitsRootPaths.GetUseKitsRootForDevEnv(visualVersion); string targetPlatform = (platform == Platform.win64) ? "x64" : "x86"; switch (kitsRoot) { case KitsRootEnum.KitsRoot: return(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot), "bin", targetPlatform, "rc.exe")); case KitsRootEnum.KitsRoot81: return(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81), "bin", targetPlatform, "rc.exe")); case KitsRootEnum.KitsRoot10: { Options.Vc.General.WindowsTargetPlatformVersion windowsTargetPlatformVersion = KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(visualVersion); if (windowsTargetPlatformVersion <= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10240_0) { string kitsRoot81Path = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81); return(Path.Combine(kitsRoot81Path, "bin", targetPlatform, "rc.exe")); } string kitsRoot10Path = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10); string platformVersion = windowsTargetPlatformVersion.ToVersionString(); // First, try WindowsSdkVerBinPath string candidateWindowsSdkVerBinPath = Path.Combine(kitsRoot10Path, "bin", platformVersion, targetPlatform, "rc.exe"); if (File.Exists(candidateWindowsSdkVerBinPath)) { return(candidateWindowsSdkVerBinPath); } // If it didn't contain rc.exe, fallback to WindowsSdkBinPath return(Path.Combine(kitsRoot10Path, "bin", targetPlatform, "rc.exe")); } default: throw new NotImplementedException("No WindowsResourceCompiler associated with " + kitsRoot); } }
public static string GetWindowsLibraryPath(this DevEnv visualVersion, Platform platform, DotNetFramework?dotNetFramework = null) { string visualStudioVCDir = Util.EnsureTrailingSeparator(visualVersion.GetVisualStudioVCRootPath()); string subDir = platform == Platform.win64 ? @"\amd64" : ""; if ((visualVersion == DevEnv.vs2017) || (visualVersion == DevEnv.vs2019)) { subDir = platform == Platform.win64 ? @"\x64" : @"\x86"; } string visualStudioLib = string.Format(@"{0}lib{1};{0}atlmfc\lib{1};", visualStudioVCDir, subDir); if (visualVersion == DevEnv.vs2010) { return(visualStudioLib); } else { KitsRootEnum useKitsRoot = KitsRootPaths.GetUseKitsRootForDevEnv(visualVersion); string targetPlatform = platform == Platform.win64 ? "x64" : "x86"; switch (useKitsRoot) { case KitsRootEnum.KitsRoot: { string kitsRoot = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot)); return(string.Format(@"{0};{1}lib\win8\um\{2};{1}References\CommonConfiguration\Neutral;", visualStudioLib, kitsRoot, targetPlatform)); } case KitsRootEnum.KitsRoot81: { string kitsRoot = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81)); return(string.Format(@"{0};{1}lib\winv6.3\um\{2};{1}References\CommonConfiguration\Neutral;", visualStudioLib, kitsRoot, targetPlatform)); } case KitsRootEnum.KitsRoot10: { string netFxPath = string.Empty; if (dotNetFramework.HasValue && visualVersion >= DevEnv.vs2015) { string netFXKitsDir = Util.EnsureTrailingSeparator(KitsRootPaths.GetNETFXKitsDir(dotNetFramework.Value < DotNetFramework.v4_6 ? DotNetFramework.v4_6 : dotNetFramework.Value)); netFxPath = Path.Combine(netFXKitsDir, "Lib", "um", targetPlatform); } string kitsRoot10 = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10); Options.Vc.General.WindowsTargetPlatformVersion windowsTargetPlatformVersion = KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(visualVersion); string platformVersion = windowsTargetPlatformVersion.ToVersionString(); var paths = new[] { visualStudioLib, Path.Combine(kitsRoot10, "Lib", platformVersion, "ucrt", targetPlatform), // $(UniversalCRT_LibraryPath_x86) or $(UniversalCRT_LibraryPath_x64) Path.Combine(kitsRoot10, "Lib", platformVersion, "um", targetPlatform), // $(WindowsSDK_LibraryPath_x86) or $(WindowsSDK_LibraryPath_x64) netFxPath }.ToList(); if (windowsTargetPlatformVersion <= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10240_0) { string kitsRoot81 = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81); paths.AddRange(new[] { Path.Combine(kitsRoot81, "lib", "winv6.3", "um", targetPlatform), Path.Combine(kitsRoot81, "References", "CommonConfiguration", "Neutral") }); } return(string.Join(";", paths)); } default: throw new NotImplementedException("No WindowsResourceCompiler associated with " + visualVersion); } } }
protected virtual void WriteWindowsKitsOverrides(IVcxprojGenerationContext context, IFileGenerator fileGenerator) { KitsRootEnum?kitsRootWritten = null; for (DevEnv devEnv = context.DevelopmentEnvironmentsRange.MinDevEnv; devEnv <= context.DevelopmentEnvironmentsRange.MaxDevEnv; devEnv = (DevEnv)((int)devEnv << 1)) { // there's no need to write the properties with older versions of vs, as we override // completely the VC++ directories entries in the vcxproj if (devEnv < DevEnv.vs2015) { continue; } KitsRootEnum kitsRootVersion = KitsRootPaths.GetUseKitsRootForDevEnv(devEnv); if (kitsRootWritten == null) { kitsRootWritten = kitsRootVersion; } else if (kitsRootWritten != kitsRootVersion) { throw new Error($"Different values of kitsRoot in the same vcxproj {context.ProjectFileName}"); } else { continue; } string windowsSdkDirKey = FileGeneratorUtilities.RemoveLineTag; string windowsSdkDirValue = FileGeneratorUtilities.RemoveLineTag; string UniversalCRTSdkDir_10 = FileGeneratorUtilities.RemoveLineTag; string UCRTContentRoot = FileGeneratorUtilities.RemoveLineTag; string targetPlatformVersionString = FileGeneratorUtilities.RemoveLineTag; if (kitsRootVersion != KitsRootEnum.KitsRoot81) // 8.1 is the default value for vs2015 and vs2017, so only specify a different platformVersion if we need to { targetPlatformVersionString = KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(devEnv).ToVersionString(); } if (devEnv.OverridenWindowsPath()) { windowsSdkDirValue = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(kitsRootVersion)); switch (kitsRootVersion) { case KitsRootEnum.KitsRoot: windowsSdkDirKey = "WindowsSdkDir_80"; break; case KitsRootEnum.KitsRoot81: windowsSdkDirKey = "WindowsSdkDir_81"; break; case KitsRootEnum.KitsRoot10: { windowsSdkDirKey = "WindowsSdkDir_10"; UniversalCRTSdkDir_10 = windowsSdkDirValue; // this variable is found in Windows Kits\10\DesignTime\CommonConfiguration\Neutral\uCRT.props // it is always read from the registry unless overridden, so we need to explicitly set it UCRTContentRoot = windowsSdkDirValue; } break; default: throw new NotImplementedException($"Unsupported kitsRoot '{kitsRootVersion}'"); } } using (fileGenerator.Declare("windowsSdkDirKey", windowsSdkDirKey)) using (fileGenerator.Declare("windowsSdkDirValue", windowsSdkDirValue)) using (fileGenerator.Declare("UniversalCRTSdkDir_10", UniversalCRTSdkDir_10)) using (fileGenerator.Declare("UCRTContentRoot", UCRTContentRoot)) using (fileGenerator.Declare("targetPlatformVersion", targetPlatformVersionString)) { fileGenerator.Write(_windowsSDKOverridesBegin); // vs2015 specific, we need to set the UniversalCRTSdkDir to $(UniversalCRTSdkDir_10) because it is not done in the .props if (devEnv == DevEnv.vs2015 && !string.Equals(UniversalCRTSdkDir_10, FileGeneratorUtilities.RemoveLineTag, StringComparison.Ordinal)) { using (fileGenerator.Declare("custompropertyname", "UniversalCRTSdkDir")) using (fileGenerator.Declare("custompropertyvalue", "$(UniversalCRTSdkDir_10)")) { fileGenerator.Write(fileGenerator.Resolver.Resolve(Vcxproj.Template.Project.CustomProperty)); } } fileGenerator.Write(_windowsSDKOverridesEnd); } } }
public static void SetRoot(KitsRootEnum kitsRoot, string kitsRootPath) { s_kitsRoots[kitsRoot] = kitsRootPath; }
public static bool IsDefaultKitRootPath(DevEnv devEnv) { KitsRootEnum kitsRoot = GetUseKitsRootForDevEnv(devEnv); return(GetDefaultRoot(kitsRoot) == GetRoot(kitsRoot)); }
public static bool UsesDefaultKitRoot(DevEnv devEnv) { KitsRootEnum kitsRoot = GetUseKitsRootForDevEnv(devEnv); return(kitsRoot == s_defaultKitsRootForDevEnv[devEnv].Item1); }