[release/7.0] Prevent warning for implicit ILCompiler reference #79870
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #79240. Since I am touching this, I'm also backporting a change to the warning message from #75043.
Customer Impact
Context: dotnet/sdk#28823
PublishAot
with .NET 8 SDK targetingnet7.0
produces the following warning:The 7.0 ILCompiler package produces this warning. This is by design for 7.0 scenarios, but the .NET 8 SDK uses an implicit
PackageReference
to reference the 7.0 ILCompiler, which should not warn.This fix removes the warning in the .NET 8 SDK scenario, and rewords the warning when using an explicit
PackageReference
(a 7.0 scenario) to avoid recommendation to setPublishAot
, since this is only reachable whenPublishAot
is already set.Testing
There are existing tests for the unchanged behavior in https://github.com/dotnet/sdk/blob/7663c1f4d5896acfb71067be3fb9510be7bde4f1/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs#L266.
Tests are being added for the 8.0 behavior in dotnet/sdk#29393.
Risk
Very low. The implicit packagereference didn't exist in 7.0, so only the warning message changes when using the NET 7 SDK.