Skip to content

Add NU1704 warning for packages using deprecated MonoAndroid framework#7229

Open
sbomer wants to merge 4 commits intoNuGet:devfrom
sbomer:monoandroid-warning
Open

Add NU1704 warning for packages using deprecated MonoAndroid framework#7229
sbomer wants to merge 4 commits intoNuGet:devfrom
sbomer:monoandroid-warning

Conversation

@sbomer
Copy link
Copy Markdown

@sbomer sbomer commented Mar 24, 2026

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.

Bug

Adds the warning mentioned in dotnet/android#11028.

Description

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
Copy link
Copy Markdown

Frulfump commented Mar 25, 2026

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
Copy link
Copy Markdown
Author

sbomer commented Mar 25, 2026

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
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Added needs-breaking-change-doc-created label because this PR has the breaking-change label.

When you commit this breaking change:

  1. Create and link to this issue a matching issue in the dotnet/docs repo using the breaking change documentation template, then remove this needs-breaking-change-doc-created label.
  2. Ask a committer to mail the .NET SDK Breaking Change Notification email list.

You can refer to the .NET SDK breaking change guidelines

}
}

// Log NU1704 warning if the package uses the deprecated MonoAndroid framework
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.

breaking change mechanics aside, i wonder if we should just re-use Nu1703.

It existed for a very very short time and it's unlikely anyone is specifying it their project file based on some of the comments we've made when we reverted it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I considered this but noticed we did document NU1703 with text that references xamarin.ios, so I went with a new warning. Happy to use NU1703 instead if we are ok with changing that doc.

Copy link
Copy Markdown
Member

@nkolev92 nkolev92 Mar 25, 2026

Choose a reason for hiding this comment

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

I'll let someone else from the team chip in too before you go and make that change. I am comfortable with changing that documentation too.

Oh there's this thing I meant to link to but I forgot in the previous comment: https://github.com/NuGet/NuGet.Client/blob/dev/docs/feature-guide.md#warnings-and-defaults

So whatever we add, we'll need to gate on SDKAnalysisLevel.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

/cc @rolfbjarne

I think it would be OK to reuse the code and just include Xamarin.Android and Xamarin.iOS both in the docs.

I think this is false anyway:

While net6.0-maccatalyst (and higher .NET versions) support using Xamarin.iOS dependencies, this is not guaranteed to be 100% compatible.

I don't think they would work at all?

However, Xamarin.Android class libraries are more in the "not guaranteed to be 100% compatible", but could actually work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While net6.0-maccatalyst (and higher .NET versions) support using Xamarin.iOS dependencies, this is not guaranteed to be 100% compatible.

I don't think they would work at all?

No, this doesn't work.

In fact Xamarin.iOS.dll never worked in .NET, so I'm fine with reusing the warning number, nobody should have seen NU1703 in the first place.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated to reuse NU1703.

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.
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.

5 participants