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

Randomly unable to debug MAUI project #1449

Closed
davidortinau opened this issue Sep 9, 2024 · 40 comments
Closed

Randomly unable to debug MAUI project #1449

davidortinau opened this issue Sep 9, 2024 · 40 comments
Assignees
Labels
area-maui bug Something isn't working vs-sync Add this label to synchronize the issue to AzDo vs-syncd Linked to AzDO

Comments

@davidortinau
Copy link
Member

davidortinau commented Sep 9, 2024

Type: Bug

After several successfully debugging sessions I will occasionally be unable to debug after hitting F5 or the debug button. I'm presented with a modal stating "could not find the task maui : BUILD".

Screenshot 2024-09-07 at 8 21 19 AM

If I reload the window, I can once again debug. Sometimes I can F5 repeatedly (closing the modal) and the issue also seems to resolve itself.

Extension version: 1.3.29
VS Code version: Code - Insiders 1.93.0-insider (4849ca9bdf9666755eb463db297b69e5385090e3, 2024-09-04T13:13:15.344Z)
OS version: Darwin arm64 23.6.0
Modes:

System Info
Item Value
CPUs Apple M1 Pro (8 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 5, 4, 4
Memory (System) 16.00GB (0.05GB free)
Process Argv --crash-reporter-id fc80353a-ef2a-479f-83ff-be5b061d3542
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vsc_aacf:30263846
vscod805:30301674
vsaa593:30376534
py29gd2263:31024238
c4g48928:30535728
962ge761:30841072
pythongtdpath:30726887
welcomedialog:30812478
pythonnoceb:30776497
asynctok:30898717
dsvsc014:30777825
dsvsc015:30821418
pythonmypyd1:30859725
2e7ec940:31000449
pythontbext0:30879054
accentitlementst:30870582
dsvsc016:30879898
dsvsc017:30880771
dsvsc018:30880772
cppperfnew:30980852
pythonait:30973460
9c06g630:31013171
a69g1124:31018687
dvdeprecation:31040973
dwnewjupytercf:31046870
nb_pkg_only:31057982
nativerepl1:31104042
refactort:31084545
pythonrstrctxt:31093868
flighttreat:31119334
wkspc-onlycs-t:31132770
nativeloc1:31118317
wkspc-ranged-t:31125599
cf971741:31111988
jh802675:31132134
e80f6927:31120813
ei213698:31121563

| VS Bug 2245110

@davidortinau
Copy link
Member Author

@emaf I wonder if this might happen when the editor doesn't have focus when I hit F5, or whatever does have focus isn't the right thing.

@emaf
Copy link
Member

emaf commented Sep 10, 2024

@davidortinau are you using a launch json file?

But I think you raised a good point, when you face this again, could you try hitting F5 from a .cs and a .xaml file? Both go through different code paths so it would be interesting to see if that makes any difference.

@emaf emaf added the area-maui label Sep 10, 2024
@emaf emaf self-assigned this Sep 10, 2024
@emaf emaf added the vs-sync Add this label to synchronize the issue to AzDo label Sep 10, 2024
@AllenD-MSFT AllenD-MSFT added the vs-syncd Linked to AzDO label Sep 10, 2024
@davidortinau
Copy link
Member Author

@davidortinau are you using a launch json file?

But I think you raised a good point, when you face this again, could you try hitting F5 from a .cs and a .xaml file? Both go through different code paths so it would be interesting to see if that makes any difference.

No, no launch.json file is there.

I'll keep an eye on what has focus when this happens next time.

@webreidi webreidi added the bug Something isn't working label Sep 11, 2024
@lcapka
Copy link

lcapka commented Sep 17, 2024

Hi, this is happening to me consistently for 2 last ours (all day today). Totally no idea how to run the MAUI project. Hitting F5 repeatedly solves nothing.

I used to use launch.json, removed it completely, tried to add some tasks.json; yet result is always the same. No error visible anywhere, except this dialog.

@lcapka
Copy link

lcapka commented Sep 17, 2024

By the way when I hit 'Debug Anyway' it says "Error processing launch options at field: program". At this point I don't have launch.json file at all so it has to be something internal/default.

@lcapka
Copy link

lcapka commented Sep 17, 2024

One more thing I just found which may or may not relate to this issues - in the Extensions Host windows, there is an exception in the dotnet-maui:

2024-09-17 11:44:18.782 [error] Error: Error writing JSON RPC Message: MessagePackSerializationException: Failed to serialize System.Exception value.
at .vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:653025
at ne (.vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:653319)
at .vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:648103
at Immediate. (.vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:648123)
at processImmediate (node:internal/timers:478:21)

@churchs19
Copy link

I am also seeing this issue.

Version: 1.94.0-insider (Universal)
Commit: c4efe1dc9eec4914f3076b2d954fe4fe174a5820
Date: 2024-09-17T05:03:51.290Z
Electron: 30.4.0
ElectronBuildId: 10073054
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Darwin arm64 24.0.0

@emaf
Copy link
Member

emaf commented Sep 17, 2024

One more thing I just found which may or may not relate to this issues - in the Extensions Host windows, there is an exception in the dotnet-maui:

2024-09-17 11:44:18.782 [error] Error: Error writing JSON RPC Message: MessagePackSerializationException: Failed to serialize System.Exception value. at .vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:653025 at ne (.vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:653319) at .vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:648103 at Immediate. (.vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:648123) at processImmediate (node:internal/timers:478:21)

If you restat VS Code, do you see the same error?

@lcapka
Copy link

lcapka commented Sep 18, 2024

If you restat VS Code, do you see the same error?

@emaf Yes. Would be great to see what is the serialized exception...

2024-09-18 09:05:10.236 [error] Error: Error writing JSON RPC Message: MessagePackSerializationException: Failed to serialize System.Exception value.
at /Users/user/.vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:653025
at ne (/Users/user/.vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:653319)
at /Users/user/.vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:648103
at Immediate. (/Users/user/.vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:648123)
at processImmediate (node:internal/timers:478:21)
2024-09-18 09:05:13.556 [error] Error: Error writing JSON RPC Message: MessagePackSerializationException: Failed to serialize System.Exception value.
at /Users/user/.vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:653025
at ne (/Users/user/.vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:653319)
at /Users/user/.vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:648103
at Immediate. (/Users/user/.vscode/extensions/ms-dotnettools.dotnet-maui-1.3.29-darwin-arm64/dist/extension.js:2:648123)
at processImmediate (node:internal/timers:478:21)

@Matadin75
Copy link

Matadin75 commented Sep 18, 2024

Any news on this error? Its really frustrating :(
I recently updated my macOS to the latest and since then, i cant even run my code in VS.
Could it be that Microsoft hasn't caught up with Apples OS?

@emaf
Copy link
Member

emaf commented Sep 18, 2024

We haven't been able to reproduce this yet, so we need you to answer a few questions:

  1. Do you all see the same error @lcapka posted in this comment?
  2. Could you share the .NET MAUI output and the Terminal content (after trying to run your project)?
  3. Could you share your host OS version, C# Dev Kit and .NET MAUI extension versions?

@emaf emaf added the needs-more-info Needing more information, waiting on OP label Sep 18, 2024
@StefanW2015
Copy link

StefanW2015 commented Sep 18, 2024

Happens to me as well after upgrading to macOS Sequoia 15.0.

I get the same error posted by @davidortinau every time I try to run our MAUI project. We have no custom launch or task profiles set up and everything was running fine before upgrading macOS.

I use
MAUI 8.0.40/8.0.100 SDK 8.0.300
MAUI Extension v1.3.29
C# DevKit v1.10.18

There is no attempt to start anything in the .NET MAUI terminal output. I immedietaly receive 'Could not find the task 'maui: Build'.' after pressing F5.

Building the solution without running it still works.

@emaf
Copy link
Member

emaf commented Sep 18, 2024

@StefanW2015 could you confirm if there is any output in the .NET MAUI output panel (not the Terminal)?

@StefanW2015
Copy link

@StefanW2015 could you confirm if there is any output in the .NET MAUI output panel (not the Terminal)?

I meant the Output panel, sorry.

It's just the information that the SDKs were found after opening the project. Nothing new after trying to run / debug the app.

...
Xcode:
	- Path: /Applications/Xcode.app
	- Discovered from: xcode-select -p
	- Installed: true

@lcapka
Copy link

lcapka commented Sep 18, 2024

I have exactly the same status as @StefanW2015 wrote above - nothing in .NET MAUI Output panel except loaded versions. By the way all the extensions are latest (as can be downloaded):

VSCode Extensions:

  • .NET MAUI v1.3.29
  • C# v2.45.25
  • C# Dev Kit v1.10.18

OS: macOS Version 15.0 (24A335)

Android components:
- Java SDK: installed version '11.0.16.1'

Android SDK recommended required components:
- platforms/android-34: installed version '3'
- build-tools/34.0.0: installed version '34.0.0'
- platform-tools: installed version '35.0.2'
- cmdline-tools/11.0: installed version '16.0'

@Matadin75
Copy link

I have exactly the same status as @StefanW2015 wrote above - nothing in .NET MAUI Output panel except loaded versions. By the way all the extensions are latest (as can be downloaded):

VSCode Extensions:

  • .NET MAUI v1.3.29
  • C# v2.45.25
  • C# Dev Kit v1.10.18

OS: macOS Version 15.0 (24A335)

Android components: - Java SDK: installed version '11.0.16.1'

Android SDK recommended required components:
- platforms/android-34: installed version '3'
- build-tools/34.0.0: installed version '34.0.0'
- platform-tools: installed version '35.0.2'
- cmdline-tools/11.0: installed version '16.0'

All is the same for me
It was working a few months back but it's now not 😅

@rolfbjarne
Copy link
Member

This might be related to Xcode 16: xamarin/xamarin-macios#20802 (comment)

@rolfbjarne
Copy link
Member

This might be related to Xcode 16: xamarin/xamarin-macios#20802 (comment)

NVM, I can repro with Xcode 15.4 as well (but I'm on Sequoia)

@rolfbjarne
Copy link
Member

This might be related to Xcode 16: xamarin/xamarin-macios#20802 (comment)

NVM, I can repro with Xcode 15.4 as well (but I'm on Sequoia)

I can't repro on Sonoma, but that's also a different machine, so there may be any number of other differences as well.

@vhugogarcia
Copy link

Thanks @rolfbjarne for reference this issue.

I'm also facing the same issue, I'm sharing my post with details here: xamarin/xamarin-macios#20802 (comment)
image
image

I'm on macOS Sequoia with XCode 15.4

If there is any fix or workaround, please let us know.

In addition, I'm using the .NET MAUI latest stable version at this moment 1.3.29.

@BretJohnson
Copy link
Member

For folks that see this, can you also look in the C# output panel. There may be more clues there, as the brokered service in question here is calling from the MAUI extension process to the C# process (the same one that hosts Roslyn).

@BretJohnson
Copy link
Member

Also, for folks that see this, can you try disabling XAML Hot Reload and see if the problem goes away. Uncheck the user preferences checkbox shown here. Assuming that makes the issue stop, that can be a temporary workaround until we get a fix in place.

image

@kimbirkelund
Copy link

Also, for folks that see this, can you try disabling XAML Hot Reload and see if the problem goes away. Uncheck the user preferences checkbox shown here. Assuming that makes the issue stop, that can be a temporary workaround until we get a fix in place.

image

This workaround seems to work for me, at least for a brand new MAUI project. Enable Hot Reload again returns the "could not find the task maui : BUILD" error.

@janusw
Copy link

janusw commented Sep 19, 2024

This workaround seems to work for me, at least for a brand new MAUI project. Enable Hot Reload again returns the "could not find the task maui : BUILD" error.

I can confirm that this workaround also helps for more complex projects 👍
(on MacOS Sequoia 15.0 with XCode 15.4 and .NET SDK 8.0.401)

@churchs19
Copy link

churchs19 commented Sep 19, 2024

Cobbling together some pieces from both this thread and xamarin/xamarin-macios#20802, these are the steps that got me working again on Mac OS Sequoia 15.0:

  1. Install XCode 16.
  2. Reinstall XCode 15.4 from the Apple Developer Portal downloads side-by-side with XCode 16
  3. Set XCode 15.4 as the default XCode.
    1. Open XCode 15.4 with the following command line. It will tell you it is not supported on Sequoia if you try to open it from the icon in Launchpad.
      /Applications/XCode-15.app/Contents/MacOS/Xcode &
    2. Open Settings -> Locations and choose Xcode-15 15.4 (15F31d) from the Command Line Tools drop down.
    image
  4. Make sure that iOS 17.5 is available in the Platforms section of the XCode 15.4 settings
    image
  5. Open Visual Studio Code Settings -> Extensions -> .NET MAUI and ensure that Dotnet > Debug: Hot Reload XAML is unchecked.
    image

After following these steps, you will be able to build and debug MAUI applications, with or without a launch.json file, through VS Code on Mac OS Sequoia 15.0.

@vhugogarcia
Copy link

vhugogarcia commented Sep 19, 2024

Thanks @BretJohnson, and all who helped me to solve my issue. I can confirm the workaround you shared worked very good and I can continue debugging/developing mobile apps in .NET MAUI using:

  • Visual Studio Code + .NET MAUI extension
  • macOS Sequioa
  • XCode 16 + XCode 15.4 (installed both side by side)

I also went ahead and created a blog post article where I share my experience, I hope it helps others as well.
https://dev.to/vhugogarcia/solving-net-maui-issues-on-macos-sequoia-with-visual-studio-code-and-xcode-16-3ljd

Please share with us when a new update of the extension is released, so we can update it and give it a try.

@danardelean
Copy link

@vhugogarcia You don't need XCode 16 + XCode 15.4 (installed both side by side). Having Xcode 15.4 is enough to make it work. Installing Xcode 16 is more confusing because you will have to pay attention to the location of Command Line Tools

@vhugogarcia
Copy link

Thanks @danardelean for the feedback.

@drasticactions
Copy link
Member

Here's a mini RCA for why the task fails in Sequoia:

dotnet/announcements#324
dotnet/runtime#106775

The MAUI XAML Hot Reload extension uses a TCP Pipeline with a self-signed certificate for handling actions to and from your application and VSCode. There was an issue with Sequoia and the runtime that caused certificates in general to throw exceptions, which is what's happening here.

The exception here should have been handled and logged, but the exception itself ({Interop+AppleCrypto+AppleCommonCryptoCryptographicException: The specified item is no longer valid. It may have been deleted from the keychain.) that is thrown in the Language server code fails to be deserialized back to the (Typescript) VSCode extension with a MessagePack error. So basically, what should have been "Hot Reload fails to start and we tell you that it didn't load" became "Hot Reload breaks the build because the task can't complete due to unhandled exception because the actual exception couldn't be serialized"

So the key fixes are that XAML Hot Reload should never break the build if anything within the language server process or its part of the extension fails. The actual exception being thrown is a Runtime bug and so, in this state, XAML Hot Reload could not work unless SSL was disabled (which for security reasons is undesirable to allow here) until that was fixed. There is a PR in flight for the extension for wrapping the offending code here, letting it fail, and telling you that XAML Hot Reload failed to load in the log output.

Once the underlying .NET Runtime code is released, and the C# Extension is updated to use it, the underlying certificate issue should be resolved.

If you want to work around this without turning off XAML Hot Reload on Sequoia, you can:

  • Download a nightly .NET build for .NET 8 or 9 (You do not need to install it globally, it's only necessary for the Language Server process, so the tar.gz is fine)
  • Change the LSP to use this version of dotnet
image

Which you can do by going into your VSCode extension settings, and searching for dotnet: Dotnet Path and pointing it to your local checkout of the nightly dotnet build.

Save, restart VSCode, and you should now be able to deploy your MAUI app with XAML Hot Reload enabled (Or at least, it shouldn't fail to deploy now with that setting enabled.)

@maonaoda
Copy link

I have been using this
https://github.com/JaneySprings/DotNet.Meteor

@sindrevr
Copy link

Any news regarding the issue of hot reload not working?
I tested @drasticactions suggestion, but after allowing the files to run it throws "Microsoft.NETCore.App.app is damaged and cant open". Other work arounds without using DotNet.Meteor?

BR,
Sindre

@hflexgrig
Copy link

Also, for folks that see this, can you try disabling XAML Hot Reload and see if the problem goes away. Uncheck the user preferences checkbox shown here. Assuming that makes the issue stop, that can be a temporary workaround until we get a fix in place.

image

Helped me as well :)

@drasticactions
Copy link
Member

Any news regarding the issue of hot reload not working? I tested @drasticactions suggestion, but after allowing the files to run it throws "Microsoft.NETCore.App.app is damaged and cant open". Other work arounds without using DotNet.Meteor?

BR, Sindre

Nightly .NET builds are not signed. So you probably need to clear the Apple Quarantine on the .NET folder for it to make a clean build.

xattr -rd com.apple.quarantine /path/to/dotnet/folder

Otherwise, there's not much else you can do without both the underlying runtime fix being released, and the extension picking it up and using it. The exception not being caught issue I mentioned above is fixed in the extensions Main branch, and that should at least let the build through and deploy. I don't know when that will be published yet though, I assume whenever the next MAUI VSCode Extension preview is out. But hot reload won't work without the underlying runtime fix being published; the only other way to work around it would be to disable SSL and that would introduce security risks that I want to avoid.

@sindrevr
Copy link

sindrevr commented Oct 4, 2024

Thanks @drasticactions , working like a charm 👍

@BretJohnson
Copy link
Member

.NET 8.0.10 is now released, which fixes this issue. Here's the latest status:

@BretJohnson
Copy link
Member

@dibarbet - I added you as an assignee, as you are making the final fix for this with dotnet/vscode-csharp#7651. Thx.

@emaf emaf removed the needs-more-info Needing more information, waiting on OP label Oct 14, 2024
@dibarbet
Copy link
Member

dibarbet commented Oct 16, 2024

Version 2.54.24 (prerelease) of the C# extension should now require (and acquire if not already present) the 8.0.10 version of the runtime.

@nicholasyin
Copy link

nicholasyin commented Nov 22, 2024

So what's the status of this? In order to use VSCode on Mac Sequoia, we need to wait for the release before upgrading XCode and/or Sequoia?

@BretJohnson
Copy link
Member

BretJohnson commented Dec 7, 2024

@nicholasyin That's technically correct, but this fix was published to prerelease in mid October and then to the release channel in (I believe) early November. If you have version 2.54.24 or later of the C# extension in VS Code, it should just work. So if you are still seeing any problems on Sequoia, please let us know (ideally creating a new bug, but also feel free to comment here on this one), as it may well be a different issue.

@nicholasyin
Copy link

@nicholasyin That's technically correct, but this fix was published to prerelease in mid October and then to the release channel in (I believe) early November. If you have version 2.54.24 or later of the C# extension in VS Code, it should just work. So if you are still seeing any problems on Sequia, please let us know (ideally creating a new bug, but also feel free to comment here on this one), as it may well be a different issue.

thanks for the reply. already upgraded and working fine so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-maui bug Something isn't working vs-sync Add this label to synchronize the issue to AzDo vs-syncd Linked to AzDO
Projects
None yet
Development

No branches or pull requests