Skip to content

Commit 273969a

Browse files
CopilotmarcpopMSFT
andauthored
Add .NET 6.0 to End-of-Life frameworks list to generate NETSDK1138 warnings (#49533)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com> Co-authored-by: Marc Paine <marcpop@microsoft.com>
1 parent e0034a5 commit 273969a

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
@@ -17,6 +17,7 @@ public GivenThatWeWantToTargetEolFrameworks(ITestOutputHelper log) : base(log)
1717
[InlineData("netcoreapp3.0")]
1818
[InlineData("netcoreapp3.1")]
1919
[InlineData("net5.0")]
20+
[InlineData("net6.0")]
2021
[InlineData("net7.0")]
2122
public void It_warns_that_framework_is_out_of_support(string targetFrameworks)
2223
{

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,8 @@ public void PublishSingleFile_fails_for_unsupported_target_framework(string targ
736736
[InlineData("net6.0", false)]
737737
[InlineData("netstandard2.0;net5.0", true)] // None of these TFMs are supported for single-file
738738
[InlineData("netstandard2.0;net6.0", false)] // Net6.0 is the min TFM supported for single-file and targeting.
739-
[InlineData("netstandard2.0;net8.0", true)] // Net8.0 is supported for single-file, but leaves a "gap" for the supported net6./net7.0 TFMs.
739+
[InlineData("netstandard2.0;net8.0", false)] // Net8.0 is supported for single-file
740+
[InlineData("netstandard2.0;net9.0", true)] // Net9.0 is supported for single-file, but leaves a "gap" for the supported net6./net7.0 TFMs.
740741
[InlineData("alias-ns2", true)]
741742
[InlineData("alias-n6", false)]
742743
[InlineData("alias-n6;alias-n8", false)] // If all TFMs are supported, there's no warning even though the project uses aliases.
@@ -749,18 +750,19 @@ public void EnableSingleFile_warns_when_expected_for_not_correctly_multitargeted
749750
TargetFrameworks = targetFrameworks
750751
};
751752
testProject.AdditionalProperties["EnableSingleFileAnalyzer"] = "true";
753+
testProject.AdditionalProperties["CheckEolTargetFramework"] = "false"; // Silence warning about targeting EOL TFMs
752754
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFrameworks)
753755
.WithProjectChanges(AddTargetFrameworkAliases);
754-
756+
755757
var buildCommand = new BuildCommand(testAsset);
756-
var resultAssertion = buildCommand.Execute("/bl:my.binlog")
758+
var resultAssertion = buildCommand.Execute("/p:CheckEolTargetFramework=false")
757759
.Should().Pass();
758760
if (shouldWarn) {
759761
// Note: can't check for Strings.EnableSingleFileAnalyzerUnsupported because each line of
760762
// the message gets prefixed with a file path by MSBuild.
761763
resultAssertion
762764
.And.HaveStdOutContaining($"warning NETSDK1211")
763-
.And.HaveStdOutContaining($"<EnableSingleFileAnalyzer Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))\">true</EnableSingleFileAnalyzer>");
765+
.And.HaveStdOutContaining($"<EnableSingleFileAnalyzer Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))\">true</EnableSingleFileAnalyzer>");
764766
} else {
765767
resultAssertion.And.NotHaveStdOutContaining($"warning");
766768
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,8 @@ public void PublishAot_fails_for_unsupported_target_framework(string targetFrame
644644
[InlineData("net7.0", false)]
645645
[InlineData("netstandard2.0;net5.0", true)] // None of these TFMs are supported for AOT
646646
[InlineData("netstandard2.0;net7.0", false)] // Net7.0 is the min TFM supported for AOT and targeting.
647-
[InlineData("netstandard2.0;net8.0", true)] // Net8.0 is supported for AOT, but leaves a "gap" for the supported net7.0 TFMs.
647+
[InlineData("netstandard2.0;net8.0", false)] // net8.0 is supported for AOT and targeting.
648+
[InlineData("netstandard2.0;net9.0", true)] // Net9.0 is supported for AOT, but leaves a "gap" for the supported net8.0 TFMs.
648649
[InlineData("alias-ns2", true)]
649650
[InlineData("alias-n6", true)]
650651
[InlineData("alias-n7", false)]
@@ -660,18 +661,19 @@ public void IsAotCompatible_warns_when_expected_for_not_correctly_multitarget_li
660661
TargetFrameworks = targetFrameworks
661662
};
662663
testProject.AdditionalProperties["IsAotCompatible"] = "true";
664+
testProject.AdditionalProperties["CheckEolTargetFramework"] = "false"; // Silence warning about targeting EOL TFMs
663665
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFrameworks)
664666
.WithProjectChanges(AddTargetFrameworkAliases);
665667

666668
var buildCommand = new BuildCommand(testAsset);
667-
var resultAssertion = buildCommand.Execute()
669+
var resultAssertion = buildCommand.Execute("/p:CheckEolTargetFramework=false")
668670
.Should().Pass();
669671
if (shouldWarn) {
670672
resultAssertion
671673
// Note: can't check for Strings.IsAotCompatibleUnsupported because each line of
672674
// the message gets prefixed with a file path by MSBuild.
673675
.And.HaveStdOutContaining($"warning NETSDK1210")
674-
.And.HaveStdOutContaining($"<IsAotCompatible Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))\">true</IsAotCompatible>");
676+
.And.HaveStdOutContaining($"<IsAotCompatible Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))\">true</IsAotCompatible>");
675677
} else {
676678
resultAssertion.And.NotHaveStdOutContaining($"warning");
677679
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,9 @@ public void PublishTrimmed_fails_for_unsupported_target_framework(string targetF
187187
[InlineData("net5.0", true)]
188188
[InlineData("net6.0", false)]
189189
[InlineData("netstandard2.0;net5.0", true)] // None of these TFMs are supported for trimming
190-
[InlineData("netstandard2.0;net6.0", false)] // Net6.0 is the min TFM supported for trimming and targeting.
191-
[InlineData("netstandard2.0;net8.0", true)] // Net8.0 is supported for trimming, but leaves a "gap" for the supported net6.0/net7.0 TFMs.
190+
[InlineData("netstandard2.0;net6.0", false)] // net6.0 is the min TFM supported for trimming and targeting.
191+
[InlineData("netstandard2.0;net8.0", false)] // Net8.0 is supported for trimming and targeting.
192+
[InlineData("netstandard2.0;net9.0", true)] // Net8.0 is supported for trimming, but leaves a "gap" for the supported net6.0/net7.0 TFMs.
192193
[InlineData("alias-ns2", true)]
193194
[InlineData("alias-n6", false)]
194195
[InlineData("alias-n6;alias-n8", false)] // If all TFMs are supported, there's no warning even though the project uses aliases.
@@ -200,19 +201,19 @@ public void IsTrimmable_warns_when_expected_for_not_correctly_multitargeted_libr
200201

201202
var testProject = CreateTestProjectForILLinkTesting(_testAssetsManager, targetFrameworks, projectName);
202203
testProject.AdditionalProperties["IsTrimmable"] = "true";
203-
testProject.AdditionalProperties["NoWarn"] = "NETSDK1138"; // Silence warning about targeting EOL TFMs
204+
testProject.AdditionalProperties["CheckEolTargetFramework"] = "false"; // Silence warning about targeting EOL TFMs
204205
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFrameworks)
205206
.WithProjectChanges(AddTargetFrameworkAliases);
206207

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

test/dotnet-new.IntegrationTests/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)