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

Debugging in Mac m2 Pro does not work #38

Open
yao-big opened this issue Jun 17, 2024 · 15 comments
Open

Debugging in Mac m2 Pro does not work #38

yao-big opened this issue Jun 17, 2024 · 15 comments
Labels

Comments

@yao-big
Copy link

yao-big commented Jun 17, 2024

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

yao-big commented Jun 17, 2024

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

@oleg-shilo
Copy link
Owner

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

yao-big commented Jun 19, 2024

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

@oleg-shilo
Copy link
Owner

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

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

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:

  • Open a fresh empty instance of VSCode
  • Create a new script:
    image
  • And now either execute the script:
    image
    Or debug it:
    image

@oleg-shilo
Copy link
Owner

And this is the result
image

@yao-big
Copy link
Author

yao-big commented Jun 20, 2024

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

@oleg-shilo
Copy link
Owner

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

yao-big commented Jun 20, 2024

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

2024-06-20.22.52.13.mov

ersion

@yao-big
Copy link
Author

yao-big commented Jun 20, 2024

image

@oleg-shilo
Copy link
Owner

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

yao-big commented Jun 21, 2024

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

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

yao-big commented Jun 21, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants