You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置VSCode的CodeRunner解决‘scriptcs未被识别’报错

Fixing "'scriptcs' is not recognized" in VS Code Code Runner for C#

Got it, let's get that Code Runner working for your C# code instead of hitting that annoying "scriptcs not recognized" error. Here are a couple of practical solutions tailored to how you write C#:

Solution 1: Use dotnet run for full .NET projects (integrate your existing workflow)

If you're working with a proper .NET project (has a .csproj file), we can configure Code Runner to run the same dotnet run command you already use manually:

  • Open VS Code settings with Ctrl + , (Windows/Linux) or Cmd + , (Mac)
  • Search for Code Runner: Executor Map, then click "Edit in settings.json"
  • Find the "csharp" entry in the JSON object, and replace its value with:
    "csharp": "cd $dir && dotnet run"
    
  • Save the settings file, restart VS Code, and try running your code again. Code Runner will now switch to your project directory and execute dotnet run just like you do in the terminal.

Solution 2: Use dotnet script for single C# files (no .csproj needed)

If you often write standalone .cs scripts without a full project, dotnet script is the modern, official alternative to scriptcs:

  1. First, install the dotnet-script tool globally via your terminal:
    dotnet tool install -g dotnet-script
    
  2. Head back to Code Runner's Executor Map settings (same steps as Solution 1) and update the "csharp" entry to:
    "csharp": "dotnet script $fullFileName"
    
  3. Save, restart VS Code, and you can now run single .cs files directly via Code Runner without any project setup.

If you really want to stick with scriptcs (though it's less maintained than .NET's official tools), you'll need to:

  • Download the scriptcs installer for your OS from its official distribution page
  • Add the directory containing the scriptcs executable to your system's PATH environment variable
  • Restart VS Code so it picks up the updated PATH entry

After any of these solutions, test running your C# code with Code Runner's play button—you should be good to go!

内容的提问来源于stack exchange,提问作者myfunnyfella

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:51:44