Skip to content

Commit

Permalink
Merge in 'release/6.0.3xx' changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnet-bot committed Nov 30, 2022
2 parents 7b79c40 + 866c282 commit 91215e5
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 19 deletions.
6 changes: 6 additions & 0 deletions src/RazorSdk/update-test-baselines.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$RepoRoot= Resolve-Path "$PSScriptRoot/../.."

$TestProjects = "Microsoft.NET.Sdk.Razor.Tests", "Microsoft.NET.Sdk.BlazorWebAssembly.Tests" |
ForEach-Object { Join-Path -Path "$RepoRoot/src/Tests/" -ChildPath $_ };

$TestProjects | ForEach-Object { dotnet test --no-build -l "console;verbosity=normal" $_ -e ASPNETCORE_TEST_BASELINES=true --filter AspNetCore=BaselineTest }
53 changes: 44 additions & 9 deletions src/Tasks/Microsoft.NET.Build.Tasks/ResolveReadyToRunCompilers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,14 @@ private bool ValidateCrossgen2Support()

bool version5 = crossgen2PackVersion.Major < 6;
bool isSupportedTarget = ExtractTargetPlatformAndArchitecture(_targetRuntimeIdentifier, out _targetPlatform, out _targetArchitecture);
string targetOS = _targetPlatform switch
{
"linux" => "linux",
"linux-musl" => "linux",
"osx" => "osx",
"win" => "windows",
_ => null
};

// In .NET 5 Crossgen2 supported only the following host->target compilation scenarios:
// win-x64 -> win-x64
// linux-x64 -> linux-x64
// linux-musl-x64 -> linux-musl-x64
string targetOS = null;
isSupportedTarget = isSupportedTarget &&
targetOS != null &&
GetCrossgen2TargetOS(out targetOS) &&
(!version5 || _targetRuntimeIdentifier == _hostRuntimeIdentifier) &&
GetCrossgen2ComponentsPaths(version5);

Expand Down Expand Up @@ -188,6 +181,48 @@ private bool ValidateCrossgen2Support()
return true;
}

private bool GetCrossgen2TargetOS(out string targetOS)
{
targetOS = null;

// Determine targetOS based on target rid.
// Use the runtime graph to support non-portable target rids.
var runtimeGraph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath);
string portablePlatform = NuGetUtils.GetBestMatchingRid(
runtimeGraph,
_targetPlatform,
new[] { "linux", "linux-musl", "osx", "win" },
out _);

// For source-build, allow the bootstrap SDK rid to be unknown to the runtime repo graph.
if (portablePlatform == null && _targetRuntimeIdentifier == _hostRuntimeIdentifier)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
portablePlatform = "linux";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
portablePlatform = "win";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
portablePlatform = "osx";
}
}

targetOS = portablePlatform switch
{
"linux" => "linux",
"linux-musl" => "linux",
"osx" => "osx",
"win" => "windows",
_ => null
};

return targetOS != null;
}

private ITaskItem GetNETCoreAppRuntimePack()
{
return GetNETCoreAppPack(RuntimePacks, MetadataKeys.FrameworkName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Xunit.Abstractions;
using Microsoft.NET.TestFramework.ProjectConstruction;
using Newtonsoft.Json.Linq;
using NuGet.Versioning;

namespace Microsoft.NET.Build.Tests
{
Expand Down Expand Up @@ -188,7 +189,7 @@ public void It_creates_a_documentation_file(string language)
[InlineData("vb", false)]
public void It_allows_us_to_override_the_documentation_file_name(string language, bool setGenerateDocumentationFileProperty)
{
var testAsset = CreateDocumentationFileLibraryAsset(setGenerateDocumentationFileProperty ? (bool?)true : null, "TestLibDoc.xml", language, "OverrideDocFileName");
var testAsset = CreateDocumentationFileLibraryAsset(setGenerateDocumentationFileProperty ? (bool?)true : null, "TestLibDoc.xml", language, "OverrideDocFileName");

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

Expand Down Expand Up @@ -217,7 +218,8 @@ public void It_allows_us_to_override_the_documentation_file_name(string language
};

// vb uses DocumentationFile relative to the IntermediateOutputPath
if (language != "vb") {
if (language != "vb")
{
expectedProjectDirectoryFiles.Add("TestLibDoc.xml");
}

Expand Down Expand Up @@ -391,6 +393,11 @@ public void It_implicitly_defines_compilation_constants_for_the_target_framework
[InlineData(new[] { "11.11", "12.12", "13.13" }, "android", "12.12", new[] { "ANDROID", "ANDROID12_12", "ANDROID11_11_OR_GREATER", "ANDROID12_12_OR_GREATER" })]
public void It_implicitly_defines_compilation_constants_for_the_target_platform(string[] sdkSupportedTargetPlatformVersion, string targetPlatformIdentifier, string targetPlatformVersion, string[] expectedDefines)
{
// Skip Test if SDK is < 7.0.200
var sdkVersion = SemanticVersion.Parse(TestContext.Current.ToolsetUnderTest.SdkVersion);
if (new SemanticVersion(sdkVersion.Major, sdkVersion.Minor, sdkVersion.Patch) < new SemanticVersion(7, 0, 200))
return; // Fixed by https://github.com/dotnet/sdk/pull/29009

var targetFramework = "net5.0";
var testAsset = _testAssetsManager
.CopyTestAsset("AppWithLibrary", "ImplicitFrameworkConstants", targetFramework, identifier: expectedDefines.GetHashCode().ToString())
Expand Down Expand Up @@ -424,7 +431,7 @@ public void It_implicitly_defines_compilation_constants_for_the_target_platform(
});

AssertDefinedConstantsOutput(testAsset, targetFramework,
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" }
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" }
.Concat(expectedDefines).ToArray());
}

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

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

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

var buildCommand = new BuildCommand(testAsset, $"{ testProject.Name}");
var buildCommand = new BuildCommand(testAsset, $"{testProject.Name}");
buildCommand
.Execute()
.Should()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
using System.IO;
using System.Linq;
using System;
using NuGet.Versioning;

namespace Microsoft.NET.Build.Tests
{
public class GivenThatWeWantToBuildAWindowsDesktopProject : SdkTest
{
public GivenThatWeWantToBuildAWindowsDesktopProject(ITestOutputHelper log) : base(log)
{}
{ }

[WindowsOnlyRequiresMSBuildVersionTheory("16.7.0-preview-20310-07")]
[InlineData("UseWindowsForms")]
Expand Down Expand Up @@ -197,6 +198,11 @@ public void It_fails_if_windows_target_platform_version_is_invalid()
[InlineData(false)]
public void It_succeeds_if_windows_target_platform_version_does_not_have_trailing_zeros(bool setInTargetframework)
{
// Skip Test if SDK is < 7.0.200
var sdkVersion = SemanticVersion.Parse(TestContext.Current.ToolsetUnderTest.SdkVersion);
if (new SemanticVersion(sdkVersion.Major, sdkVersion.Minor, sdkVersion.Patch) < new SemanticVersion(7, 0, 200))
return; // Fixed by https://github.com/dotnet/sdk/pull/29009

var testProject = new TestProject()
{
Name = "ValidWindowsVersion",
Expand Down Expand Up @@ -403,7 +409,7 @@ public void ItUsesCorrectWindowsSdkPackVersion(string targetFramework, bool? use

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

string referencedWindowsSdkVersion = GetReferencedWindowsSdkVersion(testAsset);
string referencedWindowsSdkVersion = GetReferencedWindowsSdkVersion(testAsset);

// 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
// the 4th part of the version number of the resolved package.
Expand Down
6 changes: 6 additions & 0 deletions src/Tests/Microsoft.NET.Build.Tests/WorkloadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.NET.TestFramework.Assertions;
using Microsoft.NET.TestFramework.Commands;
using Microsoft.NET.TestFramework.ProjectConstruction;
using NuGet.Versioning;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -278,6 +279,11 @@ public void It_should_get_suggested_workload_by_GetRequiredWorkloads_target()
[InlineData("net6.0", "net6.0", "macos")]
public void Given_multi_target_It_should_get_suggested_workload_by_GetRequiredWorkloads_target(string mainTfm, string referencingTfm, string expected)
{
// Skip Test if SDK is < 6.0.400
var sdkVersion = SemanticVersion.Parse(TestContext.Current.ToolsetUnderTest.SdkVersion);
if (new SemanticVersion(sdkVersion.Major, sdkVersion.Minor, sdkVersion.Patch) < new SemanticVersion(6, 0, 400))
return; // MAUI was removed from earlier versions of the SDK

var mainProject = new TestProject()
{
Name = "MainProject",
Expand Down
Loading

0 comments on commit 91215e5

Please sign in to comment.