microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
231 stars 13 forks source link

[BUG] Debugging canceled: MAUI SDK not found. #523

Closed nor0x closed 1 year ago

nor0x commented 1 year ago

Describe the Issue

I followed the setup instructions on https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation?tabs=visual-studio-code to get started with .NET MAUI development. Everything works as intended in a newly created project (dotnet new maui) - debugging is just fine.

On a previously created project however I get the following error notification. Both projects are using .NET 8 (8.0.100-rc.1.23455.8)

ERROR ExitCode(1)
Details

.NET MAUI SDK verification failed with an unexpected error: Failed to retrieve the .NET SDK information.
If you cannot solve this problem, please report an issue from the Help menu.

user preferred path: C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot
Java SDK: shared with Visual Studio [installed]
Android service Java SDK found: C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot
user preferred path: C:\Program Files (x86)\Android\android-sdk
Android SDK: shared with Visual Studio [installed]
Android service Android SDK found: C:\Program Files (x86)\Android\android-sdk
Android SDK recommended required components:
    platform-tools  installed
    cmdline-tools  installed
Debugging canceled: MAUI SDK not found.

dotnet workload list output

Installed Workload Id      Manifest Version                  Installation Source
--------------------------------------------------------------------------------
maui                       8.0.0-rc.1.9171/8.0.100-rc.1      SDK 8.0.100-rc.1

I'm on Windows 11 23H2 and using the .NET MAUI Extension version 0.3.22 but also tried with the current pre-release 0.4.3.

Environment Information

Related Issues ?

https://github.com/microsoft/vscode-dotnettools/issues/390 https://github.com/microsoft/vscode-dotnettools/issues/269

VS bug #1886262

tentom commented 1 year ago

I get the exact same error!

Developing anything on MAUI on a Mac is a real pain lately!

The entire reason why I am doing this is to try to solve an issue with CollectionViews witch is supposedly fixed in .net8 and here I am shaving a yack after installing .net8 in VS4Mac did not work out as expected either.

nor0x commented 1 year ago

I get the exact same error!

Developing anything on MAUI on a Mac is a real pain lately!

The entire reason why I am doing this is to try to solve an issue with CollectionViews witch is supposedly fixed in .net8 and here I am shaving a yack after installing .net8 in VS4Mac did not work out as expected either.

so also macOS is affected by this issue. Can you confirm that it works fine with a dotnet new maui project?

tentom commented 1 year ago

so also macOS is affected by this issue. Can you confirm that it works fine with a dotnet new maui project?

Yes I can confirm a project created with dotnet new maui creates a project that runs as documented while my project that I try to compile on .net8 fails with a Debugging canceled: MAUI SDK not found. error.

And in the output window the entire message is:

ERROR ExitCode(1)
Details

.NET MAUI SDK verification failed with an unexpected error: Failed to retrieve the .NET SDK information.
If you cannot solve this problem, please report an issue from the Help menu.

Java SDK: custom [installed]
Android service Java SDK found: /Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home
Android SDK: shared with Visual Studio [installed]
Android service Android SDK found: /Users/mortelil/Library/Developer/Xamarin/android-sdk-macosx
Android SDK recommended required components:
    platform-tools  installed
    cmdline-tools  installed
Debugging canceled: MAUI SDK not found.

Output from dotnet workload list

Installed Workload Id      Manifest Version                  Installation Source
--------------------------------------------------------------------------------
maui-ios                   8.0.0-rc.1.9171/8.0.100-rc.1      SDK 8.0.100-rc.1   
maui                       8.0.0-rc.1.9171/8.0.100-rc.1      SDK 8.0.100-rc.1  

Code version information:

Version: 1.82.1 (Universal)
Commit: 6509174151d557a81c9d0b5f8a5a1e9274db5585
Date: 2023-09-08T08:49:32.930Z (6 days ago)
Electron: 25.8.0
ElectronBuildId: 23503258
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 22.6.0

Extension Version information:

.NET MAUI v0.4.3
C# v2.2.10
C# Dev Kit
tondat commented 1 year ago

@nor0x could you please install latest .Net8 rc1 (8.0.100-rc.1.23463.5) and update the maui workload and see if that fixes the issue?

nor0x commented 1 year ago

hi @tondat sorry I have closed this by accident but the bot was too fast and now i cannot reopen it πŸ™ˆ

i can still reproduce this issue with 8.0.100-rc.1.23463.5

PurpleGranite commented 1 year ago

@tondat / @nor0x - same issue here.

What I've tried:

In every case, when attempting to start the project, the following is reported in the .NET MAUI Output window:

ERROR ExitCode(2147516547)
Details
Error: [c:\<PathToMyProject>\host\fxr] does not exist

.NET MAUI SDK verification failed with an unexpected error: Failed to retrieve the .NET SDK information.
If you cannot solve this problem, please report an issue from the Help menu.
Android platform cannot be initialized. Please verify the Android SDK and JDK installation.

Java SDK:  [not found]
Android SDK: custom [not found]
Debugging canceled: MAUI SDK not found.

(Note that I only have the maui-windows workload installed and only have windows as a target in my .csproj, so the Java / Andriod SDK issues are spurious)

I have also tried all of the above on a completely clean install of Windows 11 in a virtual machine, and it does work there. I've compared everything I can between the VM and my host system and can see no differences between the two!

Dotnet Version Information (output is the same on the affected machine and working VM):

~
❯ dotnet --version
8.0.100-rc.1.23463.5

~
❯ dotnet --list-sdks
8.0.100-rc.1.23463.5 [C:\Program Files\dotnet\sdk]

~
❯ dotnet --list-runtimes
Microsoft.AspNetCore.App 8.0.0-rc.1.23421.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.0-rc.1.23419.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.0-rc.1.23420.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

~
❯ dotnet sdk check
.NET SDKs:
Version                   Status
-------------------------------------
8.0.100-rc.1.23463.5      Up to date.

.NET Runtimes:
Name                              Version                  Status
----------------------------------------------------------------------
Microsoft.NETCore.App             8.0.0-rc.1.23419.4       Up to date.
Microsoft.WindowsDesktop.App      8.0.0-rc.1.23420.5       Up to date.
Microsoft.AspNetCore.App          8.0.0-rc.1.23421.29      Up to date.

The latest versions of .NET can be installed from https://aka.ms/dotnet-core-download. For more information about .NET lifecycles, see https://aka.ms/dotnet-core-support.

~ took 21s
❯ dotnet workload list

Installed Workload Id      Manifest Version                  Installation Source
--------------------------------------------------------------------------------
maui-windows               8.0.0-rc.1.9171/8.0.100-rc.1      SDK 8.0.100-rc.1

Use `dotnet workload search` to find additional workloads to install.

Both working and non-working machines are running: Windows 11 - 22H2 (22621.2283) Visual Studio Code:

Version: 1.82.2 (user setup)
Commit: abd2f3db4bdb28f9e95536dfa84d8479f1eb312d
Date: 2023-09-14T05:55:25.390Z
Electron: 25.8.1
ElectronBuildId: 23779380
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.22621

C# Extension Version: 2.2.10 C# Dev Kit Extension Version: 0.5.47 .NET MAUI Extension Version: 0.4.3 .NET Runtime Install Tool Extension Version: 1.7.3 IntelliCode for C# Dev Kit Extension Version: 0.1.26

I'm assuming that, in my case at least, the error relating to the host\fxr path not being found is in some way causal, but I don't see any differences between my host machine and the working test VM which would account for the extension or runtime correctly locating this in the .NET install location on the working VM, yet incorrectly searching for this path within my project code folder on the non-functional instance.

nor0x commented 1 year ago

hi @tondat sorry I have closed this by accident but the bot was too fast and now i cannot reopen it πŸ™ˆ

i can still reproduce this issue with 8.0.100-rc.1.23463.5

Hi @tondat @tmeschter @webreidi πŸ‘‹ can someone reopen this issue? It's not resolved and I closed it by accident

UPDATE: thx πŸ™Œ

PurpleGranite commented 1 year ago

I've been playing about a little more this evening, I decided to try to create a fresh MAUI project using VS Code Insiders - to my surprise this worked as expected, the project builds and runs, and the same project builds and runs in the release version too!

Weirdly, after doing this, I can now also create new projects in the release build just fine, new projects now created in the release version of VS Code build and run as expected.

But ... the same project I created in the release version of VS Code last night won't build or run, in either the release or insiders versions of VS Code!

The insiders build I used is:

Version: 1.83.0-insider (user setup)
Commit: 10765021158cf51eaf6785361598e1668f53e06e
Date: 2023-09-18T15:06:20.425Z
Electron: 25.8.1
ElectronBuildId: 23779380
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.22621

I noticed a couple of minor differences in the generated .sln file between the two, but when I ported these into my 'broken' project, nothing changed.

I can't see any other differences - a side-by-side diff of the two .csproj files shows no differences, the generated code files are the same too. I'm using the same extensions and extension versions in both cases.

Looking at my local files and my tests, I wondered for a moment whether my use of spaces or dots in the file / folder / project names made any difference, but I tried all the combinations of both I could think of, and after the odd 'workaround' of using insiders first as noted above, every project I created in the release build worked as expected.

Could the insiders build have 'fixed' something system-wide? And if so, why doesn't the original project build and run when new projects now do seem to work?

wiljoetradify commented 1 year ago

I have this exact same message too

For my scenario, I have my production Xamarin app csrpoj(s) and my MAUI app csproj(s) on the same folder. I found that removing Xamarin app csproj(s) help to make this extension work.

but I hope that this extension should only evaluate csproj that the sln file specified

jrahma commented 1 year ago

Same issue with existing Visual Studio for Mac project when running it on VS Code

OudomMunint commented 1 year ago

Same issue. I'm on macOS 13.6, Xcode 14.3.1, .NET 7 on an Existing project

MauroJavier commented 1 year ago

I deleted the solution file on my project that was created with Visual Studio for Mac and after that my project compiles and works

janhjordie commented 1 year ago

I had same issue. For some reason I had several solution files. Deleting all of them and created a new did the trick.

OudomMunint commented 1 year ago

@janhjordie How do you create a new solution file for an existing prj?

whodges commented 1 year ago

I had the same problem. I had a MAUI project created with Visual Studio for Mac (let's call it MauiApp1.sln), and I tried to open it in VS Code (on my Macbook). I'd get the "MAUI SDK Not Found" error above. Now MauiApp1 actually had two solution files: MauiApp1.sln and MauiApp1Mac.sln; I won't bother explaining why. And MauiApp1.sln referenced MauiApp1.csproj, while MauiApp1Mac.sln referenced MauiApp1Mac.csproj. So there was two .csproj files in my MauiApp1 directory; VS Code does not seem to like that. I had to delete one. On top of that, I had a PreBuild.proj file in there that contained some MSBuild script to run before the project gets built; that had to go too. Once I deleted both of those, the "MAUI SDK Not Found" error went away.

So I'm still not sure what the root cause is, but it doesn't seem like the MAUI extension in VS Code likes it when it encounters...unexpected files? Obviously .cs and .xaml files and the like are all good. But it choked on that MSBuild script file i had, and the second .csproj. The second .csproj file is weird, so I can understand that. Re. the MS Build script file, it was just flagged as a 'Document' in Finder. But if I kept it and converted it to an RTF, VS Code was fine.

Anyway, just wanted to post what I experienced.

EDIT: After poking around more, it simply chokes when there's more than one file in the MAUI project folder with an extension that ends in 'proj'.

borrmann commented 1 year ago

I still see this happening. Why was the issue closed? Is there a solution?

emaf commented 1 year ago

Sorry, our automated system mistakenly closed this issue. @tondat is currently investigating it.

durandt commented 1 year ago

I get the same issue moving from a VS for mac solution. (.NET 7 MAUI)

I must say the (forced) transition from VS for mac is really painful and the tooling not working properly makes it worse. You should at least fix so that the error message is more specific about what is missing, we developers tend to hate guessing games.

EDIT: I can confirm that solution created from dotnet new maui works, but not the solution I created with VS for mac.

dotnet new maui

<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>

My solution (created 1y ago with VS for mac)

<TargetFrameworks>net7.0-ios;net7.0-android</TargetFrameworks>
durandt commented 1 year ago

@emaf @tondat automated system closed this issue again.

emaf commented 1 year ago

This issue has been fixed and will available on the prerelase channel later this week (v0.6.6).

NOTE: this issue is tracking the Debugging canceled: MAUI SDK not found error when having multiple files which extension end with proj in the same directory. If you are facing this error but don't have multuiple *proj files, please file a new issue.

durandt commented 1 year ago

This issue has been fixed and will available on the prerelase channel later this week (v0.6.6).

NOTE: this issue is tracking the Debugging canceled: MAUI SDK not found error when having multiple files which extension end with proj in the same directory. If you are facing this error but don't have multuiple *proj files, please file a new issue.

Thank you! Just to be clear, I will have to update the C# DevKit extension to preview, not the MAUI extension, right? (Looking at the version numbers for C# DevKit and MAUI extensions I'm not sure which v0.6.6 will refer to) I think I may have the same issue with multiple csproj files.

The reason was to exclude Android dependencies for faster builds when developing/running/testing on iOS first.

emaf commented 1 year ago

Thank you! Just to be clear, I will have to update the C# DevKit extension to preview, not the MAUI extension, right? (Looking at the version numbers for C# DevKit and MAUI extensions I'm not sure which v0.6.6 will refer to) I think I may have the same issue with multiple csproj files.

Sorry, I missed clarifying that. It's the MAUI extension what you'll need to update to v0.6.6 (prerelease), which will be published this week.

durandt commented 1 year ago

Removing the extra solution & project files fixed it for me. I will try the prerelease when it comes out.