Exemplo n.º 1
0
        public static Task <VsInstance> Launch(VsHive hive, TimeSpan timeout, IDiagnostics diagnostics)
        {
            Process        process        = null;
            KillProcessJob killProcessJob = null;

            return(diagnostics.RunAsync("Launching Instance", async output =>
            {
                try
                {
                    process = VisualStudioUtil.StartProcess(hive);
                    killProcessJob = new KillProcessJob(process);
                    var dte = await VisualStudioUtil.GetDTE(process, timeout);
                    var invoker = (IRemoteComInvoker)dte.GetObject("VsixTesting.Invoker");
                    InvokeRemote(invoker, nameof(Remote.AutoKillWhenProcessExits), Process.GetCurrentProcess().Id);
                    killProcessJob.Release();
                    return new VsInstance(hive.Version, process, dte, invoker);
                }
                catch
                {
                    process?.Kill();
                    process?.Dispose();
                    throw;
                }
            }));
        }
Exemplo n.º 2
0
 public async Task LaunchAndDebug(IMessageBus messageBus, CancellationTokenSource cancellationTokenSource)
 {
     await ThreadUtil.RunOnStaThreadAsync(async() =>
     {
         using (var retryFilter = new RetryMessageFilter())
         {
             var diagnostics         = new VisualDiagnostics(this, DiagnosticMessageSink, messageBus, cancellationTokenSource);
             var extensionsToInstall = VsInstance.GetExtensionsToInstall(ExtensionDirectories);
             var installation        = VisualStudioUtil.FindInstallations().First(i => i.ApplicationPath == ApplicationPath);
             var hive = new VsHive(installation, RootSuffix);
             await VsInstance.Prepare(hive, extensionsToInstall, resetSettings: false, diagnostics, installInvoker: false);
             var process = await diagnostics.RunAsync("Launching Instance", () => Task.FromResult(VisualStudioUtil.StartProcess(hive)));
             if (Debugger.IsAttached)
             {
                 await VsInstance.AttachDebugger(process, DebugMixedMode, diagnostics);
             }
         }
     });
 }