Exemple #1
0
        public static bool IsWindowsTargetPlatformVersionInstalled(Options.Vc.General.WindowsTargetPlatformVersion version)
        {
            bool isInstalled = false;

            if (s_windowsTargetPlatformVersionInstalled.TryGetValue(version, out isInstalled))
            {
                return(isInstalled);
            }

            // cache which version folders exist on the current system
            string path;

            if (version == Options.Vc.General.WindowsTargetPlatformVersion.v8_1)
            {
                path = s_defaultKitsRoots[KitsRootEnum.KitsRoot81];
            }
            else
            {
                path = Path.Combine(s_defaultKitsRoots[KitsRootEnum.KitsRoot10], "Include", version.ToVersionString());
            }

            isInstalled = Directory.Exists(path);
            s_windowsTargetPlatformVersionInstalled.TryAdd(version, isInstalled);

            return(isInstalled);
        }
        public static string ToVersionString(this Options.Vc.General.WindowsTargetPlatformVersion windowsTargetPlatformVersion)
        {
            switch (windowsTargetPlatformVersion)
            {
            case Options.Vc.General.WindowsTargetPlatformVersion.v8_1: return("8.1");

            case Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10240_0: return("10.0.10240.0");

            case Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10586_0: return("10.0.10586.0");

            case Options.Vc.General.WindowsTargetPlatformVersion.v10_0_14393_0: return("10.0.14393.0");

            case Options.Vc.General.WindowsTargetPlatformVersion.v10_0_15063_0: return("10.0.15063.0");

            case Options.Vc.General.WindowsTargetPlatformVersion.v10_0_16299_0: return("10.0.16299.0");

            case Options.Vc.General.WindowsTargetPlatformVersion.v10_0_17134_0: return("10.0.17134.0");

            case Options.Vc.General.WindowsTargetPlatformVersion.v10_0_17763_0: return("10.0.17763.0");

            case Options.Vc.General.WindowsTargetPlatformVersion.v10_0_18362_0: return("10.0.18362.0");

            default:
                throw new ArgumentOutOfRangeException(windowsTargetPlatformVersion.ToString());
            }
        }
Exemple #3
0
        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;
            }
        }
Exemple #4
0
        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 GetWindowsExecutablePath(this DevEnv visualVersion, Platform platform)
        {
            KitsRootEnum kitsRoot = KitsRootPaths.GetUseKitsRootForDevEnv(visualVersion);

            string targetPlatform = (platform == Platform.win64) ? "x64" : "x86";

            var paths = new Strings();

            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:
            {
                Options.Vc.General.WindowsTargetPlatformVersion windowsTargetPlatformVersion = KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(visualVersion);

                string kitsRoot10Path  = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10);
                string platformVersion = windowsTargetPlatformVersion.ToVersionString();

                if (windowsTargetPlatformVersion >= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_15063_0)
                {
                    paths.Add(Path.Combine(kitsRoot10Path, "bin", platformVersion, targetPlatform));
                }
                else
                {
                    paths.Add(Path.Combine(kitsRoot10Path, "bin", targetPlatform));
                }

                if (windowsTargetPlatformVersion <= 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 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);
                }
            }
        }