@@ -72,13 +72,14 @@ public void VerifyEnvironmentVariables(ImageDescriptor imageDescriptor)
7272 {
7373 Skip . If ( IsSkippable ( imageDescriptor ) ) ;
7474
75- List < EnvironmentVariableInfo > variables = new List < EnvironmentVariableInfo > ( ) ;
75+ string vsPath = imageDescriptor . GetExpectedVsInstallationPath ( ) ;
7676
77- variables . AddRange ( RuntimeOnlyImageTests . GetEnvironmentVariables ( imageDescriptor ) ) ;
78-
79- variables . Add ( new EnvironmentVariableInfo ( "ROSLYN_COMPILER_LOCATION" ,
80- @"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\Roslyn" ) ) ;
81- variables . Add ( new EnvironmentVariableInfo ( "DOTNET_GENERATE_ASPNET_CERTIFICATE" , "false" ) ) ;
77+ List < EnvironmentVariableInfo > variables =
78+ [
79+ ..RuntimeOnlyImageTests . GetEnvironmentVariables ( imageDescriptor ) ,
80+ new EnvironmentVariableInfo ( "ROSLYN_COMPILER_LOCATION" , $@ "{ vsPath } \MSBuild\Current\Bin\Roslyn") ,
81+ new EnvironmentVariableInfo ( "DOTNET_GENERATE_ASPNET_CERTIFICATE" , "false" ) ,
82+ ] ;
8283
8384 if ( imageDescriptor . OsVariant != OsVersion . WSC_LTSC2016 &&
8485 imageDescriptor . OsVariant != OsVersion . WSC_LTSC2019 )
@@ -106,16 +107,7 @@ public void VerifyVsWhereOperability(ImageDescriptor imageDescriptor)
106107 JArray json = ( JArray ) JsonConvert . DeserializeObject ( output ) ;
107108
108109 Assert . Single ( json ) ;
109-
110- string expectedPath = imageDescriptor . OsVariant switch
111- {
112- // Visual Studio 2026/dev18 does not support Windows Server 2016.
113- // See https://learn.microsoft.com/visualstudio/releases/2026/compatibility
114- OsVersion . WSC_LTSC2016 => @"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" ,
115- _ => @"C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools" ,
116- } ;
117-
118- Assert . Equal ( expectedPath , json [ 0 ] [ "installationPath" ] ) ;
110+ Assert . Equal ( imageDescriptor . GetExpectedVsInstallationPath ( ) , json [ 0 ] [ "installationPath" ] ) ;
119111
120112 // Get build version instead of a display version or semantic version because it's easier to parse and can
121113 // also seamlessly work with preview versions.
0 commit comments