dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.26k stars 1.76k forks source link

Updating Visual Studio 2022 to 17.12.1 breaks all Maui builds #26020

Closed drewrobey closed 12 hours ago

drewrobey commented 14 hours ago

Description

We have a 5 Maui projects, and since updating Visual Studio last night, all now fail to build, with a variety of new error messages:

All of these projects built successfully yesterday before the update, both on Android and iOS.

Steps to Reproduce

  1. Update Visual Studio to 17.12.1
  2. Attempting to build any Maui project.

Link to public reproduction project repository

No response

Version with bug

9.0.10 SR1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

No response

Affected platforms

Android, iOS, Windows, macOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

similar-issues-ai[bot] commented 14 hours ago

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

jfversluis commented 14 hours ago

Besides updating Visual Studio did you update anything else? At the very least updating Visual Studio probably updated your workloads. Are you using $(MauiVersion) in your csproj file to reference the .NET MAUI version? If yes, then also your .NET MAUI SDK got updated.

Do you have some more complete build logs or anything besides just the error messages?

Are you building .NET 8 or .NET 9? What is the output of dotnet --info and dotnet workload list?

What can typically help is delete the bin & obj folders, do a Clean, do a Rebuild to make sure nothing cached is left behind and everything is build with the latest and greatest.

drewrobey commented 14 hours ago

Hi @jfversluis

The VS update was the first thing we did this morning, and we close every day with working builds, so nothing else has changed.

I'm attempting a dotnet workload update now. All errors seem to be connected to Visual Studio no longer recognising the Maui compatibility toolkit on both Android and iOS, so I'm guessing that solving that will eliminate all the errors.

jfversluis commented 14 hours ago

Let us know how it goes!

drewrobey commented 13 hours ago

Unfortunately that hasn't fixed it. The core lynchpin error, for Android at least, is:

We use the compat toolkit in all our projects, so the class signature on Android's MainActivity is always: public class MainActivity : MauiAppCompatActivity

...and if it can't resolve that, then it can't build anything else, or find any of the compat stuff used elsewhere.

EDIT: I've just created a new Maui project, using compat, and that won't build either, so something is awry with the VS update.

MitchBomcanhao commented 12 hours ago

what do you mean by compat toolkit? do you mean a reference to Microsoft.Maui.Controls.Compatibility? that line for public class MainActivity : MauiAppCompatActivity has no connection to Microsoft.Maui.Controls.Compatibility

drewrobey commented 12 hours ago

Well if that's not the compat toolkit stuff then the build issue is at a higher Maui level than the compat stuff.

EDIT: If we remove Microsoft.Maui.Controls.Compatibility from Nuget then we can build. I shall experiment further.

MitchBomcanhao commented 12 hours ago

well, on microsoft's maui documentation it says to remove the compatibility package reference when going from .net8 to .net9

drewrobey commented 12 hours ago

Interesting. We'd not moved any of the apps to .net 9 yet, but I think it might be time.

MitchBomcanhao commented 12 hours ago

if you updated maui to 9.0, aren't you using a .net9 package?

drewrobey commented 12 hours ago

Not until this morning.

drewrobey commented 12 hours ago

Solved it. The sequence that worked for us is:

  1. Upgrade projects to .net 9.
  2. Purge Nuget cache and restore.
  3. Update all Nugets to latest versions (Microsoft.Maui.Controls and Microsoft.Maui.Controls.Compatibility in Nuget must be same version - v9.0.10 - or apps won't build).
  4. Delete bin and obj folders.

We've done this on 3 of 7 workstations, and things will build again (with a ton of new warnings that weren't there before, but never mind).

I'll presume that the other 4 will also succeed with this, so I think this can be closed.