Skip to content

vscode csx

Adam Fraser-Kruck edited this page May 31, 2025 · 22 revisions

All of the info here is about how to setup vscode to debug C# script files (.csx) and provide intellisense for them.

This is an optional step, but can be very helpful when developing your .csx files.

Install

  1. If you haven't installed dotnet-script yet, see this page.
  2. Install the official C# vscode extension.
    • DO NOT install the vscode C# Dev Kit extension.
  3. Re-enable omnisharp (see directly below).

📢 NOTE! 📢

A recent vscode c# extension update removed omnisharp (which we need). It's easy to re-enable though: https://github.com/StateSmith/StateSmith/issues/221


Improved Setup!

This is now much easier with the StateSmith.Cli tool.

  1. run ss.cli
  2. select Set up vscode for StateSmith & csx files. option.
  3. select vscode for C# script debugging and intellisense
  4. now use the vscode command pallette to run OmniSharp: Restart OmniSharp or restart vscode.
  5. troubleshooting steps below if you have issues.




Manual Setup

Recommend using ss.cli (above) if you can for this.

In your vscode project directory, run the below command.

dotnet script init delete_me_dummy_file.csx

This will update the .vscode/launch.json file to enable C# script debugging and code completion.

💡 TIP! You can improve the launch.json file here.

You can delete the delete_me_dummy_file.csx file afterwards.

rm ./delete_me_dummy_file.csx

It will also create an omnisharp.json file for vscode. The omnisharp.json file should normally not be committed to a repo (.gitignore) as different users may have different versions of dotnet installed.

image

Restart omnisharp

Now use the vscode command pallette to run OmniSharp: Restart OmniSharp or restart vscode and you should be good to go.

Select omnisharp project

If your directory has other C# projects/solutions in it, you'll likely need to tell omnisharp to look at .csx files.

Run vscode command: OmniSharp: Select Project and select CSX for the correct directory. See troubleshooting below for more details.


Troubleshooting

Troubleshooting - no intellisense for .csx files

If you've done all the above steps, you might need to tell OmniSharp which project to select.

Use the vscode command pallette to run OmniSharp: Select Project and select CSX for the correct directory.

This problem can happen if OmniSharp auto selects the a Visual Studio solution in the same directory.

omnisharp-select-project

More troubleshooting specific to just .csx files: https://github.com/StateSmith/StateSmith/wiki/csx%E2%80%90troubleshooting



More csx info

https://github.com/StateSmith/StateSmith/wiki/csx

Clone this wiki locally