From b0ec0d50933bb26a17c109a4b9a9d4e2b8bc2e06 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Fri, 13 Jul 2018 11:44:54 -0500 Subject: [PATCH] Only reset the experimental instance the first time it's launched This improves the performance of integration tests by reducing the amount of time it takes to restart a Visual Studio instance. --- .../VisualStudioInstanceFactory.cs | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs index c1ef16c9e2d..1b7443853b9 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs @@ -30,6 +30,11 @@ public sealed class VisualStudioInstanceFactory : IDisposable /// private VisualStudioInstance _currentlyRunningInstance; + /// + /// Identifies the first time a Visual Studio instance is launched during an integration test run. + /// + private static bool _firstLaunch = true; + static VisualStudioInstanceFactory() { var majorVsProductVersion = VsProductVersion.Split('.')[0]; @@ -287,11 +292,16 @@ private static Process StartNewVisualStudioProcess(string installationPath) { var vsExeFile = Path.Combine(installationPath, @"Common7\IDE\devenv.exe"); - // BUG: Currently building with /p:DeployExtension=true does not always cause the MEF cache to recompose... - // So, run clearcache and updateconfiguration to workaround https://devdiv.visualstudio.com/DevDiv/_workitems?id=385351. - Process.Start(vsExeFile, $"/clearcache {VsLaunchArgs}").WaitForExit(); - Process.Start(vsExeFile, $"/updateconfiguration {VsLaunchArgs}").WaitForExit(); - Process.Start(vsExeFile, $"/resetsettings General.vssettings /command \"File.Exit\" {VsLaunchArgs}").WaitForExit(); + if (_firstLaunch) + { + // BUG: Currently building with /p:DeployExtension=true does not always cause the MEF cache to recompose... + // So, run clearcache and updateconfiguration to workaround https://devdiv.visualstudio.com/DevDiv/_workitems?id=385351. + Process.Start(vsExeFile, $"/clearcache {VsLaunchArgs}").WaitForExit(); + Process.Start(vsExeFile, $"/updateconfiguration {VsLaunchArgs}").WaitForExit(); + Process.Start(vsExeFile, $"/resetsettings General.vssettings /command \"File.Exit\" {VsLaunchArgs}").WaitForExit(); + + _firstLaunch = false; + } // Make sure we kill any leftover processes spawned by the host IntegrationHelper.KillProcess("DbgCLR"); -- GitLab