Skip to content

Add NU1703 warning for packages using deprecated MonoAndroid framework - #7229

Merged
nkolev92 merged 10 commits into
NuGet:devfrom
sbomer:monoandroid-warning
May 4, 2026
Merged

nkolev92 merged 10 commits into
NuGet:devfrom
sbomer:monoandroid-warning

Conversation

@sbomer

@sbomer sbomer commented Mar 24, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

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.
@dotnet-policy-service dotnet-policy-service Bot added the Community PRs created by someone not in the NuGet team label Mar 24, 2026
@Frulfump

Frulfump commented Mar 25, 2026 •

Copy link
Copy Markdown

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?

@sbomer
sbomer marked this pull request as ready for review March 25, 2026 22:19
@sbomer
sbomer requested a review from a team as a code owner March 25, 2026 22:19
@sbomer
sbomer requested review from jeffkl and kartheekp-ms March 25, 2026 22:19
@sbomer

sbomer commented Mar 25, 2026

Copy link
Copy Markdown
Contributor Author

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.

@nkolev92

Copy link
Copy Markdown
Member

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.

@nkolev92 nkolev92 added the Breaking-change Label for .NET SDK breaking changes. label Mar 25, 2026
@nkolev92
nkolev92 self-requested a review March 25, 2026 23:25
sbomer added a commit to sbomer/docs.microsoft.com-nuget that referenced this pull request Mar 30, 2026
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.
@sbomer sbomer changed the title Add NU1704 warning for packages using deprecated MonoAndroid framework Add NU1703 warning for packages using deprecated MonoAndroid framework Mar 30, 2026
@jeffkl
jeffkl removed their request for review April 1, 2026 00:25
sbomer added 2 commits April 3, 2026 10:54
…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.
@sbomer
sbomer requested a review from nkolev92 April 3, 2026 22:41
@sbomer

sbomer commented Apr 7, 2026

Copy link
Copy Markdown
Contributor Author

@nkolev92 PTAL

@sbomer
sbomer requested a review from zivkan April 14, 2026 18:22
@sbomer

sbomer commented Apr 16, 2026

Copy link
Copy Markdown
Contributor Author

@zivkan @nkolev92 PTAL

@nkolev92 nkolev92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@sbomer
sbomer requested a review from nkolev92 April 21, 2026 21:33
@sbomer
sbomer requested a review from nkolev92 April 27, 2026 17:04
@sbomer

sbomer commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the help @nkolev92. Could you please merge this for me?

@sbomer

sbomer commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

@nkolev92 @zivkan I think this is ready to go, can someone please help merge this?

@nkolev92
nkolev92 merged commit 18f767f into NuGet:dev May 4, 2026
17 checks passed
@nkolev92

nkolev92 commented May 4, 2026

Copy link
Copy Markdown
Member

Sorry for the delay @sbomer.

Can you send the breaking change e-mail whenever you have some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking-change Label for .NET SDK breaking changes. Community PRs created by someone not in the NuGet team needs-breaking-change-doc-created

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add deprecation warning for monoandroid TFMs

6 participants