From 9ee971ce60e099af07921f91ee2555c3c6711f87 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 21 May 2020 10:43:52 -0700 Subject: [PATCH] Initialize integration tests without showing console windows --- .../VisualStudioInstanceFactory.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs index 50cceb1ce052a..379915aaafc28 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs @@ -315,20 +315,20 @@ private static Process StartNewVisualStudioProcess(string installationPath, int if (majorVersion == 16) { // Make sure the start window doesn't show on launch - Process.Start(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU General OnEnvironmentStartup dword 10").WaitForExit(); + Process.Start(CreateSilentStartInfo(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU General OnEnvironmentStartup dword 10")).WaitForExit(); } // 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(); + Process.Start(CreateSilentStartInfo(vsExeFile, $"/clearcache {VsLaunchArgs}")).WaitForExit(); + Process.Start(CreateSilentStartInfo(vsExeFile, $"/updateconfiguration {VsLaunchArgs}")).WaitForExit(); + Process.Start(CreateSilentStartInfo(vsExeFile, $"/resetsettings General.vssettings /command \"File.Exit\" {VsLaunchArgs}")).WaitForExit(); // Disable roaming settings to avoid interference from the online user profile - Process.Start(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU \"ApplicationPrivateSettings\\Microsoft\\VisualStudio\" RoamingEnabled string \"1*System.Boolean*False\"").WaitForExit(); + Process.Start(CreateSilentStartInfo(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU \"ApplicationPrivateSettings\\Microsoft\\VisualStudio\" RoamingEnabled string \"1*System.Boolean*False\"")).WaitForExit(); // Disable background download UI to avoid toasts - Process.Start(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU \"FeatureFlags\\Setup\\BackgroundDownload\" Value dword 0").WaitForExit(); + Process.Start(CreateSilentStartInfo(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU \"FeatureFlags\\Setup\\BackgroundDownload\" Value dword 0")).WaitForExit(); // Remove legacy experiment setting for controlling async completion to ensure it does not interfere. // We no longer set this value, but it could be in place from an earlier test run on the same machine. @@ -341,7 +341,7 @@ private static Process StartNewVisualStudioProcess(string installationPath, int // Disable text editor error reporting because it pops up a dialog. We want to either fail fast in our // custom handler or fail silently and continue testing. - Process.Start(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU \"Text Editor\" \"Report Exceptions\" dword 0").WaitForExit(); + Process.Start(CreateSilentStartInfo(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU \"Text Editor\" \"Report Exceptions\" dword 0")).WaitForExit(); _firstLaunch = false; } @@ -355,6 +355,11 @@ private static Process StartNewVisualStudioProcess(string installationPath, int Debug.WriteLine($"Launched a new instance of Visual Studio. (ID: {process.Id})"); return process; + + static ProcessStartInfo CreateSilentStartInfo(string fileName, string arguments) + { + return new ProcessStartInfo(fileName, arguments) { CreateNoWindow = true, UseShellExecute = false }; + } } private static string GetAssemblyDirectory()