
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.
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.cs
file.
Step-by-Step Guide to Fixing the Error
1. 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.cs
file 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
.NET
is 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
csharp
entry replaces the defaultscriptcs
command withdotnet run
.
Final Steps and Verification
- Return to your C# project.
- Open the
Program.cs
file. - 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.
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!