oleg-shilo / cs-script.vscode

VSCode extension for CS-Script
MIT License
39 stars 7 forks source link

Debugging in Mac m2 Pro does not work #38

Open yao-big opened 3 months ago

yao-big commented 3 months ago

The vscode plugin CS Script Mono Debug C # has been installed

Mono has also been installed

image image

The program can run normally, but clicking the debug button does not respond

Is it a problem with my local environment? Can you provide some guidance? Thank you very much

yao-big commented 3 months ago

I searched for a lot of information but couldn't solve this problem. What should I do?

oleg-shilo commented 3 months ago

I am not sure what cs-script version you are running. The plugin that is currently distributed is compiled against .NET but not .NET Framework. Thus it cannot be executed nor debugged unless you have .NET 8.0 installed. If you do, then you don't need mono at all.

You just have VSCode .NET tools installed and it's all you need

yao-big commented 3 months ago

The. net version is 8.0 cs script, which is the latest version

oleg-shilo commented 3 months ago

OK, then I do not know who the mono compiler is in the picture.

cs-script is executed under the hood with the dotnet executable, not Mono.

And for debugging VSCode is using the .NET tools plugin but not the Mono plugin.

This is the primary problem.

The secondary problem is that I made a mistake in my answer. The VSCode CS-Script plugin depends on .NET 7 not .NET 8. Thus unless you also install .NET7 SDK you will not be able to run/debug. Thus I will urgently release the update so the plugin targets the latest .NET

I will prioritize this work, but it will not help you until you solve the Mono problem.

oleg-shilo commented 3 months ago

Mind you that there is also an option to configure an external deployment of CS-Script engine (e.g. via nuget) instead of the one that is distributed with the plugin: image This can be used when you want to use a specific version of the engine.

oleg-shilo commented 3 months ago

Done, I just have published the update to the plugin that includes the cs-script version that targets .NET 8.0 image . . . So after you update the plugin:

oleg-shilo commented 3 months ago

And this is the result image

yao-big commented 3 months ago

May I ask how to install CS script on Mac? I tried several methods, but none of them worked

oleg-shilo commented 3 months ago

Install .NET SDK 8. Then install the script engine by any of the installation approaches from the release notes. See the deployment section: https://github.com/oleg-shilo/cs-script/releases/tag/v4.8.16.0

In your case it will be either manual approach or as a .net tool. I suggest you do the second:

dotnet tool install --global cs-script.cli

Now you can execute cs-script as

dotnet <path to cscs.dll> --version

I would recommend creating an alias:

alias css='dotnet /usr/local/bin/cs-script/cscs.dll'+
. . .
css --version

After that you can create the script

css -new test.cs

and execute it

css test.cs
yao-big commented 3 months ago

CS script has been installed and still cannot be used

I recorded a video, you can take a look

Operating system Mac m2

Vscode version 1.90.2

CS script latest v

https://github.com/oleg-shilo/cs-script.vscode/assets/30170943/f51f5d7e-0ba6-4abe-b31e-3b298bd9f5d1

ersion

yao-big commented 3 months ago
image
oleg-shilo commented 3 months ago

Great progress. CS-Script works now perfectly.

The only thing that is not happening for you is debugging.

I have checked and in debug() routine found some dead code that is not executed but... I do not like that it hangs there and potentially interferes with the debugging. I cannot check it as I do not have mac environment. So I just removed the dead code and published a pre-release for you: https://github.com/oleg-shilo/cs-script.vscode/releases/tag/v2.2.3-pre

So please check if it helps. Remember, you must ensure you have no workspace/folder open in VSCode. Only a single cs file.

The whole debugging is not a rocket science. Plugin simply executes vscode.debug.startDebugging(undefined, launchConfig) where launchConfig is a launch.json that I distribute with the plugin.

I captured this file from a sample C# project I created with VSCode.

Maybe this launchConfig is somehow invalid in your environment. On Linux it's fine...

let launchConfig = {
            name: ".NET Core Launch (console)",
            type: "coreclr",
            request: "launch",
            program: "dotnet",
            args: [settings.cscs, "-d", extra_args().replace("-co:/debug:pdbonly", ""), vsc_config.get("cs-script.extra_args"), "", "-l", "-ac:2", editor.document.fileName],
            cwd: path.dirname(editor.document.fileName),
            console: "internalConsole",
            stopAtEntry: false
        }
yao-big commented 3 months ago

I found that there must be no open workspace/folder in VSCode. Is it normal for only one CS file to be debugged?

oleg-shilo commented 3 months ago

Yes, it is normal. In fact, it is the only right way for the extension to operate. Otherwise, if you start debugging the script while VSCode has the workspace it is not clear what is going to be debugged an open document or an open folder.

This is the reason I have asked you to open VSCode without any folder loaded. I even used work empty in bold. :)

image

yao-big commented 3 months ago

Sure, thank you very much. It's already working fine now. This is a great feature, and I'm very grateful for your help.