[英]How to configure Vs Code to run Csharp(C#) with Code Runner?
我的設置。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
+ CategoryInfo: ObjectNotFound: (scriptcs:String) [], CommandNotFoundException + FullyQualifiedErrorId: CommandNotFoundException
您可以使用以下命令在終端中運行代碼:
dotnet run
(確保您的終端 url 必須在項目目錄中)
您可以配置代碼運行器以使用命令“dotnet run”運行,如下所示:
"csharp": "dotnet run"
還要確保將代碼運行器配置為在終端中運行。
"code-runner.runInTerminal": true
In VS Code Go to Settings, Search for " Code-runner:Executor Map " There you find " Edit in settings.json " open " settings.json " inside JSON put the following Script:
"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",
},
第 1 步:首先你應該從這里安裝 cs-script
第 2 步:確保已安裝 cs-script,打開終端並輸入css
第 3 步:打開 VS 代碼settings.json文件 [ VS 代碼:如何打開 settings.json 文件? ]
第 4 步:在文件末尾添加以下行(注意:如果“code-runner.executorMap”配置已經存在,那么您只需復制和粘貼/替換"csharp": "cd $dir && css $fileName"
)
"code-runner.executorMap": {
"csharp": "cd $dir && css $fileName",
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.