From 44e9ba27ec2267c2733b86602aa8c467a246409c Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Mon, 13 Feb 2023 15:25:37 -0800 Subject: [PATCH] Revert #29916 Port fix for environmentinfo. Realize that the fix won't work for 11.0 Modify the fix to work better following the idea of the other fix that almost worked --- ...enThatWeWantToPublishAHelloWorldProject.cs | 6 +++ .../EnvironmentInfo.cs | 37 +++++++++++++++---- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs index 34125550d3fb..f83be52124d7 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs @@ -66,10 +66,16 @@ public void It_publishes_portable_apps_to_the_publish_folder_and_the_app_should_ } [Theory] + [InlineData("netcoreapp1.1")] [InlineData("netcoreapp2.0")] [InlineData("netcoreapp3.0")] public void It_publishes_self_contained_apps_to_the_publish_folder_and_the_app_should_run(string targetFramework) { + if (!EnvironmentInfo.SupportsTargetFramework(targetFramework)) + { + return; + } + var rid = EnvironmentInfo.GetCompatibleRid(targetFramework); var helloWorldAsset = _testAssetsManager diff --git a/src/Tests/Microsoft.NET.TestFramework/EnvironmentInfo.cs b/src/Tests/Microsoft.NET.TestFramework/EnvironmentInfo.cs index cf0af4fdb79e..0ae92a60eb92 100644 --- a/src/Tests/Microsoft.NET.TestFramework/EnvironmentInfo.cs +++ b/src/Tests/Microsoft.NET.TestFramework/EnvironmentInfo.cs @@ -127,7 +127,7 @@ public static bool SupportsTargetFramework(string targetFramework) string ubuntuVersionString = restOfRid.Split('-')[0]; if (float.TryParse(ubuntuVersionString, out float ubuntuVersion)) { - if (ubuntuVersion > 16.04) + if (ubuntuVersion > 16.04f) { if (nugetFramework.Version < new Version(2, 0, 0, 0)) { @@ -144,27 +144,29 @@ public static bool SupportsTargetFramework(string targetFramework) { string restOfRid = currentRid.Substring(ridOS.Length + 1); string osxVersionString = restOfRid.Split('-')[0]; - // From a string such as "10.14", get the second part, e.g. "14" - string osxVersionString2 = osxVersionString.Split('.')[1]; - if (int.TryParse(osxVersionString2, out int osxVersion)) + if (float.TryParse(osxVersionString, out float osxVersion)) { // .NET Core 1.1 - 10.11, 10.12 // .NET Core 2.0 - 10.12+ - if (osxVersion <= 11) + // .NET Core 2.1 - 10.12-10.15 + // .NET 5 <= 11.0 + // .NET 6 <= 12 + // .NET 7 <= 13 + if (osxVersion <= 10.11f) { if (nugetFramework.Version >= new Version(2, 0, 0, 0)) { return false; } } - else if (osxVersion == 12) + else if (osxVersion == 10.12f) { if (nugetFramework.Version < new Version(2, 0, 0, 0)) { return false; } } - else if (osxVersion > 12) + else if (osxVersion > 10.12f && osxVersion <= 10.15f) { // .NET Core 2.0 is out of support, and doesn't seem to work with OS X 10.14 // (it finds no assets for the RID), even though the support page says "10.12+" @@ -173,6 +175,27 @@ public static bool SupportsTargetFramework(string targetFramework) return false; } } + else if (osxVersion == 11.0f) + { + if (nugetFramework.Version < new Version(5, 0, 0, 0)) + { + return false; + } + } + else if (osxVersion == 12.0f) + { + if (nugetFramework.Version < new Version(6, 0, 0, 0)) + { + return false; + } + } + else if (osxVersion > 12.0f) + { + if (nugetFramework.Version < new Version(7, 0, 0, 0)) + { + return false; + } + } } }