Skip to content

Commit 892e618

Browse files
authored
[release/9.0.1xx] Add .NET 6.0 to End-of-Life frameworks list to generate NETSDK1138 warnings (#49822)
2 parents c89e2c9 + 0924112 commit 892e618

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.EolTargetFrameworks.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Copyright (c) .NET Foundation. All rights reserved.
2121
receive servicing updates and security fixes.
2222
-->
2323
<ItemGroup>
24-
<_EolNetCoreTargetFrameworkVersions Include="1.0;1.1;2.0;2.1;2.2;3.0;3.1;5.0;7.0" />
24+
<_EolNetCoreTargetFrameworkVersions Include="1.0;1.1;2.0;2.1;2.2;3.0;3.1;5.0;6.0;7.0" />
2525
</ItemGroup>
2626
<PropertyGroup>
27-
<_MinimumNonEolSupportedNetCoreTargetFramework>net6.0</_MinimumNonEolSupportedNetCoreTargetFramework>
27+
<_MinimumNonEolSupportedNetCoreTargetFramework>net8.0</_MinimumNonEolSupportedNetCoreTargetFramework>
2828
</PropertyGroup>
2929

3030
<Target Name="_CheckForEolTargetFrameworks" AfterTargets="_CheckForUnsupportedNETCoreVersion"

test/Microsoft.NET.Build.Tests/GivenThatWeWantToTargetEolFrameworks.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public GivenThatWeWantToTargetEolFrameworks(ITestOutputHelper log) : base(log)
1515
[InlineData("netcoreapp3.0")]
1616
[InlineData("netcoreapp3.1")]
1717
[InlineData("net5.0")]
18+
[InlineData("net6.0")]
1819
[InlineData("net7.0")]
1920
public void It_warns_that_framework_is_out_of_support(string targetFrameworks)
2021
{

test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,8 @@ public void PublishSingleFile_fails_for_unsupported_target_framework(string targ
731731
[InlineData("net6.0", false)]
732732
[InlineData("netstandard2.0;net5.0", true)] // None of these TFMs are supported for single-file
733733
[InlineData("netstandard2.0;net6.0", false)] // Net6.0 is the min TFM supported for single-file and targeting.
734-
[InlineData("netstandard2.0;net8.0", true)] // Net8.0 is supported for single-file, but leaves a "gap" for the supported net6./net7.0 TFMs.
734+
[InlineData("netstandard2.0;net8.0", false)] // Net8.0 is supported for single-file
735+
[InlineData("netstandard2.0;net9.0", true)] // Net9.0 is supported for single-file, but leaves a "gap" for the supported net6./net7.0 TFMs.
735736
[InlineData("alias-ns2", true)]
736737
[InlineData("alias-n6", false)]
737738
[InlineData("alias-n6;alias-n8", false)] // If all TFMs are supported, there's no warning even though the project uses aliases.
@@ -744,18 +745,19 @@ public void EnableSingleFile_warns_when_expected_for_not_correctly_multitargeted
744745
TargetFrameworks = targetFrameworks
745746
};
746747
testProject.AdditionalProperties["EnableSingleFileAnalyzer"] = "true";
748+
testProject.AdditionalProperties["CheckEolTargetFramework"] = "false"; // Silence warning about targeting EOL TFMs
747749
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFrameworks)
748750
.WithProjectChanges(AddTargetFrameworkAliases);
749-
751+
750752
var buildCommand = new BuildCommand(testAsset);
751-
var resultAssertion = buildCommand.Execute("/bl:my.binlog")
753+
var resultAssertion = buildCommand.Execute("/p:CheckEolTargetFramework=false")
752754
.Should().Pass();
753755
if (shouldWarn) {
754756
// Note: can't check for Strings.EnableSingleFileAnalyzerUnsupported because each line of
755757
// the message gets prefixed with a file path by MSBuild.
756758
resultAssertion
757759
.And.HaveStdOutContaining($"warning NETSDK1211")
758-
.And.HaveStdOutContaining($"<EnableSingleFileAnalyzer Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))\">true</EnableSingleFileAnalyzer>");
760+
.And.HaveStdOutContaining($"<EnableSingleFileAnalyzer Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))\">true</EnableSingleFileAnalyzer>");
759761
} else {
760762
resultAssertion.And.NotHaveStdOutContaining($"warning");
761763
}

test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,8 @@ public void PublishAot_fails_for_unsupported_target_framework(string targetFrame
630630
[InlineData("net7.0", false)]
631631
[InlineData("netstandard2.0;net5.0", true)] // None of these TFMs are supported for AOT
632632
[InlineData("netstandard2.0;net7.0", false)] // Net7.0 is the min TFM supported for AOT and targeting.
633-
[InlineData("netstandard2.0;net8.0", true)] // Net8.0 is supported for AOT, but leaves a "gap" for the supported net7.0 TFMs.
633+
[InlineData("netstandard2.0;net8.0", false)] // net8.0 is supported for AOT and targeting.
634+
[InlineData("netstandard2.0;net9.0", true)] // Net9.0 is supported for AOT, but leaves a "gap" for the supported net8.0 TFMs.
634635
[InlineData("alias-ns2", true)]
635636
[InlineData("alias-n6", true)]
636637
[InlineData("alias-n7", false)]
@@ -646,18 +647,19 @@ public void IsAotCompatible_warns_when_expected_for_not_correctly_multitarget_li
646647
TargetFrameworks = targetFrameworks
647648
};
648649
testProject.AdditionalProperties["IsAotCompatible"] = "true";
650+
testProject.AdditionalProperties["CheckEolTargetFramework"] = "false"; // Silence warning about targeting EOL TFMs
649651
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFrameworks)
650652
.WithProjectChanges(AddTargetFrameworkAliases);
651653

652654
var buildCommand = new BuildCommand(testAsset);
653-
var resultAssertion = buildCommand.Execute()
655+
var resultAssertion = buildCommand.Execute("/p:CheckEolTargetFramework=false")
654656
.Should().Pass();
655657
if (shouldWarn) {
656658
resultAssertion
657659
// Note: can't check for Strings.IsAotCompatibleUnsupported because each line of
658660
// the message gets prefixed with a file path by MSBuild.
659661
.And.HaveStdOutContaining($"warning NETSDK1210")
660-
.And.HaveStdOutContaining($"<IsAotCompatible Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))\">true</IsAotCompatible>");
662+
.And.HaveStdOutContaining($"<IsAotCompatible Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))\">true</IsAotCompatible>");
661663
} else {
662664
resultAssertion.And.NotHaveStdOutContaining($"warning");
663665
}

test/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ public void PublishTrimmed_fails_for_unsupported_target_framework(string targetF
183183
[InlineData("net5.0", true)]
184184
[InlineData("net6.0", false)]
185185
[InlineData("netstandard2.0;net5.0", true)] // None of these TFMs are supported for trimming
186-
[InlineData("netstandard2.0;net6.0", false)] // Net6.0 is the min TFM supported for trimming and targeting.
187-
[InlineData("netstandard2.0;net8.0", true)] // Net8.0 is supported for trimming, but leaves a "gap" for the supported net6.0/net7.0 TFMs.
186+
[InlineData("netstandard2.0;net6.0", false)] // net6.0 is the min TFM supported for trimming and targeting.
187+
[InlineData("netstandard2.0;net8.0", false)] // Net8.0 is supported for trimming and targeting.
188+
[InlineData("netstandard2.0;net9.0", true)] // Net8.0 is supported for trimming, but leaves a "gap" for the supported net6.0/net7.0 TFMs.
188189
[InlineData("alias-ns2", true)]
189190
[InlineData("alias-n6", false)]
190191
[InlineData("alias-n6;alias-n8", false)] // If all TFMs are supported, there's no warning even though the project uses aliases.
@@ -196,19 +197,19 @@ public void IsTrimmable_warns_when_expected_for_not_correctly_multitargeted_libr
196197

197198
var testProject = CreateTestProjectForILLinkTesting(targetFrameworks, projectName);
198199
testProject.AdditionalProperties["IsTrimmable"] = "true";
199-
testProject.AdditionalProperties["NoWarn"] = "NETSDK1138"; // Silence warning about targeting EOL TFMs
200+
testProject.AdditionalProperties["CheckEolTargetFramework"] = "false"; // Silence warning about targeting EOL TFMs
200201
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFrameworks)
201202
.WithProjectChanges(AddTargetFrameworkAliases);
202203

203204
var buildCommand = new BuildCommand(testAsset);
204-
var resultAssertion = buildCommand.Execute()
205+
var resultAssertion = buildCommand.Execute("/p:CheckEolTargetFramework=false")
205206
.Should().Pass();
206207
if (shouldWarn) {
207208
resultAssertion
208209
// Note: can't check for Strings.IsTrimmableUnsupported because each line of
209210
// the message gets prefixed with a file path by MSBuild.
210211
.And.HaveStdOutContaining($"warning NETSDK1212")
211-
.And.HaveStdOutContaining($"<IsTrimmable Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))\">true</IsTrimmable>");
212+
.And.HaveStdOutContaining($"<IsTrimmable Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))\">true</IsTrimmable>");
212213
} else {
213214
resultAssertion.And.NotHaveStdOutContaining($"warning");
214215
}

test/dotnet-new.Tests/CommonTemplatesTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ public async Task FeaturesSupport(
386386
string finalProjectName = Path.Combine(projectDir, $"{projName}.{extension}");
387387

388388
Dictionary<string, string> environmentUnderTest = new() { ["DOTNET_NOLOGO"] = false.ToString() };
389+
environmentUnderTest["CheckEolTargetFramework"] = false.ToString();
389390
TestContext.Current.AddTestEnvironmentVariables(environmentUnderTest);
390391

391392
TemplateVerifierOptions options = new TemplateVerifierOptions(templateName: name)
@@ -420,7 +421,7 @@ public async Task FeaturesSupport(
420421
{
421422
new DotnetBuildCommand(_log, "MyProject")
422423
.WithWorkingDirectory(workingDir)
423-
.Execute()
424+
.Execute("/p:CheckEolTargetFramework=false")
424425
.Should()
425426
.Pass()
426427
.And.NotHaveStdErr();

0 commit comments

Comments
 (0)