简体   繁体   中英

Getting error of scriptcs when trying to run C# code in VS Code in Ubuntu 20.04

[Running] scriptcs "/home/yash/netcore/netcore/Program.cs" /bin/sh: 1: scriptcs: not found

[Done] exited with code=127 in 0.012 seconds

You need to install mono-complete if you want to run software for Mono or Microsoft .NET which you are not installing from a Debian package.

Then, nstall mono-complete. In all currently supported versions of Ubuntu open the terminal and type:

sudo apt install mono-complete

Save your C# code in a file called hello.cs. Example hello.cs code is: Make hello.cs executable. Right-click the hello.cs file -> select Properties -> Permissions tab -> put a checkmark to the left of Allow executing file as program.

Change directories using the cd command to the directory that contains the hello.cs file.

Use the mcs compiler and create a Windows executable named hello.exe from the source hello.cs:

mcs -out:hello.exe hello.cs

Run the hello.exe program with mono:

mono hello.exe

The results of running your program in step 6. should be:

Hello World!

Press Enter to exit back to a default terminal prompt.

Decompile the executable file.

monodis --output=decompiled-hello.txt hello.exe

Your code probably is not compiling as you didn't install or set the compiler on your computer. You need to install Run Time Compile for C# and .NET Core SDK, then use the terminal to run your code. Here some instructions that could help you set this up https://almirvuk.blogspot.com/2016/09/run-and-compile-c-in-visual-studio-code.html . Otherwise, you can install Visual Studio, which will take care of its own for compiling when you Run your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM