Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
drewrobey opened this issue Nov 21, 2024 · 19 comments
Closed

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

drewrobey opened this issue Nov 21, 2024 · 19 comments
Labels
platform/android 🤖 platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 potential-regression This issue described a possible regression on a currently supported version., verification pending s/needs-attention Issue has more information and needs another look t/bug Something isn't working

Comments

@drewrobey
Copy link

drewrobey commented Nov 21, 2024

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

@drewrobey drewrobey added the t/bug Something isn't working label Nov 21, 2024
Copy link

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

jfversluis commented Nov 21, 2024

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.

@jfversluis jfversluis added the s/needs-info Issue needs more info from the author label Nov 21, 2024
@drewrobey
Copy link
Author

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.

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Nov 21, 2024
@jfversluis
Copy link
Member

Let us know how it goes!

@drewrobey
Copy link
Author

drewrobey commented Nov 21, 2024

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

  • The type or namespace name 'MauiAppCompatActivity' could not be found (are you missing a using directive or an assembly reference?)

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

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

drewrobey commented Nov 21, 2024

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

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

@drewrobey
Copy link
Author

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

@MitchBomcanhao
Copy link

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

@drewrobey
Copy link
Author

Not until this morning.

@drewrobey
Copy link
Author

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.

@samhouts samhouts added platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 platform/android 🤖 platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending labels Nov 21, 2024
@philosowaffle
Copy link

philosowaffle commented Nov 27, 2024

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.

@drewrobey
Copy link
Author

drewrobey commented Nov 27, 2024

@philosowaffle Are you using Microsoft.Maui.Controls.Compatibility?

There was another VS update released in the last 24 hours, have you got this yet?

@NickDrouin
Copy link

I was going to try out Maui today, I'm hitting this same problem, I installed 17.12.2.

I can build and run a new Maui .net8 project, I can build a new .net9 maui project, I can't build the sample project from:

https://github.com/CommunityToolkit/Maui

On a fresh install of the git repo.

C:\Users\...\source\repos\microsoft\Maui>dotnet --info
.NET SDK:
 Version:           8.0.404
 Commit:            7b190310f2
 Workload version:  8.0.400-manifests.22517898
 MSBuild version:   17.11.9+a69bbaaf5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.404\

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
 [android]
   Installation Source: SDK 8.0.400, VS 17.12.35521.163
   Manifest Version:    34.0.145/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.145\WorkloadManifest.json
   Install Type:        FileBased

 [aspire]
   Installation Source: SDK 8.0.400, VS 17.12.35521.163
   Manifest Version:    8.2.2/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
   Install Type:        FileBased

 [ios]
   Installation Source: SDK 8.0.400, VS 17.12.35521.163
   Manifest Version:    18.0.8316/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\18.0.8316\WorkloadManifest.json
   Install Type:        FileBased

 [maccatalyst]
   Installation Source: SDK 8.0.400, VS 17.12.35521.163
   Manifest Version:    18.0.8316/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\18.0.8316\WorkloadManifest.json
   Install Type:        FileBased

 [maui]
   Installation Source: SDK 8.0.400
   Manifest Version:    8.0.83/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.83\WorkloadManifest.json
   Install Type:        FileBased

 [maui-android]
   Installation Source: SDK 8.0.400
   Manifest Version:    8.0.83/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.83\WorkloadManifest.json
   Install Type:        FileBased

 [maui-ios]
   Installation Source: SDK 8.0.400
   Manifest Version:    8.0.83/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.83\WorkloadManifest.json
   Install Type:        FileBased

 [maui-maccatalyst]
   Installation Source: SDK 8.0.400
   Manifest Version:    8.0.83/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.83\WorkloadManifest.json
   Install Type:        FileBased

 [maui-tizen]
   Installation Source: SDK 8.0.400
   Manifest Version:    8.0.83/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.83\WorkloadManifest.json
   Install Type:        FileBased

 [maui-windows]
   Installation Source: SDK 8.0.400, VS 17.12.35521.163
   Manifest Version:    8.0.83/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.83\WorkloadManifest.json
   Install Type:        FileBased


Host:
  Version:      9.0.0
  Architecture: x64
  Commit:       9d5a6a9aa4

.NET SDKs installed:
  8.0.404 [C:\Program Files\dotnet\sdk]
  9.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  C:\Users\...\source\repos\microsoft\Maui\global.json

Where global.json is the default from the repo:

{
  "sdk": {
    "version": "8.0.303",
    "rollForward": "latestFeature",
    "allowPrerelease": false
  }
}

Errors are:

Severity	Code	Description	Project	File	Line	Suppression State
Error (active)	CS0234	The type or namespace name 'Composition' does not exist in the namespace 'Microsoft.UI' (are you missing an assembly reference?)	CommunityToolkit.Maui.Sample (net8.0-windows10.0.19041.0)	C:\Users\...\source\repos\microsoft\Maui\samples\CommunityToolkit.Maui.Sample\MauiProgram.cs	38	
Error (active)	CS0234	The type or namespace name 'Windowing' does not exist in the namespace 'Microsoft.UI' (are you missing an assembly reference?)	CommunityToolkit.Maui.Sample (net8.0-windows10.0.19041.0)	C:\Users\...\source\repos\microsoft\Maui\samples\CommunityToolkit.Maui.Sample\MauiProgram.cs	39	
Error (active)	CS0234	The type or namespace name 'Media' does not exist in the namespace 'Microsoft.UI.Xaml' (are you missing an assembly reference?)	CommunityToolkit.Maui.Sample (net8.0-windows10.0.19041.0)	C:\Users\...\source\repos\microsoft\Maui\samples\CommunityToolkit.Maui.Sample\MauiProgram.cs	40	
Error (active)	CS0246	The type or namespace name 'MauiWinUIApplication' could not be found (are you missing a using directive or an assembly reference?)	CommunityToolkit.Maui.Sample (net8.0-windows10.0.19041.0)	C:\Users\...\source\repos\microsoft\Maui\samples\CommunityToolkit.Maui.Sample\Platforms\Windows\App.xaml.cs	6	

@drewrobey
Copy link
Author

@NickDrouin I've never used one of the sample projects, so I can't comment on that directly, but .Net 9 has certainly changed much of the former ways Maui was configured to run (some methods have been tweaked, some methods deprecated and replaced, etc) so there's a distinct possibility that that sample project is now out-of-date and won't quite meet the latest standards.

@sbricchi
Copy link

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

@philosowaffle
Copy link

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

@sbricchi
Copy link

sbricchi commented Dec 9, 2024

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

It certainly works in development PC's and also Github Actions.
We have checked and you can even use "--sdk-version 8.0.404" to build your MAUI 7 app.
I´m not sure what´s the effect of using sdk 8 to build net/maui 7 apps. Does anyone know the difference?
But I´m pretty sure this was happening with our daily buildings in our development machines with VS2022 17.11 and earlier too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/android 🤖 platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 potential-regression This issue described a possible regression on a currently supported version., verification pending s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants