1

我的 settings.json

"code-runner.ignoreSelection": true,    
"code-runner.executorMap": {
    "javascript": "node",
    "php": "php",
    "python": "python -u",
    "powershell": "powershell -ExecutionPolicy ByPass -File",
    "csharp": "scriptcs -script",
    "vbscript": "cscript //Nologo",
    "typescript": "ts-node",
    "coffeescript": "coffee",
    "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
    "scss": "scss --style expanded"
},
"code-runner.runInTerminal": true,

在终端:

PS C:\Users\avaa1\Desktop\Projeto\ConsoleProject> scriptcs -script "c:\Users\avaa1\Desktop\Projeto\ConsoleProject\Program.cs" scriptcs : O termo 'scriptcs' não é reconhecido como nome de cmdlet, função,arquivo de script ou programa operável。Verifique a grafia do nome ou, se um caminho tiver sido incluído, veja se o caminho está correto etente novamente。没有 linha:1 caractere:1

  • scriptcs -script "c:\Users\avaa1\Desktop\Projeto\ConsoleProject\Progr ...
  •   + CategoryInfo          : ObjectNotFound: (scriptcs:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
4

4 回答 4

1

在 VS Code 中转到设置,搜索“Code-runner:Executor Map”,您会在 JSON 中找到“Edit in settings.json”打开“settings.json”,输入以下脚本:

 "code-runner.executorMap": {

    "javascript": "node",
    "php": "C:\\php\\php.exe",
    "python": "python",
    "perl": "perl",
    "ruby": "C:\\Ruby23-x64\\bin\\ruby.exe",
    "go": "go run",
    "html": "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\"",
    "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
    "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    
    "csharp": "cd $dir && dotnet run",
   
},
于 2021-11-16T09:29:38.773 回答
1

您可以配置代码运行器以使用命令“dotnet run”运行,如下所示:

"csharp": "dotnet run"

还要确保将代码运行器配置为在终端中运行。

"code-runner.runInTerminal": true
于 2021-05-03T15:04:09.123 回答
0

第 1 步:首先你应该从这里安装 cs-script

第 2 步:确保已安装 cs-script,打开终端并输入css

第 3 步:打开 VS Code settings.json文件 [ VS Code:如何打开 settings.json 文件?]

第 4 步:在文件末尾添加以下行(注意:如果“code-runner.executorMap”配置已经存在,那么您只需复制和粘贴/替换即可 "csharp": "cd $dir && css $fileName"

"code-runner.executorMap": {
      "csharp": "cd $dir && css $fileName",
}
于 2022-02-05T07:43:59.947 回答
-1

you can run your code in terminal by using this command:

dotnet run

(make sure your terminal url must be in the project directory)

于 2021-02-01T17:21:27.863 回答