Skip to content

Commit 3debcfd

Browse files
CopilotmarcpopMSFT
andcommitted
Add .NET 6.0 to End-of-Life frameworks list to generate NETSDK1138 warnings (#49533)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: marcpopMSFT <[email protected]> Co-authored-by: Marc Paine <[email protected]>
1 parent 214a132 commit 3debcfd

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,8 @@ public void ILLink_analyzer_warnings_are_produced_using_EnableSingleFileAnalyzer
637637
[InlineData("netstandard2.0", true)]
638638
[InlineData("netstandard2.0;net5.0", true)] // None of these TFMs are supported for single-file
639639
[InlineData("netstandard2.0;net6.0", false)] // Net6.0 is the min TFM supported for single-file and targeting.
640-
[InlineData("netstandard2.0;net8.0", true)] // Net8.0 is supported for single-file, but leaves a "gap" for the supported net6./net7.0 TFMs.
640+
[InlineData("netstandard2.0;net8.0", false)] // Net8.0 is supported for single-file
641+
[InlineData("netstandard2.0;net9.0", true)] // Net9.0 is supported for single-file, but leaves a "gap" for the supported net6./net7.0 TFMs.
641642
[InlineData("alias-ns2", true)]
642643
[InlineData("alias-n6", false)]
643644
[InlineData("alias-n6;alias-n8", false)] // If all TFMs are supported, there's no warning even though the project uses aliases.
@@ -650,18 +651,19 @@ public void EnableSingleFile_warns_when_expected_for_not_correctly_multitargeted
650651
TargetFrameworks = targetFrameworks
651652
};
652653
testProject.AdditionalProperties["EnableSingleFileAnalyzer"] = "true";
654+
testProject.AdditionalProperties["CheckEolTargetFramework"] = "false"; // Silence warning about targeting EOL TFMs
653655
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFrameworks)
654656
.WithProjectChanges(AddTargetFrameworkAliases);
655-
657+
656658
var buildCommand = new BuildCommand(testAsset);
657-
var resultAssertion = buildCommand.Execute("/bl:my.binlog")
659+
var resultAssertion = buildCommand.Execute("/p:CheckEolTargetFramework=false")
658660
.Should().Pass();
659661
if (shouldWarn) {
660662
// Note: can't check for Strings.EnableSingleFileAnalyzerUnsupported because each line of
661663
// the message gets prefixed with a file path by MSBuild.
662664
resultAssertion
663665
.And.HaveStdOutContaining($"warning NETSDK1211")
664-
.And.HaveStdOutContaining($"<EnableSingleFileAnalyzer Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))\">true</EnableSingleFileAnalyzer>");
666+
.And.HaveStdOutContaining($"<EnableSingleFileAnalyzer Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))\">true</EnableSingleFileAnalyzer>");
665667
} else {
666668
resultAssertion.And.NotHaveStdOutContaining($"warning");
667669
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,8 @@ public void IsAotCompatible_implies_enable_analyzers(string targetFramework)
594594
[InlineData("netstandard2.0", true)]
595595
[InlineData("netstandard2.0;net5.0", true)] // None of these TFMs are supported for AOT
596596
[InlineData("netstandard2.0;net7.0", false)] // Net7.0 is the min TFM supported for AOT and targeting.
597-
[InlineData("netstandard2.0;net8.0", true)] // Net8.0 is supported for AOT, but leaves a "gap" for the supported net7.0 TFMs.
597+
[InlineData("netstandard2.0;net8.0", false)] // net8.0 is supported for AOT and targeting.
598+
[InlineData("netstandard2.0;net9.0", true)] // Net9.0 is supported for AOT, but leaves a "gap" for the supported net8.0 TFMs.
598599
[InlineData("alias-ns2", true)]
599600
[InlineData("alias-n6", false)]
600601
[InlineData("alias-n7;alias-n8", false)] // If all TFMs are supported, there's no warning even though the project uses aliases.
@@ -609,18 +610,19 @@ public void IsAotCompatible_warns_when_expected_for_not_correctly_multitarget_li
609610
TargetFrameworks = targetFrameworks
610611
};
611612
testProject.AdditionalProperties["IsAotCompatible"] = "true";
613+
testProject.AdditionalProperties["CheckEolTargetFramework"] = "false"; // Silence warning about targeting EOL TFMs
612614
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFrameworks)
613615
.WithProjectChanges(AddTargetFrameworkAliases);
614616

615617
var buildCommand = new BuildCommand(testAsset);
616-
var resultAssertion = buildCommand.Execute()
618+
var resultAssertion = buildCommand.Execute("/p:CheckEolTargetFramework=false")
617619
.Should().Pass();
618620
if (shouldWarn) {
619621
resultAssertion
620622
// Note: can't check for Strings.IsAotCompatibleUnsupported because each line of
621623
// the message gets prefixed with a file path by MSBuild.
622624
.And.HaveStdOutContaining($"warning NETSDK1210")
623-
.And.HaveStdOutContaining($"<IsAotCompatible Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))\">true</IsAotCompatible>");
625+
.And.HaveStdOutContaining($"<IsAotCompatible Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))\">true</IsAotCompatible>");
624626
} else {
625627
resultAssertion.And.NotHaveStdOutContaining($"warning");
626628
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ public void PublishTrimmed_fails_for_unsupported_target_framework(string targetF
169169
[InlineData("netstandard2.0", true)]
170170
[InlineData("netstandard2.1", true)]
171171
[InlineData("netstandard2.0;net5.0", true)] // None of these TFMs are supported for trimming
172-
[InlineData("netstandard2.0;net6.0", false)] // Net6.0 is the min TFM supported for trimming and targeting.
173-
[InlineData("netstandard2.0;net8.0", true)] // Net8.0 is supported for trimming, but leaves a "gap" for the supported net6.0/net7.0 TFMs.
172+
[InlineData("netstandard2.0;net6.0", false)] // net6.0 is the min TFM supported for trimming and targeting.
173+
[InlineData("netstandard2.0;net8.0", false)] // Net8.0 is supported for trimming and targeting.
174+
[InlineData("netstandard2.0;net9.0", true)] // Net8.0 is supported for trimming, but leaves a "gap" for the supported net6.0/net7.0 TFMs.
174175
[InlineData("alias-ns2", true)]
175176
[InlineData("alias-n6", false)]
176177
[InlineData("alias-n6;alias-n8", false)] // If all TFMs are supported, there's no warning even though the project uses aliases.
@@ -182,18 +183,19 @@ public void IsTrimmable_warns_when_expected_for_not_correctly_multitargeted_libr
182183

183184
var testProject = CreateTestProjectForILLinkTesting(targetFrameworks, projectName);
184185
testProject.AdditionalProperties["IsTrimmable"] = "true";
186+
testProject.AdditionalProperties["CheckEolTargetFramework"] = "false"; // Silence warning about targeting EOL TFMs
185187
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFrameworks)
186188
.WithProjectChanges(AddTargetFrameworkAliases);
187189

188190
var buildCommand = new BuildCommand(testAsset);
189-
var resultAssertion = buildCommand.Execute()
191+
var resultAssertion = buildCommand.Execute("/p:CheckEolTargetFramework=false")
190192
.Should().Pass();
191193
if (shouldWarn) {
192194
resultAssertion
193195
// Note: can't check for Strings.IsTrimmableUnsupported because each line of
194196
// the message gets prefixed with a file path by MSBuild.
195197
.And.HaveStdOutContaining($"warning NETSDK1212")
196-
.And.HaveStdOutContaining($"<IsTrimmable Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))\">true</IsTrimmable>");
198+
.And.HaveStdOutContaining($"<IsTrimmable Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))\">true</IsTrimmable>");
197199
} else {
198200
resultAssertion.And.NotHaveStdOutContaining($"warning");
199201
}

src/Tests/dotnet-new.Tests/CommonTemplatesTests.cs

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

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

390391
TemplateVerifierOptions options = new TemplateVerifierOptions(templateName: name)
@@ -419,7 +420,7 @@ public async void FeaturesSupport(
419420
{
420421
new DotnetBuildCommand(_log, "MyProject")
421422
.WithWorkingDirectory(workingDir)
422-
.Execute()
423+
.Execute("/p:CheckEolTargetFramework=false")
423424
.Should()
424425
.Pass()
425426
.And.NotHaveStdErr();

0 commit comments

Comments
 (0)