Esempio n. 1
0
        public override string GetVsVersionAndInstance()
        {
            if (string.IsNullOrEmpty(_vsVersionInstance))
            {
                ISetupConfiguration configuration = new SetupConfiguration() as ISetupConfiguration;
                ISetupInstance      instance      = configuration.GetInstanceForCurrentProcess();
                string version    = instance.GetInstallationVersion();
                string instanceId = instance.GetInstanceId();
                _vsVersionInstance = $"{version}-{instanceId}";
            }

            return(_vsVersionInstance);
        }
        private void InvokeVsixInstaller(string tempDir, string rootSuffix)
        {
            var                  process       = System.Diagnostics.Process.GetCurrentProcess();
            var                  dir           = Path.GetDirectoryName(process.MainModule.FileName);
            var                  exe           = Path.Combine(dir, "VSIXInstaller.exe");
            var                  configuration = new SetupConfiguration() as ISetupConfiguration;
            ISetupInstance       instance      = configuration.GetInstanceForCurrentProcess();
            IEnumerable <string> vsixFiles     = Directory.EnumerateFiles(tempDir, "*.vsix").Select(f => Path.GetFileName(f));

            var start = new ProcessStartInfo {
                FileName         = exe,
                Arguments        = $"{string.Join(" ", vsixFiles)} /instanceIds:{instance.GetInstanceId()}",
                WorkingDirectory = tempDir,
                UseShellExecute  = false,
            };

            if (!string.IsNullOrEmpty(rootSuffix))
            {
                start.Arguments += $" /rootSuffix:{rootSuffix}";
            }

            System.Diagnostics.Process.Start(start);
        }