Skip to content

Commit 11b8675

Browse files
committed
Fix ROSLYN_COMPILER_LOCATION test
1 parent bc98723 commit 11b8675

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

tests/Microsoft.DotNet.Framework.Docker.Tests/ImageDescriptor.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ public class ImageDescriptor
88
{
99
public string Version { get; set; }
1010
public string OsVariant { get; set; }
11-
12-
public string GetDockerfilePath(string imageType) =>
13-
$"src/{imageType}/{Version}/{OsVariant}";
14-
1511
public string SdkVersion { get; set; }
1612
}
1713
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace Microsoft.DotNet.Framework.Docker.Tests;
6+
7+
internal static class ImageDescriptorExtensions
8+
{
9+
/// <summary>
10+
/// The path to the Dockerfile that was used to build the image.
11+
/// </summary>
12+
/// <param name="imageType">"sdk", "runtime", "aspnet", or "wcf".</param>
13+
public static string GetDockerfilePath(this ImageDescriptor imageDescriptor, string imageType) =>
14+
$"src/{imageType}/{imageDescriptor.Version}/{imageDescriptor.OsVariant}";
15+
16+
/// <summary>
17+
/// The expected Visual Studio installation path inside the image.
18+
/// </summary>
19+
public static string GetExpectedVsInstallationPath(this ImageDescriptor imageDescriptor) =>
20+
imageDescriptor.OsVariant switch
21+
{
22+
// Visual Studio 2026/dev18 does not support Windows Server 2016.
23+
// See https://learn.microsoft.com/visualstudio/releases/2026/compatibility
24+
OsVersion.WSC_LTSC2016 => @"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools",
25+
_ => @"C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools",
26+
};
27+
}

tests/Microsoft.DotNet.Framework.Docker.Tests/SdkOnlyImageTests.cs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)