Ejemplo n.º 1
0
        public static string VersionToVersionString(VsVersion vsVersion)
        {
            switch (vsVersion)
            {
            case VsVersion.Vs2005:
                return("8.0");

            case VsVersion.Vs2008:
                return("9.0");

            case VsVersion.Vs2010:
                return("10.0");

            case VsVersion.Vs2012:
                return("11.0");

            case VsVersion.Vs2013:
                return("12.0");

            case VsVersion.Vs2015:
                return("14.0");

            case VsVersion.Vs2017:
                return("15.0");

            case VsVersion.Vs2019:
                return("16.0");

            default:
                return("");
            }
        }
        public void SetStyle(ToolStrip strip, VsVersion version, ThemeBase theme)
        {
            var apply = false;
            ToolStripProperties properties = null;

            if (!strips.ContainsKey(strip))
            {
                properties = new ToolStripProperties(strip) { VsVersion = version };
                strips.Add(strip, properties);
                apply = true;
            }
            else
            {
                properties = strips[strip];
                apply = properties.VsVersion != version;
            }

            if (apply)
            {
                if (theme == null)
                    strip.Renderer = DefaultRenderer;
                else
                    theme.ApplyTo(strip);
                properties.VsVersion = version;
            }
        }
Ejemplo n.º 3
0
        private static Assembly LoadSettingsAssembly(VsVersion version)
        {
            var    format = "Microsoft.VisualStudio.Settings{0}, Version={1}.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
            string suffix = "";

            switch (version)
            {
            case VsVersion.Vs2010:
                suffix = "";
                break;

            case VsVersion.Vs2012:
                suffix = ".11.0";
                break;

            case VsVersion.Vs2013:
                suffix = ".12.0";
                break;

            case VsVersion.Vs2015:
                suffix = ".14.0";
                break;

            case VsVersion.Vs2017:
                suffix = ".15.0";
                break;

            default:
                throw new Exception("Bad Version");
            }

            var strongName = string.Format(format, suffix, VsVersionUtil.GetVersionNumber(version));

            return(Assembly.Load(strongName));
        }
Ejemplo n.º 4
0
    protected override void OnStartup(StartupEventArgs e) {
      HasParams = e.Args.Length > 0;

      var xArgs = new string[e.Args.Length];
      for (int i = 0; i < xArgs.Length; i++) {
        xArgs[i] = e.Args[i].ToUpper();
      }
      IsUserKit = xArgs.Contains("-USERKIT");
      ResetHive = xArgs.Contains("-RESETHIVE");
      StayOpen = xArgs.Contains("-STAYOPEN");
      UseTask = !xArgs.Contains("-NOTASK");
      NoMsBuildClean = xArgs.Contains("-NOCLEAN");
      InstallTask = xArgs.Contains("-INSTALLTASK");
      DoNotLaunchVS = xArgs.Contains("-NOVSLAUNCH");
      // For use during dev of Builder only.
      IgnoreVS = xArgs.Contains("-IGNOREVS");
      TestMode = xArgs.Contains("-TESTMODE");
      if (xArgs.Contains("-VS2015") || xArgs.Contains("/VS2015")) {
        VsVersion = VsVersion.Vs2015;
        Paths.VsVersion = VsVersion.Vs2015;
      }

      if (xArgs.Contains("-VS2013") || xArgs.Contains("/VS2013")) {
        VsVersion = VsVersion.Vs2013;
        Paths.VsVersion = VsVersion.Vs2013;
      }

      if (xArgs.Contains("-VSEXPHIVE") || xArgs.Contains("/VSEXPHIVE")) {
        UseVsHive = true;
      }

      base.OnStartup(e);
    }
Ejemplo n.º 5
0
        public void SetStyle(ToolStrip strip, VsVersion version)
        {
            var apply = false;
            ToolStripProperties properties = null;

            if (!strips.ContainsKey(strip))
            {
                properties = new ToolStripProperties(strip)
                {
                    VsVersion = version
                };
                strips.Add(strip, properties);
                apply = true;
            }
            else
            {
                properties = strips[strip];
                apply      = properties.VsVersion != version;
            }

            if (apply)
            {
                strip.Renderer = version == VsVersion.Vs2013
                                     ? this.VS2013Renderer
                                     : version == VsVersion.Vs2012 ? VS2012Renderer : DefaultRenderer;
                properties.VsVersion = version;
            }
        }
        public void SetStyle(ToolStrip strip, VsVersion version, ThemeBase theme)
        {
            ToolStripProperties properties = null;

            if (!strips.ContainsKey(strip))
            {
                properties = new ToolStripProperties(strip)
                {
                    VsVersion = version
                };
                strips.Add(strip, properties);
            }
            else
            {
                properties = strips[strip];
            }

            if (theme == null)
            {
                if (DefaultRenderer != null)
                {
                    strip.Renderer = DefaultRenderer;
                }
            }
            else
            {
                theme.ApplyTo(strip);
            }

            properties.VsVersion = version;
        }
Ejemplo n.º 7
0
        public static bool IsVisualStudioInstalled(VsVersion vsVersion)
        {
            string[] subKeyNames = Registry.ClassesRoot.GetSubKeyNames();
            switch (vsVersion)
            {
            case VsVersion.Vs2005:
                return(Array.IndexOf(subKeyNames, "VisualStudio.DTE.8.0") > 0);

            case VsVersion.Vs2008:
                return(Array.IndexOf(subKeyNames, "VisualStudio.DTE.9.0") > 0);

            case VsVersion.Vs2010:
                return(Array.IndexOf(subKeyNames, "VisualStudio.DTE.10.0") > 0);

            case VsVersion.Vs2012:
                return(Array.IndexOf(subKeyNames, "VisualStudio.DTE.11.0") > 0);

            case VsVersion.Vs2013:
                return(Array.IndexOf(subKeyNames, "VisualStudio.DTE.12.0") > 0);

            case VsVersion.Vs2015:
                return(Array.IndexOf(subKeyNames, "VisualStudio.DTE.14.0") > 0);

            case VsVersion.Vs2017:
                return(Array.IndexOf(subKeyNames, "VisualStudio.DTE.15.0") > 0);

            case VsVersion.Vs2019:
                return(Array.IndexOf(subKeyNames, "VisualStudio.DTE.16.0") > 0);

            default:
                return(false);
            }
        }
Ejemplo n.º 8
0
        static Assembly CurrentDomain_AssemblyResolve_VS(object sender, ResolveEventArgs args)
        {
            if (!args.Name.StartsWith("Microsoft.VisualStudio"))
            {
                return(null);
            }

            var name = new AssemblyName(args.Name);

            if (name.Version != null && name.Version.Major == VsVersion.Major)
            {
                return(null);                   // Don't recurse.  I check the major version only because AssemblyName will resolve the build number from the GAC.
            }
            // Always specify a complete version to avoid partial assembly loading, which skips the GAC.
            name.Version = new Version(VsVersion.Major, VsVersion.Minor, 0, 0);
            name.Name    = versionMatcher.Replace(name.Name, VsVersion.ToString(2));
            Debug.WriteLine("Redirecting load of " + args.Name + ",\tfrom " + (args.RequestingAssembly == null ? "(unknown)" : args.RequestingAssembly.FullName));

            try {
                return(Assembly.Load(name));
            } catch (FileNotFoundException) {
                if (name.Name.EndsWith(".resources"))
                {
                    return(LoadResourceDll(name, InstallationDirectory, name.CultureInfo)
                           ?? LoadResourceDll(name, InstallationDirectory, name.CultureInfo.Parent));
                }
                return(Assembly.LoadFile(Path.Combine(InstallationDirectory, name.Name + ".dll")));
            }
        }
Ejemplo n.º 9
0
        protected override void OnStartup(StartupEventArgs e)
        {
            HasParams = e.Args.Length > 0;

            var xArgs = new string[e.Args.Length];

            for (int i = 0; i < xArgs.Length; i++)
            {
                xArgs[i] = e.Args[i].ToUpper();
            }
            IsUserKit      = xArgs.Contains("-USERKIT");
            ResetHive      = xArgs.Contains("-RESETHIVE");
            StayOpen       = xArgs.Contains("-STAYOPEN");
            UseTask        = !xArgs.Contains("-NOTASK");
            NoMsBuildClean = xArgs.Contains("-NOCLEAN");
            InstallTask    = xArgs.Contains("-INSTALLTASK");
            DoNotLaunchVS  = xArgs.Contains("-NOVSLAUNCH");
            // For use during dev of Builder only.
            IgnoreVS = xArgs.Contains("-IGNOREVS");
            TestMode = xArgs.Contains("-TESTMODE");
            if (xArgs.Contains("-VS2015") || xArgs.Contains("/VS2015"))
            {
                VsVersion       = VsVersion.Vs2015;
                Paths.VsVersion = VsVersion.Vs2015;
            }

            if (xArgs.Contains("-VSEXPHIVE") || xArgs.Contains("/VSEXPHIVE"))
            {
                UseVsHive = true;
            }

            base.OnStartup(e);
        }
Ejemplo n.º 10
0
        public void SetStyle(ToolStrip strip, ThemeBase theme)//VsVersion version,
        {
            ToolStripProperties           properties = null;
            VsVersion                     version    = VsVersion.Vs2015;
            VisualStudioToolStripRenderer vsRenderer = (VisualStudioToolStripRenderer)theme.ToolStripRenderer;

            vsRenderer.Refresh();

            if (!strips.ContainsKey(strip))
            {
                properties = new ToolStripProperties(strip)
                {
                    VsVersion = version
                };
                strips.Add(strip, properties);
            }
            else
            {
                properties = strips[strip];
            }

            if (theme == null)
            {
                if (DefaultRenderer != null)
                {
                    strip.Renderer = DefaultRenderer;
                }
            }
            else
            {
                theme.ApplyTo(strip);
            }
            properties.VsVersion = version;
        }
Ejemplo n.º 11
0
        public static int Year(this VsVersion version)
        {
            switch (version)
            {
            case VsVersion.Unknown:
                return(0);

            case VsVersion.VS2012:
            case VsVersion.VS2012_1:
                return(2012);

            case VsVersion.VS2013:
                return(2013);

            case VsVersion.VS2015:
                return(2015);

            case VsVersion.VS2017:
                return(2017);

            case VsVersion.VS2019:
                return(2019);

            default:
                throw new InvalidOperationException();
            }
        }
Ejemplo n.º 12
0
        private static Assembly LoadImplementationAssembly(VsVersion version)
        {
            var format     = "Microsoft.VisualStudio.ExtensionManager.Implementation, Version={0}.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
            var strongName = string.Format(format, VsVersionUtil.GetVersionNumber(version));

            return(Assembly.Load(strongName));
        }
Ejemplo n.º 13
0
            public void Version(string option, string version, VsVersion vsVersion)
            {
                var consoleContext = new TestConsoleContext();

                var commandLine = Program.ParseCommandLine(consoleContext, option, version);

                Assert.That(commandLine.VsVersion, Is.EqualTo(vsVersion));
            }
Ejemplo n.º 14
0
        public static string GetVsTestConsolePath(VsVersion version)
        {
            // TODO select packages versions by VsVersion
            string nugetDir = Path.Combine(GtaSolutionDir, "Tests.Common", "VsTestConsole");

            return(Directory.GetFiles(nugetDir, "vstest.console.exe", SearchOption.AllDirectories)
                   .Single());
        }
Ejemplo n.º 15
0
                public void FilterVsVersion(VsVersion vsVersion, VsVersion filterVsVersion, bool expect)
                {
                    var installedVersion = new InstalledVersion(null, vsVersion, "Community");
                    var commandLine      = new CommandLine(vsVersion: filterVsVersion);

                    var include = Program.Filter(installedVersion, commandLine);

                    Assert.That(include, Is.EqualTo(expect));
                }
Ejemplo n.º 16
0
        protected List<Project> SelectProjects(List<Project> projects, VsVersion version, params string[] names)
        {
            List<Project> matchedProjects = new List<Project>();

            foreach (string name in names)
                matchedProjects.AddRange(projects.Where(x => x.Versions.Contains(version) && x.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase)));

            return matchedProjects;
        }
Ejemplo n.º 17
0
        public string GetProjectFileName(VsVersion version)
        {
            for (int i = 0; i < Versions.Length; i++)
            {
                if (Versions[i] == version)
                    return GetProjectFileName(i);
            }

            throw new Exception("Version not found.");
        }
Ejemplo n.º 18
0
        public static string VersionString(this VsVersion version)
        {
            switch (version)
            {
            case VsVersion.Unknown:
            case VsVersion.VS2012:
                return("0.0");

            default:
                return($"{(int)version}.0");
            }
        }
Ejemplo n.º 19
0
        public static bool PrintsTimeStampAndSeverity(this VsVersion version)
        {
            switch (version)
            {
            case VsVersion.Unknown:
            case VsVersion.VS2012:
            case VsVersion.VS2012_1:
            case VsVersion.VS2013:
            case VsVersion.VS2015:
                return(false);

            default:
                return(true);
            }
        }
Ejemplo n.º 20
0
        public static bool NeedsToBeThrottled(this VsVersion version)
        {
            switch (version)
            {
            case VsVersion.Unknown:
            case VsVersion.VS2012:
            case VsVersion.VS2012_1:
            case VsVersion.VS2013:
            case VsVersion.VS2015:
                return(true);

            default:
                return(false);
            }
        }
Ejemplo n.º 21
0
        public static void LogVisualStudioVersion(ILogger logger)
        {
            VsVersion version = VsVersionUtils.VsVersion;

            switch (version)
            {
            // warning printed while checking version
            case VsVersion.Unknown:
            case VsVersion.VS2012:
                return;

            default:
                logger.DebugInfo(String.Format(Resources.VSVersion, version));
                break;
            }
        }
Ejemplo n.º 22
0
        public static string GetVsTestConsolePath(VsVersion version)
        {
            switch (version)
            {
            case VsVersion.VS2012_1:
            case VsVersion.VS2013:
            case VsVersion.VS2015:
                return($@"C:\Program Files (x86)\Microsoft Visual Studio {version:d}.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe");

            case VsVersion.VS2017:
                return(Path.Combine(VS2017Location.Value, @"Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"));

            default:
                throw new InvalidOperationException();
            }
        }
Ejemplo n.º 23
0
        public static void LogVisualStudioVersion(ILogger logger)
        {
            VsVersion version = VsVersionUtils.GetVisualStudioVersion(logger);

            switch (version)
            {
            // warning printed while checking version
            case VsVersion.Unknown:
            case VsVersion.VS2012:
                return;

            default:
                logger.DebugInfo($"Visual Studio Version: {version}");
                break;
            }
        }
Ejemplo n.º 24
0
        private static string GenerateConfigFileContents(VsVersion version)
        {
            Debug.Assert(version != VsVersion.Vs2010);
            const string contentFormat = @"
<configuration>
  <runtime>
    <assemblyBinding xmlns=""urn:schemas-microsoft-com:asm.v1"">
      <dependentAssembly>
        <assemblyIdentity name=""Microsoft.VisualStudio.ExtensionManager"" publicKeyToken=""b03f5f7f11d50a3a"" culture=""neutral"" />
        <bindingRedirect oldVersion=""10.0.0.0-{0}"" newVersion=""{0}"" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
";

            return(string.Format(contentFormat, GetAssemblyVersionNumber(version)));
        }
Ejemplo n.º 25
0
        public static bool UnInstallAddIn(VsVersion vsVersion)
        {
            switch (vsVersion)
            {
            case VsVersion.Vs2005:
            case VsVersion.Vs2008:
            case VsVersion.Vs2010:
            case VsVersion.Vs2012:
            case VsVersion.Vs2013:
                return(UnInstallAddIn(GetAddInstallPath(vsVersion), vsVersion));

            case VsVersion.Vs2015:
            case VsVersion.Vs2017:
            case VsVersion.Vs2019:
                return(InstallVsix(vsVersion));

            default:
                throw new ArgumentOutOfRangeException("vsVer", vsVersion, null);
            }
        }
Ejemplo n.º 26
0
        public VsVersions()
        {
            InitializeComponent();

            ChosenVersions = 0;

            VsVersion latest = 0, latestExpress = 0;
            for (VsVersion ver = VsVersion.VCSExpress; ver <= VsVersion.VisualStudio14; ver = (VsVersion)((byte)ver * 2))
                if (FromVsVersion(ver).IsEnabled = ((PossibleVersions & ver) != 0))
                {
                    latest = ver;
                    if (ver == VsVersion.VCSExpress || ver == VsVersion.WDExpress11 || ver == VsVersion.WDExpress12)
                        latestExpress = ver;
                }

            VCs10.Checked += (s, e) => ChosenVersions |= VsVersion.VCSExpress;
            VCs10.Unchecked += (s, e) => ChosenVersions ^= VsVersion.VCSExpress;

            Vs10.Checked += (s, e) => ChosenVersions |= VsVersion.VisualStudio10;
            Vs10.Unchecked += (s, e) => ChosenVersions ^= VsVersion.VisualStudio10;

            WdE11.Checked += (s, e) => ChosenVersions |= VsVersion.WDExpress11;
            WdE11.Unchecked += (s, e) => ChosenVersions ^= VsVersion.WDExpress11;

            Vs11.Checked += (s, e) => ChosenVersions |= VsVersion.VisualStudio11;
            Vs11.Unchecked += (s, e) => ChosenVersions ^= VsVersion.VisualStudio11;

            WdE12.Checked += (s, e) => ChosenVersions |= VsVersion.WDExpress12;
            WdE12.Unchecked += (s, e) => ChosenVersions ^= VsVersion.WDExpress12;

            Vs12.Checked += (s, e) => ChosenVersions |= VsVersion.VisualStudio12;
            Vs12.Unchecked += (s, e) => ChosenVersions ^= VsVersion.VisualStudio12;

            Vs14.Checked += (s, e) => ChosenVersions |= VsVersion.VisualStudio14;
            Vs14.Unchecked += (s, e) => ChosenVersions ^= VsVersion.VisualStudio14;

            if (latest != 0)
                FromVsVersion(latest).IsChecked = true;
            if (latestExpress != 0)
                FromVsVersion(latestExpress).IsChecked = true;
        }
Ejemplo n.º 27
0
        private void ValidateSpecific(VsVersion vsVersion, IEnumerable <ReferenceData> referenceDataCollection)
        {
            var badList = new List <ReferenceData>();
            var count   = 0;

            foreach (var refData in referenceDataCollection)
            {
                switch (refData.Kind)
                {
                case ReferenceKind.ComponentVersioned:
                case ReferenceKind.ShellVersioned:
                case ReferenceKind.ShellPia:
                    if (vsVersion < refData.VsVersion)
                    {
                        badList.Add(refData);
                    }
                    break;

                case ReferenceKind.Framework:
                case ReferenceKind.VsVim:
                    // Nothing to validate for these.
                    break;

                case ReferenceKind.Editor:
                case ReferenceKind.ShellNonVersioned:
                    if (refData.VsVersion != vsVersion)
                    {
                        badList.Add(refData);
                    }
                    break;

                default:
                    throw Contract.GetInvalidEnumException(refData.Kind);
                }

                count++;
            }

            Assert.True(count >= 8);
            Assert.Empty(badList);
        }
Ejemplo n.º 28
0
 public static bool InstallAddIn(string AddInstallPath, VsVersion vsVersion)
 {
     try
     {
         if (!Directory.Exists(AddInstallPath))
         {
             Directory.CreateDirectory(AddInstallPath);
         }
         //FileStream fileStream = new FileStream(Path.Combine(AddInstallPath, "DevExpress.Patch.Vsa.AddIn"), FileMode.Create, FileAccess.Write);
         //fileStream.Write(Resources.AddInXml, 0, Resources.AddInXml.Length);
         //fileStream.Close();
         //FileStream fileStream2 = new FileStream(Path.Combine(AddInstallPath, "DevExpress.Patch.Vsa.dll"), FileMode.Create, FileAccess.Write);
         //fileStream2.Write(Resources.AddInDll, 0, Resources.AddInDll.Length);
         //fileStream2.Close();
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 29
0
        CheckBox FromVsVersion(VsVersion version)
        {
            switch (version)
            {
                case VsVersion.VCSExpress:
                    return VCs10;
                case VsVersion.VisualStudio10:
                    return Vs10;
                case VsVersion.WDExpress11:
                    return WdE11;
                case VsVersion.VisualStudio11:
                    return Vs11;
                case VsVersion.WDExpress12:
                    return WdE12;
                case VsVersion.VisualStudio12:
                    return Vs12;
                case VsVersion.VisualStudio14:
                    return Vs14;
            }

            throw new ArgumentOutOfRangeException("version");
        }
Ejemplo n.º 30
0
        public static int GetVersionNumber(VsVersion version)
        {
            switch (version)
            {
            case VsVersion.Vs2010:
                return(10);

            case VsVersion.Vs2012:
                return(11);

            case VsVersion.Vs2013:
                return(12);

            case VsVersion.Vs2015:
                return(14);

            case VsVersion.Vs2017:
                return(15);

            default:
                throw new Exception("Bad Version");
            }
        }
Ejemplo n.º 31
0
 public static bool UnInstallAddIn(string AddInstallPath, VsVersion vsVersion)
 {
     try
     {
         string path = "DevExpress.Patch.Vsa.AddIn";
         path = Path.Combine(AddInstallPath, path);
         if (File.Exists(path))
         {
             File.Delete(path);
         }
         path = "DevExpress.Patch.Vsa.dll";
         path = Path.Combine(AddInstallPath, path);
         if (File.Exists(path))
         {
             File.Delete(path);
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 32
0
        private static bool InstallVsix(VsVersion vsVersion)
        {
            if (!IsVsixSupported())
            {
                return(false);
            }
            string text = null;

            switch (vsVersion)
            {
            case VsVersion.Vs2015:
            case VsVersion.Vs2017:
            case VsVersion.Vs2019:
                text = "ac087982-c7c2-4312-b8ea-4a31e1add2c6";
                break;

            default:
                throw new ArgumentOutOfRangeException("vsVer", vsVersion, null);

            case VsVersion.Vs2005:
            case VsVersion.Vs2008:
            case VsVersion.Vs2010:
            case VsVersion.Vs2012:
            case VsVersion.Vs2013:
                break;
            }
            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }
            return(Process.Start(new ProcessStartInfo(GetVsixInstallerPath(), $"/quiet /admin /uninstall:{text}")
            {
                CreateNoWindow = true,
                RedirectStandardOutput = true,
                UseShellExecute = false
            })?.WaitForExit(300000) ?? false);
        }
Ejemplo n.º 33
0
        public void SetStyle(ToolStrip strip, VsVersion version)
        {
            var apply = false;
            ToolStripProperties properties = null;

            if (!strips.ContainsKey(strip))
            {
                properties = new ToolStripProperties(strip) { VsVersion = version };
                strips.Add(strip, properties);
                apply = true;
            }
            else
            {
                properties = strips[strip];
                apply = properties.VsVersion != version;
            }

            if (apply)
            {
                strip.Renderer = version == VsVersion.Vs2013
                                     ? this.VS2013Renderer
                                     : version == VsVersion.Vs2012 ? VS2012Renderer : DefaultRenderer;
                properties.VsVersion = version;
            }
        }
Ejemplo n.º 34
0
 static VsVersionUtils()
 {
     VsVersion = GetVisualStudioVersion();
 }
Ejemplo n.º 35
0
 private static string GetAddInstallPath(VsVersion vsVersion) => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Microsoft\\VisualStudio\\@vsVer@\\Addins").Replace("@vsVer@", VersionToVersionString(vsVersion));
Ejemplo n.º 36
0
 internal static string GetAssemblyVersionNumber(VsVersion version)
 {
     return(string.Format("{0}.0.0.0", VsVersionUtil.GetVersionNumber(version)));
 }
Ejemplo n.º 37
0
        private static Type GetExtensionManagerServiceType(VsVersion version)
        {
            var assembly = LoadImplementationAssembly(version);

            return(assembly.GetType("Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService"));
        }