Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting <UseMaui>true</UseMaui> does not automatically include NuGet package references?

I'm making a MAUI Android app and some time ago I updated the target framework to .NET8. Since then, I'm getting this warning about Microsoft.Maui.Controls not being automatically included.

Warning MA002 Starting with .NET 8, setting true does not automatically include NuGet package references in your project. Update your project by including this item: . You can skip this warning by setting true in your project file. NLTerminal C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\8.0.7\Sdk\BundledVersions.targets 85

I updated the package to 8.0.21 and then manually added a PackageReference in the .csproj file:

<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.21" />

I then saw, VS automatically also added an Update reference:

<PackageReference Update="Microsoft.Maui.Controls" Version="8.0.21" />

Is there any way to resolve this warning except suppressing it as it suggests?

<SkipValidateMauiImplicitPackageReferences>true</SkipValidateMauiImplicitPackageReferences>

I figured out the warning is coming from the BundledVersions.targets file where it seems to be hard-coded to be permanently displayed until it's erased from there. Is that the right solution though?

Or is there a way to fetch a newer version of Microsoft.Maui.Sdk and hope that will resolve the warning?

like image 392
Val Avatar asked Mar 14 '26 09:03

Val


1 Answers

This may relate to a known issue on GitHub, warning MA002 is raised claiming that packages are not automatically included. From the comment, it seems the messaging text is misleading here, and the issue is added to the backlog. You may track this issue.

Also, these Microsoft.Maui.Controls are about Controls of MAUI, which IS A part of MAUI. So you don't have to reference them again.

Hope it helps!

like image 178
Felix Shen Avatar answered Mar 16 '26 00:03

Felix Shen