Alexsandro Andrade
Alexsandro Andrade

Reputation: 11

How can I configure VS Code to run C# with Code Runner?

My 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,

In Terminal:

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 e tente novamente. No linha:1 caractere:1

Upvotes: 1

Views: 10009

Answers (3)

Harish D
Harish D

Reputation: 41

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",
   
},

Upvotes: 4

Jhunnior22
Jhunnior22

Reputation: 11

You can configure code runner to run with the command "dotnet run" like this:

"csharp": "dotnet run"

Also make sure that code runner is configured to run in the terminal.

"code-runner.runInTerminal": true

Upvotes: 1

Amirhossein Azhdari
Amirhossein Azhdari

Reputation: 189

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

dotnet run

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

Upvotes: 0

Related Questions