Skip to content

Commit 76c8721

Browse files
committed
Update test harness to locate the correct instance of Visual Studio 2017
See dotnet/roslyn#27966
1 parent f1bc474 commit 76c8721

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Tvl.VisualStudio.MouseFastScroll.IntegrationTests/Harness/VisualStudioInstanceFactory.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,24 @@ private static IEnumerable<ISetupInstance> EnumerateVisualStudioInstancesViaInst
208208

209209
private static Tuple<string, Version, ImmutableHashSet<string>, InstanceState> LocateVisualStudioInstance(Version version, ImmutableHashSet<string> requiredPackageIds)
210210
{
211-
var vsInstallDir = Environment.GetEnvironmentVariable("VSInstallDir");
211+
var vsInstallDir = Environment.GetEnvironmentVariable("__UNITTESTEXPLORER_VSINSTALLPATH__")
212+
?? Environment.GetEnvironmentVariable("VSAPPIDDIR");
213+
if (vsInstallDir != null)
214+
{
215+
vsInstallDir = Path.GetFullPath(Path.Combine(vsInstallDir, @"..\.."));
216+
}
217+
else
218+
{
219+
vsInstallDir = Environment.GetEnvironmentVariable("VSInstallDir");
220+
}
221+
212222
var haveVsInstallDir = !string.IsNullOrEmpty(vsInstallDir);
213223

214224
if (haveVsInstallDir)
215225
{
216226
vsInstallDir = Path.GetFullPath(vsInstallDir);
217227
vsInstallDir = vsInstallDir.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
218-
Debug.WriteLine($"An environment variable named 'VSInstallDir' was found, adding this to the specified requirements. (VSInstallDir: {vsInstallDir})");
228+
Debug.WriteLine($"An environment variable named 'VSInstallDir' (or equivalent) was found, adding this to the specified requirements. (VSInstallDir: {vsInstallDir})");
219229
}
220230

221231
var instances = EnumerateVisualStudioInstances().Where((instance) =>
@@ -225,11 +235,12 @@ private static Tuple<string, Version, ImmutableHashSet<string>, InstanceState> L
225235
isMatch &= version.Major == instance.Item2.Major;
226236
isMatch &= instance.Item2 >= version;
227237

228-
if (haveVsInstallDir)
238+
if (haveVsInstallDir && version.Major == 15)
229239
{
230240
var installationPath = instance.Item1;
241+
installationPath = Path.GetFullPath(installationPath);
231242
installationPath = installationPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
232-
////isMatch &= installationPath.Equals(vsInstallDir, StringComparison.OrdinalIgnoreCase);
243+
isMatch &= installationPath.Equals(vsInstallDir, StringComparison.OrdinalIgnoreCase);
233244
}
234245
}
235246

0 commit comments

Comments
 (0)