未验证 提交 69ef6226 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #33100 from sharwell/vs2019-tests

Support running integration tests in VS 2019
......@@ -2,15 +2,20 @@
using System;
using Microsoft.VisualStudio.Shell.Interop;
using vsStartUp = EnvDTE.vsStartUp;
namespace Microsoft.VisualStudio.IntegrationTest.Utilities.InProcess
{
internal class StartPage_InProc : InProcComponent
{
// Values come from Tools -> Options -> Environment -> Startup -> At startup
private const int ShowEmptyEnvironment = 4;
private const int ShowEmptyEnvironment = (int)vsStartUp.vsStartUpEmptyEnvironment;
private const int ShowStartPage = 5;
// These values apply to Visual Studio 2019
private const int VS2019ShowStartWindow = 13;
private const int VS2019ShowEmptyEnvironment = 10;
public static StartPage_InProc Create()
=> new StartPage_InProc();
......@@ -19,7 +24,14 @@ public bool IsEnabled()
return InvokeOnUIThread(() =>
{
var property = GetProperty();
if (new Version(property.DTE.Version).Major == 16)
{
return (int)property.Value == VS2019ShowStartWindow;
}
else
{
return (int)property.Value == ShowStartPage;
}
});
}
......@@ -28,7 +40,14 @@ public void SetEnabled(bool enabled)
InvokeOnUIThread(() =>
{
var property = GetProperty();
if (new Version(property.DTE.Version).Major == 16)
{
property.Value = enabled ? VS2019ShowStartWindow : VS2019ShowEmptyEnvironment;
}
else
{
property.Value = enabled ? ShowStartPage : ShowEmptyEnvironment;
}
});
}
......
......@@ -163,7 +163,9 @@ private async Task UpdateCurrentlyRunningInstanceAsync(ImmutableHashSet<string>
supportedPackageIds = ImmutableHashSet.CreateRange(instance.GetPackages().Select((supportedPackage) => supportedPackage.GetId()));
installationPath = instance.GetInstallationPath();
hostProcess = StartNewVisualStudioProcess(installationPath);
var instanceVersion = instance.GetInstallationVersion();
var majorVersion = int.Parse(instanceVersion.Substring(0, instanceVersion.IndexOf('.')));
hostProcess = StartNewVisualStudioProcess(installationPath, majorVersion);
var procDumpInfo = ProcDumpInfo.ReadFromEnvironment();
if (procDumpInfo != null)
......@@ -248,8 +250,6 @@ private static ISetupInstance LocateVisualStudioInstance(ImmutableHashSet<string
{
var isMatch = true;
{
isMatch &= instance.GetInstallationVersion().StartsWith(VsProductVersion);
if (haveVsInstallDir)
{
var installationPath = instance.GetInstallationPath();
......@@ -257,6 +257,10 @@ private static ISetupInstance LocateVisualStudioInstance(ImmutableHashSet<string
installationPath = installationPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
isMatch &= installationPath.Equals(vsInstallDir, StringComparison.OrdinalIgnoreCase);
}
else
{
isMatch &= instance.GetInstallationVersion().StartsWith(VsProductVersion);
}
}
return isMatch;
});
......@@ -291,12 +295,19 @@ private static ISetupInstance LocateVisualStudioInstance(ImmutableHashSet<string
"There were no instances of Visual Studio found that match the specified requirements.");
}
private static Process StartNewVisualStudioProcess(string installationPath)
private static Process StartNewVisualStudioProcess(string installationPath, int majorVersion)
{
var vsExeFile = Path.Combine(installationPath, @"Common7\IDE\devenv.exe");
var vsRegEditExeFile = Path.Combine(installationPath, @"Common7\IDE\VsRegEdit.exe");
if (_firstLaunch)
{
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();
}
// 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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册