Skip to content

Commit 866c282

Browse files
authored
Merge pull request #29132 from dotnet-maestro-bot/merge/release/6.0.1xx-to-release/6.0.3xx
[automated] Merge branch 'release/6.0.1xx' => 'release/6.0.3xx'
2 parents 8eba9da + c04cfe3 commit 866c282

File tree

6 files changed

+224
-19
lines changed

6 files changed

+224
-19
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$RepoRoot= Resolve-Path "$PSScriptRoot/../.."
2+
3+
$TestProjects = "Microsoft.NET.Sdk.Razor.Tests", "Microsoft.NET.Sdk.BlazorWebAssembly.Tests" |
4+
ForEach-Object { Join-Path -Path "$RepoRoot/src/Tests/" -ChildPath $_ };
5+
6+
$TestProjects | ForEach-Object { dotnet test --no-build -l "console;verbosity=normal" $_ -e ASPNETCORE_TEST_BASELINES=true --filter AspNetCore=BaselineTest }

src/Tasks/Microsoft.NET.Build.Tasks/ResolveReadyToRunCompilers.cs

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,14 @@ private bool ValidateCrossgen2Support()
143143

144144
bool version5 = crossgen2PackVersion.Major < 6;
145145
bool isSupportedTarget = ExtractTargetPlatformAndArchitecture(_targetRuntimeIdentifier, out _targetPlatform, out _targetArchitecture);
146-
string targetOS = _targetPlatform switch
147-
{
148-
"linux" => "linux",
149-
"linux-musl" => "linux",
150-
"osx" => "osx",
151-
"win" => "windows",
152-
_ => null
153-
};
154146

155147
// In .NET 5 Crossgen2 supported only the following host->target compilation scenarios:
156148
// win-x64 -> win-x64
157149
// linux-x64 -> linux-x64
158150
// linux-musl-x64 -> linux-musl-x64
151+
string targetOS = null;
159152
isSupportedTarget = isSupportedTarget &&
160-
targetOS != null &&
153+
GetCrossgen2TargetOS(out targetOS) &&
161154
(!version5 || _targetRuntimeIdentifier == _hostRuntimeIdentifier) &&
162155
GetCrossgen2ComponentsPaths(version5);
163156

@@ -188,6 +181,48 @@ private bool ValidateCrossgen2Support()
188181
return true;
189182
}
190183

184+
private bool GetCrossgen2TargetOS(out string targetOS)
185+
{
186+
targetOS = null;
187+
188+
// Determine targetOS based on target rid.
189+
// Use the runtime graph to support non-portable target rids.
190+
var runtimeGraph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath);
191+
string portablePlatform = NuGetUtils.GetBestMatchingRid(
192+
runtimeGraph,
193+
_targetPlatform,
194+
new[] { "linux", "linux-musl", "osx", "win" },
195+
out _);
196+
197+
// For source-build, allow the bootstrap SDK rid to be unknown to the runtime repo graph.
198+
if (portablePlatform == null && _targetRuntimeIdentifier == _hostRuntimeIdentifier)
199+
{
200+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
201+
{
202+
portablePlatform = "linux";
203+
}
204+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
205+
{
206+
portablePlatform = "win";
207+
}
208+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
209+
{
210+
portablePlatform = "osx";
211+
}
212+
}
213+
214+
targetOS = portablePlatform switch
215+
{
216+
"linux" => "linux",
217+
"linux-musl" => "linux",
218+
"osx" => "osx",
219+
"win" => "windows",
220+
_ => null
221+
};
222+
223+
return targetOS != null;
224+
}
225+
191226
private ITaskItem GetNETCoreAppRuntimePack()
192227
{
193228
return GetNETCoreAppPack(RuntimePacks, MetadataKeys.FrameworkName);

src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Xunit.Abstractions;
1818
using Microsoft.NET.TestFramework.ProjectConstruction;
1919
using Newtonsoft.Json.Linq;
20+
using NuGet.Versioning;
2021

2122
namespace Microsoft.NET.Build.Tests
2223
{
@@ -188,7 +189,7 @@ public void It_creates_a_documentation_file(string language)
188189
[InlineData("vb", false)]
189190
public void It_allows_us_to_override_the_documentation_file_name(string language, bool setGenerateDocumentationFileProperty)
190191
{
191-
var testAsset = CreateDocumentationFileLibraryAsset(setGenerateDocumentationFileProperty ? (bool?)true : null, "TestLibDoc.xml", language, "OverrideDocFileName");
192+
var testAsset = CreateDocumentationFileLibraryAsset(setGenerateDocumentationFileProperty ? (bool?)true : null, "TestLibDoc.xml", language, "OverrideDocFileName");
192193

193194
var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, "TestLibrary");
194195

@@ -217,7 +218,8 @@ public void It_allows_us_to_override_the_documentation_file_name(string language
217218
};
218219

219220
// vb uses DocumentationFile relative to the IntermediateOutputPath
220-
if (language != "vb") {
221+
if (language != "vb")
222+
{
221223
expectedProjectDirectoryFiles.Add("TestLibDoc.xml");
222224
}
223225

@@ -391,6 +393,11 @@ public void It_implicitly_defines_compilation_constants_for_the_target_framework
391393
[InlineData(new[] { "11.11", "12.12", "13.13" }, "android", "12.12", new[] { "ANDROID", "ANDROID12_12", "ANDROID11_11_OR_GREATER", "ANDROID12_12_OR_GREATER" })]
392394
public void It_implicitly_defines_compilation_constants_for_the_target_platform(string[] sdkSupportedTargetPlatformVersion, string targetPlatformIdentifier, string targetPlatformVersion, string[] expectedDefines)
393395
{
396+
// Skip Test if SDK is < 7.0.200
397+
var sdkVersion = SemanticVersion.Parse(TestContext.Current.ToolsetUnderTest.SdkVersion);
398+
if (new SemanticVersion(sdkVersion.Major, sdkVersion.Minor, sdkVersion.Patch) < new SemanticVersion(7, 0, 200))
399+
return; // Fixed by https://github.com/dotnet/sdk/pull/29009
400+
394401
var targetFramework = "net5.0";
395402
var testAsset = _testAssetsManager
396403
.CopyTestAsset("AppWithLibrary", "ImplicitFrameworkConstants", targetFramework, identifier: expectedDefines.GetHashCode().ToString())
@@ -424,7 +431,7 @@ public void It_implicitly_defines_compilation_constants_for_the_target_platform(
424431
});
425432

426433
AssertDefinedConstantsOutput(testAsset, targetFramework,
427-
new[] { "NETCOREAPP", "NETCOREAPP1_0_OR_GREATER", "NETCOREAPP1_1_OR_GREATER", "NETCOREAPP2_0_OR_GREATER", "NETCOREAPP2_1_OR_GREATER", "NETCOREAPP2_2_OR_GREATER", "NETCOREAPP3_0_OR_GREATER", "NETCOREAPP3_1_OR_GREATER", "NET", "NET5_0", "NET5_0_OR_GREATER" }
434+
new[] { "NETCOREAPP", "NETCOREAPP1_0_OR_GREATER", "NETCOREAPP1_1_OR_GREATER", "NETCOREAPP2_0_OR_GREATER", "NETCOREAPP2_1_OR_GREATER", "NETCOREAPP2_2_OR_GREATER", "NETCOREAPP3_0_OR_GREATER", "NETCOREAPP3_1_OR_GREATER", "NET", "NET5_0", "NET5_0_OR_GREATER" }
428435
.Concat(expectedDefines).ToArray());
429436
}
430437

@@ -920,7 +927,7 @@ public void It_can_build_with_dynamic_loading_enabled(string targetFramework, st
920927
testProject.AdditionalProperties["CopyLocalLockFileAssemblies"] = copyLocal.ToString().ToLower();
921928
}
922929

923-
var identifier = targetFramework + shouldSetRollForward + shouldCopyLocal + (rollForwardValue == null? "Null" : rollForwardValue);
930+
var identifier = targetFramework + shouldSetRollForward + shouldCopyLocal + (rollForwardValue == null ? "Null" : rollForwardValue);
924931
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: identifier);
925932

926933
var buildCommand = new BuildCommand(testAsset);
@@ -949,7 +956,7 @@ public void It_can_build_with_dynamic_loading_enabled(string targetFramework, st
949956
string runtimeConfigFile = Path.Combine(outputDirectory.FullName, runtimeConfigName);
950957
string runtimeConfigContents = File.ReadAllText(runtimeConfigFile);
951958
JObject runtimeConfig = JObject.Parse(runtimeConfigContents);
952-
JToken rollForward= runtimeConfig["runtimeOptions"]["rollForward"];
959+
JToken rollForward = runtimeConfig["runtimeOptions"]["rollForward"];
953960
if (shouldSetRollForward)
954961
{
955962
rollForward.Value<string>().Should().Be(string.IsNullOrEmpty(rollForwardValue) ? "LatestMinor" : rollForwardValue);
@@ -990,7 +997,7 @@ public class ProjectNameWithSpacesClass
990997
}");
991998
string projectFolder = Path.Combine(testAsset.Path, testProject.Name);
992999

993-
var buildCommand = new BuildCommand(testAsset, $"{ testProject.Name}");
1000+
var buildCommand = new BuildCommand(testAsset, $"{testProject.Name}");
9941001
buildCommand
9951002
.Execute()
9961003
.Should()

src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
using System.IO;
1313
using System.Linq;
1414
using System;
15+
using NuGet.Versioning;
1516

1617
namespace Microsoft.NET.Build.Tests
1718
{
1819
public class GivenThatWeWantToBuildAWindowsDesktopProject : SdkTest
1920
{
2021
public GivenThatWeWantToBuildAWindowsDesktopProject(ITestOutputHelper log) : base(log)
21-
{}
22+
{ }
2223

2324
[WindowsOnlyRequiresMSBuildVersionTheory("16.7.0-preview-20310-07")]
2425
[InlineData("UseWindowsForms")]
@@ -197,6 +198,11 @@ public void It_fails_if_windows_target_platform_version_is_invalid()
197198
[InlineData(false)]
198199
public void It_succeeds_if_windows_target_platform_version_does_not_have_trailing_zeros(bool setInTargetframework)
199200
{
201+
// Skip Test if SDK is < 7.0.200
202+
var sdkVersion = SemanticVersion.Parse(TestContext.Current.ToolsetUnderTest.SdkVersion);
203+
if (new SemanticVersion(sdkVersion.Major, sdkVersion.Minor, sdkVersion.Patch) < new SemanticVersion(7, 0, 200))
204+
return; // Fixed by https://github.com/dotnet/sdk/pull/29009
205+
200206
var testProject = new TestProject()
201207
{
202208
Name = "ValidWindowsVersion",
@@ -403,7 +409,7 @@ public void ItUsesCorrectWindowsSdkPackVersion(string targetFramework, bool? use
403409

404410
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework + useWindowsSDKPreview + windowsSdkPackageVersion);
405411

406-
string referencedWindowsSdkVersion = GetReferencedWindowsSdkVersion(testAsset);
412+
string referencedWindowsSdkVersion = GetReferencedWindowsSdkVersion(testAsset);
407413

408414
// The patch version of the Windows SDK Ref pack will change over time, so we use a '*' in the expected version to indicate that and replace it with
409415
// the 4th part of the version number of the resolved package.

src/Tests/Microsoft.NET.Build.Tests/WorkloadTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Microsoft.NET.TestFramework.Assertions;
1515
using Microsoft.NET.TestFramework.Commands;
1616
using Microsoft.NET.TestFramework.ProjectConstruction;
17+
using NuGet.Versioning;
1718
using Xunit;
1819
using Xunit.Abstractions;
1920

@@ -278,6 +279,11 @@ public void It_should_get_suggested_workload_by_GetRequiredWorkloads_target()
278279
[InlineData("net6.0", "net6.0", "macos")]
279280
public void Given_multi_target_It_should_get_suggested_workload_by_GetRequiredWorkloads_target(string mainTfm, string referencingTfm, string expected)
280281
{
282+
// Skip Test if SDK is < 6.0.400
283+
var sdkVersion = SemanticVersion.Parse(TestContext.Current.ToolsetUnderTest.SdkVersion);
284+
if (new SemanticVersion(sdkVersion.Major, sdkVersion.Minor, sdkVersion.Patch) < new SemanticVersion(6, 0, 400))
285+
return; // MAUI was removed from earlier versions of the SDK
286+
281287
var mainProject = new TestProject()
282288
{
283289
Name = "MainProject",

0 commit comments

Comments
 (0)