Repository navigation
Add NU1703 warning for packages using deprecated MonoAndroid framework - #7229
Conversation
Emit NU1704 when a project targeting net11.0-android or later references a package that resolves MonoAndroid framework assets instead of the modern net6.0-android+ TFMs. The warning is gated on SdkAnalysisLevel >= 11.0.100 and only applies to Android-targeting projects with framework version >= 11. The detection inspects compile-time and runtime assembly paths in the lock file target library for 'monoandroid' folder segments, following the pattern of the previously removed MaccatalystFallback helper.
# Conflicts: # src/NuGet.Core/NuGet.Common/PublicAPI.Unshipped.txt
|
NU1704 doesn't seem to be documented at https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings do I assume it's a new warning for NuGet 7/.NET 11? The PR title or description wasn't making it obvious if the warning itself is new or just the scenario... Since I couldn't find any docs for it I will ask this question. The PR description mentions lockfiles so will using lockfiles be a pre-condition to get this warning? Could a warning be issued without it or could some docs be further clarified? |
|
NU1704 is a new warning I'm introducing. It's similar to the NU1703 for xamarin.ios (before it was removed in #4362 because we decided xamarin.ios would not be supported). I'll add a docs PR too. |
|
Hey @sbomer Thanks for getting this conversation going. While the implementation is correct, we normally start with an https://github.com/nuget/home/issues and sometimes a spec for changes like this. https://github.com/NuGet/Home/blob/dev/meta/template.md The reasoning being that adding a new warning is considered disruptive and a breaking change as well meaning as it may be. We'd also probably be curious about the blast radius, so how many projects would be affected, but I doubt that's something we can easily figure out right now. I'll tag the PR as a breaking change and bot will follow with more links. |
Per PR feedback on NuGet/NuGet.Client#7229, reuse the NU1703 warning code for the MonoAndroid deprecation scenario. The previous NU1703 for Xamarin.iOS never shipped, so the code is safe to repurpose. Remove NU1704 doc and references from TOC and index.
…g paths Instead of re-parsing assembly paths (e.g. lib/monoandroid10.0/a.dll) to detect MonoAndroid usage, read the NuGetFramework already computed by FindBestItemGroup from ContentItemGroup.Properties["tfm"] during asset selection. Extend CreateLockFileTargetLibrary and LockFileBuilderCache to propagate the compile and runtime asset frameworks, and check IsMonoAndroidFramework in LockFileBuilder where the NU1703 warning is emitted. This removes the path-parsing helpers and simplifies tests.
|
@nkolev92 PTAL |
nkolev92
left a comment
There was a problem hiding this comment.
Apologies for the delay.
1 small feedback about src and the rest is for the tests.
- Move librariesWithMonoAndroidWarnings inside the per-framework loop so NU1703 is emitted per target framework, not deduplicated globally (see NuGet/Home#14815) - Convert ShouldCheck unit tests to Theory with InlineData - Reduce integration tests to: basic emit, multi-package, and package-level suppression (replacing redundant restore tests) - Remove unused System.Globalization using Co-authored-by: Copilot <[email protected]>
…MonoAndroidDeprecationTests.cs Co-authored-by: Nikolche Kolev <[email protected]>
|
Thanks for the help @nkolev92. Could you please merge this for me? |
|
Sorry for the delay @sbomer. Can you send the breaking change e-mail whenever you have some time. |
Bug
Fixes: NuGet/Home#14828
Adds the warning mentioned in dotnet/android#11028.
Description
Emit NU1704 when a project targeting net11.0-android or later references a package that resolves MonoAndroid framework assets instead of the modern net6.0-android+ TFMs. The warning is gated on SdkAnalysisLevel >= 11.0.100 and only applies to Android-targeting projects with framework version >= 11.
The detection inspects compile-time and runtime assembly paths in the lock file target library for 'monoandroid' folder segments, following the pattern of the previously removed MaccatalystFallback helper.
PR Checklist