maui: Updating Visual Studio 2022 to 17.12.1 breaks all Maui builds

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:

  • resource style/Maui.SplashTheme (aka XXXXXXX:style/Maui.SplashTheme) not found.
  • failed linking references.
  • The type or namespace name ‘MauiAppCompatActivity’ could not be found (are you missing a using directive or an assembly reference?)
  • Cannot implicitly convert type ‘XXXXXXX.MainActivity’ to ‘Android.App.Activity’
  • ‘Platform’ does not contain a definition for ‘OnRequestPermissionsResult’
  • The name ‘Resources’ does not exist in the current context
  • style attribute ‘attr/windowNoTitle (aka XXXXXXX:attr/windowNoTitle)’ not found.
  • style attribute ‘attr/windowActionBar (aka XXXXXXX:attr/windowActionBar)’ not found.
  • The type or namespace name ‘MauiUIApplicationDelegate’ could not be found (are you missing a using directive or an assembly reference?)
  • The type or namespace name ‘MauiWinUIApplication’ could not be found (are you missing a using directive or an assembly reference?)

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


About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (2 by maintainers)

Most upvoted comments

We’ve found some similar issues:

  • #25160 , similarity score: 83%

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.

Eventually found my way to this issue and a solution that would allow me to build .net7 workloads in GitHub Actions.

The changeset is here, but I believe the magic sauce was adding these two steps:

     - name: Set global.json
      run: dotnet new globaljson --sdk-version 7.0.100

    - name: Restore MAUI Workloads
      run: dotnet workload restore

Does anyone have steps for resolving this without having to upgrade to .NET 9 (currently on .net 7)?

Example error: GitHub Action runners.

I do not have the bandwidth to upgrade all my projects to .NET 9 right now. That is on the roadmap for 2025.

This fixed my local builds in Visual Studio, but it did not fix GHA builds.

Sounds as a real world consideration…

Does anyone have steps for resolving this without having to upgrade to .NET 9 (currently on .net 7)?

Example error: GitHub Action runners.

I do not have the bandwidth to upgrade all my projects to .NET 9 right now. That is on the roadmap for 2025.

This fixed my local builds in Visual Studio, but it did not fix GHA builds.

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.