Ejemplo n.º 1
0
        public VisualStudioInstance(ISetupInstance2 FromInstance)
        {
            this.IsLaunchable = FromInstance.IsLaunchable();
            this.IsComplete   = FromInstance.IsComplete();
            this.Name         = FromInstance.GetInstallationName();
            this.Path         = FromInstance.GetInstallationPath();
            this.Version      = FromInstance.GetInstallationVersion();
            this.DisplayName  = FromInstance.GetDisplayName();
            this.Description  = FromInstance.GetDescription();
            this.ResolvePath  = FromInstance.ResolvePath();
            this.EnginePath   = FromInstance.GetEnginePath();
            this.InstanceId   = FromInstance.GetInstanceId();
            this.ProductPath  = FromInstance.GetProductPath();

            try
            {
                var   time     = FromInstance.GetInstallDate();
                ulong high     = (ulong)time.dwHighDateTime;
                uint  low      = (uint)time.dwLowDateTime;
                long  fileTime = (long)((high << 32) + low);

                this.InstallDate = DateTime.FromFileTimeUtc(fileTime);
            }
            catch
            {
                this.InstallDate = DateTime.UtcNow;
            }

            // FromInstance.GetState();
            // FromInstance.GetPackages();
            // FromInstance.GetProduct();
            // FromInstance.GetProperties();
            // FromInstance.GetErrors();
        }
Ejemplo n.º 2
0
        public VisualStudioInstance(ISetupInstance2 FromInstance)
        {
            this.Packages            = new List <VisualStudioPackage>();
            this.Name                = FromInstance.GetInstallationName();
            this.Path                = FromInstance.GetInstallationPath();
            this.InstallationVersion = FromInstance.GetInstallationVersion();
            this.DisplayName         = FromInstance.GetDisplayName();
            this.ResolvePath         = FromInstance.ResolvePath();
            this.InstanceId          = FromInstance.GetInstanceId();
            this.ProductPath         = FromInstance.GetProductPath();
            this.State               = FromInstance.GetState();

            var packages = FromInstance.GetPackages();

            foreach (var item in packages)
            {
                this.Packages.Add(new VisualStudioPackage(item));
            }
        }
Ejemplo n.º 3
0
        private static VSInstance ParseInstance(ISetupInstance2 setupInstance2)
        {
            VSInstance inst = new VSInstance();

            string[] prodParts = setupInstance2.GetProduct().GetId().Split('.');
            Array.Reverse(prodParts);
            inst["Product"]              = prodParts[0];
            inst["ID"]                   = setupInstance2.GetInstanceId();
            inst["Name"]                 = setupInstance2.GetDisplayName(0x1000);
            inst["Description"]          = setupInstance2.GetDescription(0x1000);
            inst["InstallationName"]     = setupInstance2.GetInstallationName();
            inst["Version"]              = setupInstance2.GetInstallationVersion();
            inst["State"]                = Enum.GetName(typeof(InstanceState), setupInstance2.GetState());
            inst["InstallationPath"]     = setupInstance2.GetInstallationPath();
            inst["IsComplete"]           = setupInstance2.IsComplete();
            inst["IsLaunchable"]         = setupInstance2.IsLaunchable();
            inst["Common7ToolsPath"]     = inst["InstallationPath"] + @"\Common7\Tools\";
            inst["CmdPath"]              = inst["Common7ToolsPath"] + "VsDevCmd.bat";
            inst["VCAuxiliaryBuildPath"] = inst["InstallationPath"] + @"\VC\Auxiliary\Build\";
            inst["VCVarsAllPath"]        = inst["VCAuxiliaryBuildPath"] + "vcvarsall.bat";

            inst["Win8SDK"]        = "";
            inst["SDK10Full"]      = "";
            inst["VisualCppTools"] = "";

            Regex trimmer = new Regex(@"\.\d+$");

            List <string> packs = new List <String>();

            foreach (ISetupPackageReference package in setupInstance2.GetPackages())
            {
                string id = package.GetId();

                string ver    = package.GetVersion();
                string detail = "{\"id\": \"" + id + "\", \"version\":\"" + ver + "\"}";
                packs.Add("        " + detail);

                if (id.Contains("Component.MSBuild"))
                {
                    inst["MSBuild"]        = detail;
                    inst["MSBuildVerFull"] = ver;
                }
                else if (id.Contains("Microsoft.VisualCpp.Tools.Core"))
                {
                    inst["VCTools"] = detail;
                    inst["VisualCppToolsFullVersion"] = ver;
                    string majorMinor = trimmer.Replace(trimmer.Replace(ver, ""), "");
                    inst["VisualCppToolsVersionMinor"] = majorMinor;
                    inst["VCToolsVersionCode"]         = "vc" + majorMinor.Replace(".", "");
                }
                else if (id.Contains("Microsoft.Windows.81SDK"))
                {
                    if (inst["Win8SDK"].ToString().CompareTo(ver) > 0)
                    {
                        continue;
                    }
                    inst["Win8SDK"] = ver;
                }
                else if (id.Contains("Win10SDK_10"))
                {
                    if (inst["SDK10Full"].ToString().CompareTo(ver) > 0)
                    {
                        continue;
                    }
                    inst["SDK10Full"] = ver;
                }
            }
            packs.Sort();
            inst["Packages"] = packs.ToArray();

            string[] sdk10Parts = inst["SDK10Full"].ToString().Split('.');
            sdk10Parts[sdk10Parts.Length - 1] = "0";
            inst["SDK10"] = String.Join(".", sdk10Parts);
            inst["SDK"]   = inst["SDK10"].ToString() != "0" ? inst["SDK10"] : inst["Win8SDK"];
            if (inst.ContainsKey("MSBuildVerFull"))
            {
                string ver = trimmer.Replace(trimmer.Replace((string)inst["MSBuildVerFull"], ""), "");
                inst["MSBuildVer"]       = ver;
                inst["MSBuildToolsPath"] = inst["InstallationPath"] + @"\MSBuild\" + ver + @"\Bin\";
                inst["MSBuildPath"]      = inst["MSBuildToolsPath"] + "MSBuild.exe";
            }
            if (inst.ContainsKey("VCTools"))
            {
                string ver = trimmer.Replace((string)inst["VisualCppToolsFullVersion"], "");
                inst["VisualCppToolsX64"]   = inst["InstallationPath"] + @"\VC\Tools\MSVC\" + ver + @"\bin\HostX64\x64\";
                inst["VisualCppToolsX64CL"] = inst["VisualCppToolsX64"] + "cl.exe";
                inst["VisualCppToolsX86"]   = inst["InstallationPath"] + @"\VC\Tools\MSVC\" + ver + @"\bin\HostX86\x86\";
                inst["VisualCppToolsX86CL"] = inst["VisualCppToolsX86"] + "cl.exe";
                inst["VisualCppTools"]      = Is64() ? inst["VisualCppToolsX64"] : inst["VisualCppToolsX86"];
                inst["VisualCppToolsCL"]    = Is64() ? inst["VisualCppToolsX64CL"] : inst["VisualCppToolsX86CL"];
            }
            inst["IsVcCompatible"] = inst.JSONBool("SDK") && inst.JSONBool("MSBuild") && inst.JSONBool("VisualCppTools");
            return(inst);
        }