public async Task Init(CancellationTokenSource cts)
        {
            if (initialized == true)
            {
                return;
            }

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            diagnostics = CreateDiagnostics(cts);
            var installation = Installations.Value.First(i => i.ApplicationPath == InstancePath);
            var hive         = new VsHive(installation, Settings.VsRootSuffix);
            await VsInstance.Prepare(hive, Settings.GetExtensionsToInstall(), Settings.VsResetSettings, diagnostics);

            instance = await VsInstance.Launch(hive, Settings.GetLaunchTimeout(), diagnostics);

            if (Debugger.IsAttached)
            {
                await VsInstance.AttachDebugger(instance.Process, Settings.VsDebugMixedMode, diagnostics);
            }
            instance.SetAssemblyResolver(TestAssemblyDirectory);
            rmt = instance.GetOrCreateSingletonService <Rmt>("VsixTesting.Xunit", Settings.VsSecureChannel);
            remoteTestAssemblyRunner = CreateRemoteTestAssemblyRunner(cts);
            initialized = true;
        }
Пример #2
0
        public async Task Init(CancellationTokenSource cts)
        {
            if (initialized == true)
            {
                return;
            }

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            diagnostics = CreateDiagnostics(cts);
            if (testCases.OfType <VsTestCase>().GroupBy(c => c.Settings.SecureChannel).Count() >= 2)
            {
                throw new Exception($"All test methods sharing the same Visual Studio Instance must also use the same value for {nameof(ITestSettings.SecureChannel)}.");
            }
            var installation = Installations.Value.First(i => i.ApplicationPath == InstancePath);
            var hive         = new VsHive(installation, Settings.RootSuffix);
            await VsInstance.Prepare(hive, GetExtensionsToInstall(), Settings.ResetSettings, diagnostics);

            instance = await VsInstance.Launch(hive, Settings.GetLaunchTimeout(), diagnostics);

            if (Debugger.IsAttached)
            {
                await VsInstance.AttachDebugger(instance.Process, Settings.DebugMixedMode, diagnostics);
            }
            instance.SetAssemblyResolver(TestAssemblyDirectory);
            rmt = instance.GetOrCreateSingletonService <Rmt>("VsixTesting.Xunit", Settings.SecureChannel);
            remoteTestAssemblyRunner = CreateRemoteTestAssemblyRunner(cts);
            initialized = true;
        }
Пример #3
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);
             }
         }
     });
 }