JaneySprings / DotNet.Meteor

A VSCode extension that can run and debug .NET apps (Xamarin, MAUI, Avalonia)
https://marketplace.visualstudio.com/items?itemName=nromanov.dotnet-meteor
MIT License
269 stars 10 forks source link

Error starting debugging session on Windows #34

Closed jfversluis closed 10 months ago

jfversluis commented 1 year ago

When using the extension on Windows, trying to run on Android, I run into the following error:

* Executing task: dotnet build "c:\Users\joverslu\testingmauivscode\testingmauivscode.csproj" -c:Debug -f:net7.0-android -t:Build -p:EmbedAssembliesIntoApk=true -p:AndroidSdkDirectory="C:\Program Files (x86)\Android\android-sdk"

x86: The term 'x86' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

It seems that it's thrown off by the (x86) in the path of the Android SDK directory, but it seems to be in quotes, so not sure why that happens. On the other hand, running that exact same command manually does seem to work, so maybe it isn't about the x86 in the path?

This is on a File > New .NET MAUI app and I installed the extension for the first time on my existing machine configuration.

JaneySprings commented 1 year ago

Hello! Thank you for your question. This looks like a bug. I've noticed that this behavior occurs only if you use PowerShell instead of the cmd. As a workaround, you can switch your VSCode terminal to the cmd.

image image
jfversluis commented 1 year ago

Ah perfect, I was wondering if that had anything to do with it. Confirmed that fixes it for now, thanks!

JaneySprings commented 1 year ago

Hi! This looks like a VSCode bug. I created the issue for this bug: https://github.com/microsoft/vscode/issues/173719

OutOfScopeia commented 1 year ago

Hi Nikita, I just ran into the same error. May I suggest using single quotes (') instead of double quotes (") to wrap the cmdline arguments in? I think that usually works better with powershell. I'd rather we didn't have to fall back to cmd in 2023 ;). I'm currently trying to do this myself and build a version of the extension to test it, but I'm unable to build anyway, without spending another weekend figuring out how Cake works (I always dread when I see tools like Cake/Fake/Paket because I immediately know I won't be able to build easily).

The line I think needs changing: from: builder.append(-p:AndroidSdkDirectory="${ConfigurationController.androidSdkDirectory}"); to: builder.append(-p:AndroidSdkDirectory='${ConfigurationController.androidSdkDirectory}');

and the method in this line could do with the same change tbh: .appendQuoted(ConfigurationController.project!.path)

JaneySprings commented 1 year ago

Hi, @OutOfScopeia! It would be a nice solution, but a lot of users are already using cmd. It will be a breaking change for them. I hope the VSCode team will fix this problem.

As a workaround, you can always open the folder with the extension code (C:\Users\YOU\.vscode\extensions\nromanov.dotnet-meteor-X.X.X\extension) and modify the extension.js file.

image

Don't forget to save the file and restart VSCode.

OutOfScopeia commented 1 year ago

I have already managed to build my own version with single-qoutes. I just needed to install vcse and webpack. And remove the 'net8.0' target from whatever project. But it's nice that an edit to an already deployed extension can fix it, too! I'll definitely be doing that from now on.

JaneySprings commented 10 months ago

Hi, Guys! When I was working on .NET Meteor 4.0, I found that there is a vscode.env.shell property in the VSCode. If we are on Windows and using powershell, then it will be a string C:\Windows\...\powershell.exe. I wrote a magic code that fixes the path to the Android Sdk.

Try the new version 3.4.1. Maybe someday Microsoft will fix this problem, but it's bad fix better than nothing =)