Skip to content

Commit 44e9ba2

Browse files
committed
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
1 parent 834803c commit 44e9ba2

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,16 @@ public void It_publishes_portable_apps_to_the_publish_folder_and_the_app_should_
6666
}
6767

6868
[Theory]
69+
[InlineData("netcoreapp1.1")]
6970
[InlineData("netcoreapp2.0")]
7071
[InlineData("netcoreapp3.0")]
7172
public void It_publishes_self_contained_apps_to_the_publish_folder_and_the_app_should_run(string targetFramework)
7273
{
74+
if (!EnvironmentInfo.SupportsTargetFramework(targetFramework))
75+
{
76+
return;
77+
}
78+
7379
var rid = EnvironmentInfo.GetCompatibleRid(targetFramework);
7480

7581
var helloWorldAsset = _testAssetsManager

src/Tests/Microsoft.NET.TestFramework/EnvironmentInfo.cs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public static bool SupportsTargetFramework(string targetFramework)
127127
string ubuntuVersionString = restOfRid.Split('-')[0];
128128
if (float.TryParse(ubuntuVersionString, out float ubuntuVersion))
129129
{
130-
if (ubuntuVersion > 16.04)
130+
if (ubuntuVersion > 16.04f)
131131
{
132132
if (nugetFramework.Version < new Version(2, 0, 0, 0))
133133
{
@@ -144,27 +144,29 @@ public static bool SupportsTargetFramework(string targetFramework)
144144
{
145145
string restOfRid = currentRid.Substring(ridOS.Length + 1);
146146
string osxVersionString = restOfRid.Split('-')[0];
147-
// From a string such as "10.14", get the second part, e.g. "14"
148-
string osxVersionString2 = osxVersionString.Split('.')[1];
149-
if (int.TryParse(osxVersionString2, out int osxVersion))
147+
if (float.TryParse(osxVersionString, out float osxVersion))
150148
{
151149
// .NET Core 1.1 - 10.11, 10.12
152150
// .NET Core 2.0 - 10.12+
153-
if (osxVersion <= 11)
151+
// .NET Core 2.1 - 10.12-10.15
152+
// .NET 5 <= 11.0
153+
// .NET 6 <= 12
154+
// .NET 7 <= 13
155+
if (osxVersion <= 10.11f)
154156
{
155157
if (nugetFramework.Version >= new Version(2, 0, 0, 0))
156158
{
157159
return false;
158160
}
159161
}
160-
else if (osxVersion == 12)
162+
else if (osxVersion == 10.12f)
161163
{
162164
if (nugetFramework.Version < new Version(2, 0, 0, 0))
163165
{
164166
return false;
165167
}
166168
}
167-
else if (osxVersion > 12)
169+
else if (osxVersion > 10.12f && osxVersion <= 10.15f)
168170
{
169171
// .NET Core 2.0 is out of support, and doesn't seem to work with OS X 10.14
170172
// (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)
173175
return false;
174176
}
175177
}
178+
else if (osxVersion == 11.0f)
179+
{
180+
if (nugetFramework.Version < new Version(5, 0, 0, 0))
181+
{
182+
return false;
183+
}
184+
}
185+
else if (osxVersion == 12.0f)
186+
{
187+
if (nugetFramework.Version < new Version(6, 0, 0, 0))
188+
{
189+
return false;
190+
}
191+
}
192+
else if (osxVersion > 12.0f)
193+
{
194+
if (nugetFramework.Version < new Version(7, 0, 0, 0))
195+
{
196+
return false;
197+
}
198+
}
176199
}
177200
}
178201

0 commit comments

Comments
 (0)