If you’re a developer working with C# in Visual Studio Code, you might encounter the “scriptcs not found” error when trying to run your program. This guide provides step-by-step instructions to fix this issue so you can seamlessly execute your code. Let’s dive into the details, ensure the environment is configured correctly, and learn how to resolve this error.
Learn how to fix the “scriptcs not found” error in Visual Studio Code for .NET SDK. Follow this detailed step-by-step guide to troubleshoot and resolve the issue efficiently.

What Causes the “scriptcs not found” Error?
The “scriptcs not found” error occurs because Visual Studio Code attempts to use scriptcs as the default executor for C# files when running code. However, .NET SDK does not rely on scriptcs for execution; instead, it uses the dotnet command. This mismatch in configurations results in the error.
This error usually appears when trying to execute or debug C# scripts inside VS Code. It means that the ScriptCS runtime (scriptcs), or the .NET SDK integration, is either not installed correctly, not recognized by the system path, or conflicting with VS Code extensions.
This guide will explain why this error happens and provide a detailed, step-by-step process to fix it. By the end, you’ll have a smooth environment where you can run C# scripts without interruptions.
What is ScriptCS?
ScriptCS is short for C# Scripting with ScriptCS. It’s a lightweight tool that allows you to write and execute C# code in script style, without creating a full Visual Studio project.
With ScriptCS you can:
- Run
.csxfiles directly. - Quickly prototype C# code like you would with Python or JavaScript REPL.
- Use C# for automation and scripting tasks.
Although .NET Core and .NET 5+ now include native support for C# interactive scripting via dotnet-script, many tutorials still reference ScriptCS. That’s why developers often run into issues in modern VS Code setups.
Why Does the “scriptcs not found” Error Occur?
There are several possible reasons:
- ScriptCS not installed
If you haven’t installed ScriptCS on your system, VS Code can’t find the command. - Path variable not updated
Even if ScriptCS is installed, the system may not recognize it because the installation folder isn’t added to your environment variables. - Using .NET Core/SDK instead of ScriptCS
Newer versions of .NET SDK usedotnet-scriptinstead ofscriptcs. Runningscriptcson such systems leads to a missing command error. - Extension conflicts
VS Code extensions like C# for Visual Studio Code (OmniSharp),dotnet-script, and ScriptCS may conflict with each other. - OS-specific installation issues
Installing ScriptCS differs slightly between Windows, macOS, and Linux. An incomplete or incorrect installation can cause the error.
Prerequisites
Before we start fixing the issue, ensure the following:
- Visual Studio Code is installed on your machine.
- .NET SDK is installed and properly configured.
- Your project folder contains a valid C# project with a
Program.csfile.
A. Check Your .NET SDK Installation
Before installing ScriptCS, make sure that .NET SDK itself is properly installed.
- Open a terminal or command prompt.
- Type:
dotnet --versionIf this shows a version number (e.g.8.0.100), then .NET SDK is installed. - If you see an error like “dotnet command not found”, then install the .NET SDK from Microsoft’s official .NET download page
B. Add ScriptCS to Your PATH
Sometimes ScriptCS installs but the system doesn’t recognize it.
- On Windows:
- Search for Environment Variables in the start menu.
- Edit System environment variables → Environment Variables.
- Under System Variables, find
Path. - Add the installation folder for ScriptCS (e.g.
C:\ProgramData\chocolatey\bin). - Restart VS Code or Command Prompt.
Step-by-Step Guide to Fixing the Error
Step 1: Configure Visual Studio Code
- Open VS Code.
- Install the extension: C# for Visual Studio Code (powered by OmniSharp).
- Install Code Runner extension if you want quick script execution.
- If using
dotnet-script, also install the C# Script extension from the marketplace. - Update VS Code settings (
settings.json):
{
"code-runner.executorMap": {
"csharp": "dotnet script"
}
}
This tells VS Code to use dotnet script instead of scriptcs.
Step 2: Install the Code Runner Extension
The Code Runner extension simplifies running code snippets and scripts directly in Visual Studio Code.
- Open Visual Studio Code.
- Navigate to the Extensions view by clicking the Extensions icon in the sidebar or pressing
Ctrl + Shift + X. - Search for Code Runner in the marketplace search bar.
- Click Install to add the extension.

Example Output:
After installation, you should see a new “Run Code” button available in your editor.
2. Open Your C# Project
- Open the folder containing your C# project in Visual Studio Code.
- Ensure your
Program.csfile is visible in the Explorer view. (Check How to Run C# project in VS Code)
Tip: If your project isn’t a valid .NET project, you may need to initialize it using
dotnet new console.
3. Run Your Program in Terminal
Before fixing the error, verify that your .NET SDK is correctly installed:
- Open the terminal in Visual Studio Code (`Ctrl + “).
- Type the command:
dotnet run - If the output of your program appears, it confirms
.NETis installed and functioning properly.

4. Update Run Code Settings
Steps to Update Run Code Settings
- Click the Settings icon in the bottom-left corner.
- From the menu, select Settings.

- In the Settings view, navigate to Extensions.
- Scroll down to locate Run Code Configuration.
- Ensure the Run in Terminal option is checked.

5. Modify the settings.json File
If the error persists, update the settings.json file to configure the correct command for running C# files.
Steps to Modify settings.json:

- Open the Command Palette (
Ctrl + Shift + P) and typesettings.json. - Press Enter to open the file.

3. Now at the bottom of the code, type “code-runner.executorMap” and press ENTER (or Select the option from dropdown)

4. In the code generated, Locate or add the following configuration:
"csharp": "scriptcs" change the above code to
"csharp": "dotnet run" 
Save the file (Ctrl + S).
Important: The
csharpentry replaces the defaultscriptcscommand withdotnet run.
Final Steps and Verification
- Return to your C# project.
- Open the
Program.csfile. - Click the Run Code button (available in the top-right corner).
- The terminal should now display the output of your program without errors.
Congratulations! The “scriptcs not found” error is resolved.
Common Troubleshooting Tips
- Issue: “scriptcs requires Mono”
→ Installmono-completepackage on Linux/macOS. - Issue: Command found but script fails
→ Ensure.csxfile extension is used, not.cs. - Issue: Extension not working in VS Code
→ Disable conflicting extensions (like multiple C# runtimes). - Issue: Path still not working
→ Restart the machine. Some OS require full restart after path changes.
When to Prefer ScriptCS vs. dotnet-script
- Use ScriptCS if:
- You’re maintaining legacy scripts.
- You specifically need ScriptCS features.
- Use dotnet-script if:
- You’re working on .NET Core, .NET 5+, .NET 6/7/8.
- You want long-term compatibility and support.
- You’re running inside modern VS Code workflows.
Conclusion
The error “command scriptcs not found” in VS Code usually stems from either a missing installation or environment path issue. By ensuring you have the right .NET SDK, properly installing ScriptCS (or switching to dotnet-script), and configuring VS Code settings, you can resolve this error quickly.
Once fixed, you’ll be able to run C# scripts in a lightweight, interactive way—perfect for prototyping, automation, or teaching.
FAQs
1. What is scriptcs in Visual Studio Code?
scriptcs is a lightweight framework for executing C# scripts. Visual Studio Code mistakenly defaults to scriptcs for running C# programs unless configured otherwise.
2. Why does the error occur?
The error occurs because .NET SDK uses the dotnet run command, while Visual Studio Code’s default Code Runner setting relies on scriptcs.
3. Can I use scriptcs instead of dotnet?
Yes, you can install scriptcs separately if you prefer, but .NET SDK is more widely used and recommended for modern C# development.
4. How do I check if .NET SDK is installed?
Run the following command in your terminal:
bashCopy codedotnet --version
If installed, it will return the version of the SDK.
5. Does this method work for macOS/Linux?
Yes! The steps are platform-independent as long as Visual Studio Code and .NET SDK are correctly installed.
By following these steps, you can easily resolve the “scriptcs not found” error in Visual Studio Code and get back to coding in C#. Happy coding!