Thoughts on handling errors when running terminal commands in vscode's Code Runner plug-in, scriptcs' is not recognized as an internal or external command

  This time I encountered a problem running the c# script. VS was too big, so I wanted to use vscode to run it. The result was that 'scriptcs' is not recognized as an internal or external command. I was thinking that the environment had already been configured when the .net file was installed, so I looked for a lot of posts, and some said to use dotnet install, but it didn't work. I found that code runner actually helps you complete the process of transmitting a command to the cmd terminal. C# defaults to sending commands in the form of scriptcs plus file name in code runner.

In fact, the problem is solved by using the dotnet run filename command.

Therefore, the solution to the problem is very simple, that is, modify the configuration file in the code runner. The command of the configuration file in code runner can be modified like this:

First of all, you can ensure that it can run normally in cmd, but there is a problem with running instructions in vscode.

Enter the code runner's extended settings.

First make sure code runner:run in terminal is turned on.

Find code-runner:Executor Map and select "Edit in setting.json"

Then add code-runner.executorMap.

The entire instruction set can be found in this, so this can be used to modify all instructions that need to be run. Since this time I am changing to c#, I found the csharp modification instruction and changed it to:

"csharp": "cd $dir && dotnet run $fileName",

problem solved!

The main purpose here is to modify the running instructions of the code runner. This method is not only used for c#, but can also be used for other languages ​​​​that use the code runner to run. Detailed analysis of specific issues is required!

Guess you like

Origin blog.csdn.net/weixin_45987528/article/details/132921639