Skip to content

Instantly share code, notes, and snippets.

@glennblock
Last active January 19, 2021 17:51
Show Gist options
  • Save glennblock/b1cc0446abae0ba9127b094e9607751c to your computer and use it in GitHub Desktop.
Save glennblock/b1cc0446abae0ba9127b094e9607751c to your computer and use it in GitHub Desktop.
Debugging with scriptcs in VS Code

scripts debugging in VS Code!

Pre-requisites

  1. Install latest mono here (don't use brew) http://www.mono-project.com/docs/getting-started/install/mac/
  2. Clone the dev branch of scriptcs or download from here
  3. Run brew_build.sh in the scriptcs folder this will build the scriptcs binaries into scriptcs\artifacts
  4. Install Visual Studio Code.
  5. Open VS code and install the Mono Debug extension.

Debugging

  1. Open Visual Studio code
  2. Open in VS Code the folder that contains the script you want to debug.
  3. Add a break point in the main script or in a child script.
  4. Click Debug.
  5. Click the play arrow next to Debug
  6. Select C# Mono in the drop down. This will create a launch.json.
  7. For "program" put the location of your scriptcs.exe. Use $root$/scriptcs/src/scriptcs/bin/debug/scriptcs.exe replacing $root$ with the folder that your cloned scriptcs repo lives in.
  8. For "args" put ["$script$.csx","-D"] replacing $script$ with the main script file.

Here is an example launch.json showing how it should look

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "mono",
            "request": "launch",
            "program": "/Users/glennblock/src/scriptcs/src/scriptcs/bin/debug/scriptcs.exe",
            "args": ["test.csx","-D"],
            "cwd": "${workspaceRoot}",
            "preLaunchTask": "",
            "runtimeExecutable": null,
            "env": {},
            "externalConsole": false
        },
        {
            "name": "Attach",
            "type": "mono",
            "request": "attach",
            "address": "localhost",
            "port": 55555
        }
    ]
}

Below is a screenshot showing a simple script being debugged in Visual Studio Code running on a mac

screen shot 2017-04-14 at 9 56 39 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment