diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs index c1ef16c9e2de114af9861ed48db87b98f71ba005..1b7443853b93801af5df753bfbcdf56d251f5cfb 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");