Esempio n. 1
0
        public static string GetVCTargetsPath(this DevEnv visualVersion)
        {
            if (!visualVersion.IsVisualStudio())
            {
                return(null);
            }

            switch (visualVersion)
            {
            case DevEnv.vs2010:
                return(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"MSBuild\Microsoft.Cpp\v4.0")));

            case DevEnv.vs2012:
            case DevEnv.vs2013:
            case DevEnv.vs2015:
                string versionSubfolder = visualVersion.GetDefaultPlatformToolset().ToUpperInvariant();     // this is enough for now but we could make a specific method to retrieve this value
                return(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"MSBuild\Microsoft.Cpp\v4.0", versionSubfolder)));

            case DevEnv.vs2017:
                return(Path.Combine(visualVersion.GetVisualStudioDir(), @"Common7\IDE\VC\VCTargets"));

            case DevEnv.vs2019:
                return(Path.Combine(visualVersion.GetVisualStudioDir(), @"MSBuild\Microsoft\VC\v160"));

            default:
                throw new ArgumentOutOfRangeException(nameof(visualVersion), visualVersion, null);
            }
        }
Esempio n. 2
0
        public static string GetVisualStudioVCRootPath(this DevEnv visualVersion)
        {
            string visualStudioVCRootPath = s_visualStudioVCRootPathCache.GetOrAdd(visualVersion, devEnv =>
            {
                string vsDir = visualVersion.GetVisualStudioDir();
                switch (visualVersion)
                {
                case DevEnv.vs2010:
                case DevEnv.vs2012:
                case DevEnv.vs2013:
                case DevEnv.vs2015:
                    return(Path.Combine(vsDir, "VC"));

                case DevEnv.vs2017:
                case DevEnv.vs2019:
                    string compilerVersion = visualVersion.GetDefaultCompilerVersion();     // default fallback
                    try
                    {
                        string toolchainFile = Path.Combine(vsDir, "VC", "Auxiliary", "Build", "Microsoft.VCToolsVersion.default.txt");
                        if (File.Exists(toolchainFile))
                        {
                            using (StreamReader file = new StreamReader(toolchainFile))
                                compilerVersion = file.ReadLine().Trim();
                        }
                    }
                    catch { }

                    return(Path.Combine(vsDir, @"VC\Tools\MSVC", compilerVersion));
                }
                throw new ArgumentOutOfRangeException("VS version not recognized " + visualVersion);
            });

            return(visualStudioVCRootPath);
        }
Esempio n. 3
0
        public static Version GetVisualStudioVCRedistVersion(this DevEnv visualVersion)
        {
            Version version = s_visualStudioVCRedistVersionCache.GetOrAdd(visualVersion, devEnv =>
            {
                string vsDir = visualVersion.GetVisualStudioDir();
                switch (visualVersion)
                {
                case DevEnv.vs2017:
                case DevEnv.vs2019:
                    string versionString = visualVersion.GetDefaultRedistVersion();     // default fallback
                    try
                    {
                        string toolchainFile = Path.Combine(vsDir, "VC", "Auxiliary", "Build", "Microsoft.VCRedistVersion.default.txt");
                        if (File.Exists(toolchainFile))
                        {
                            using (StreamReader file = new StreamReader(toolchainFile))
                                versionString = file.ReadLine().Trim();
                        }
                    }
                    catch { }

                    return(new Version(versionString));
                }
                throw new ArgumentOutOfRangeException("VS version not recognized " + visualVersion);
            });

            return(version);
        }
Esempio n. 4
0
        public static Version GetVisualStudioVCToolsVersion(this DevEnv visualVersion)
        {
            if (!visualVersion.IsVisualStudio())
            {
                throw new Error($"{visualVersion} is not a visual studio version!");
            }

            Version version = s_visualStudioVCToolsVersionCache.GetOrAdd(visualVersion, devEnv =>
            {
                string versionString = visualVersion.GetDefaultCompilerVersion(); // default fallback
                try
                {
                    string toolchainFile = Path.Combine(visualVersion.GetVisualStudioDir(), "VC", "Auxiliary", "Build", "Microsoft.VCToolsVersion.default.txt");
                    if (File.Exists(toolchainFile))
                    {
                        using (StreamReader file = new StreamReader(toolchainFile))
                            versionString = file.ReadLine().Trim();
                    }
                }
                catch { }

                return(new Version(versionString));
            });

            return(version);
        }
Esempio n. 5
0
        public static string GetVisualStudioVCRootPath(this DevEnv visualVersion)
        {
            string vsDir = visualVersion.GetVisualStudioDir();

            switch (visualVersion)
            {
            case DevEnv.vs2010:
            case DevEnv.vs2012:
            case DevEnv.vs2013:
            case DevEnv.vs2015:
                return(Path.Combine(vsDir, "VC"));

            case DevEnv.vs2017:
                string compilerVersion = "14.10.25017";     // default fallback
                try
                {
                    using (StreamReader file = new StreamReader(Path.Combine(vsDir, "VC", "Auxiliary", "Build", "Microsoft.VCToolsVersion.default.txt")))
                        compilerVersion = file.ReadLine().Trim();
                }
                catch { }

                return(Path.Combine(vsDir, @"VC\Tools\MSVC", compilerVersion));
            }
            throw new ArgumentOutOfRangeException("VS version not recognized " + visualVersion);
        }
Esempio n. 6
0
            public static string LLVMInstallDirVsEmbedded(DevEnv devEnv)
            {
                if (OverridenLLVMInstallDir)
                {
                    return(LLVMInstallDir);
                }

                string vsDir = devEnv.GetVisualStudioDir();

                return(Path.Combine(vsDir, "VC", "Tools", "Llvm", "x64"));
            }
Esempio n. 7
0
        public static string GetVisualStudioVCRootPath(this DevEnv visualVersion)
        {
            string visualStudioVCRootPath = s_visualStudioVCRootPathCache.GetOrAdd(visualVersion, devEnv =>
            {
                string vsDir = visualVersion.GetVisualStudioDir();
                switch (visualVersion)
                {
                case DevEnv.vs2015:
                    return(Path.Combine(vsDir, "VC"));

                case DevEnv.vs2017:
                case DevEnv.vs2019:
                    return(Path.Combine(vsDir, @"VC\Tools\MSVC", visualVersion.GetVisualStudioVCToolsVersion().ToString()));
                }
                throw new ArgumentOutOfRangeException("VS version not recognized " + visualVersion);
            });

            return(visualStudioVCRootPath);
        }
Esempio n. 8
0
        public static Version GetVisualStudioVCRedistVersion(this DevEnv visualVersion)
        {
            Version version = s_visualStudioVCRedistVersionCache.GetOrAdd(visualVersion, devEnv =>
            {
                string vsDir         = visualVersion.GetVisualStudioDir();
                string versionString = visualVersion.GetDefaultRedistVersion(); // default fallback
                try
                {
                    string toolchainFile = Path.Combine(vsDir, "VC", "Auxiliary", "Build", "Microsoft.VCRedistVersion.default.txt");
                    if (File.Exists(toolchainFile))
                    {
                        using (StreamReader file = new StreamReader(toolchainFile))
                            versionString = file.ReadLine().Trim();
                    }
                }
                catch { }

                return(new Version(versionString));
            });

            return(version);
        }
Esempio n. 9
0
        public static string GetVisualStudioVCRootPath(this DevEnv visualVersion)
        {
            if (!visualVersion.IsVisualStudio())
            {
                throw new Error($"{visualVersion} is not a visual studio version!");
            }

            string visualStudioVCRootPath = s_visualStudioVCRootPathCache.GetOrAdd(visualVersion, devEnv =>
            {
                string vsDir = visualVersion.GetVisualStudioDir();
                if (visualVersion > DevEnv.vs2015)
                {
                    return(Path.Combine(vsDir, @"VC\Tools\MSVC", visualVersion.GetVisualStudioVCToolsVersion().ToString()));
                }
                else
                {
                    return(Path.Combine(vsDir, "VC"));
                }
            });

            return(visualStudioVCRootPath);
        }