0

I'm new to programming, I'm following a programming class where we learn C# using Visual Studio on Windows.

I wanted to practice also at home on my Linux Mint PC.

I've built a simple program where the user inputs two numbers, and the program generates a random number.

When using Sublime Text Editor and executing using Mono, it works perfectly, but I would like to be able to use Visual Studio Code as it's similar to Visual Studio we are using at school. However, it seems to be a complete mess to install on a Linux machine. I've followed tons of links and installed extensions and everything, and even tried to follow instructions given on users here who had the same issue, but I can't understand them and well it doesn't work. I just get on a link that tells me to go to another link which also tells me to go to another link, and I'm just totally confused on what exactly I need to do.

using System;
class random
{
  static void Main(string[] args)
  {
      Random rnd = new Random();
      Console.WriteLine("Entrez le nombre minimum: ");
      int minimum = Convert.ToInt32(Console.ReadLine());
      Console.WriteLine("Entrez le nombre maximum: ");
      int maximum = Convert.ToInt32(Console.ReadLine());
      int num = rnd.Next(minimum, maximum);
      Console.WriteLine($"Le nombre aléatoire choisi est: {num}.");
  }
}

returns following message:

[Running] scriptcs "/home/pc/Codes/C#/random.cs"
/bin/sh: 1: scriptcs: not found

[Done] exited with code=127 in 0.026 seconds

Thanks for your help!

  • To help us answer, please describe what you've been able to do successfully and the step at which things are failing. For example, it sounds like you've installed Visual Studio Code successfully and you're able to open your project using it, but it's failing when building the project? Are you using the `dotnet run` command or something else to build / run the project? Sharing all the output after that command rather than just the last bit will also help. It doesn't look like a problem with your code. – sbridewell Feb 15 '22 at 16:49
  • Hi @sbridewell. When I click on Run Code in Visual Studio Code, the only output I get is [Running] scriptcs "/tmp/tempCodeRunnerFile.csharp" /bin/sh: 1: scriptcs: not found [Done] exited with code=127 in 0.009 seconds I went on discoverdot,net to see how to install scriptcs. It tells me to use Chocolatey, but the instructions they give are Windows powershell instructions and not Linux command line instructions. So, I'm stuck there. – thefrenchnoob Feb 18 '22 at 14:48
  • Have you tried navigating to the project folder either in VS Code's terminal window, or in a separate terminal window, and running the `dotnet run` command? If so, what happens? You may find https://code.visualstudio.com/docs/languages/csharp helpful – sbridewell Feb 18 '22 at 17:08
  • It tells me there are no project to execute. Verify if there is a project. I'm sure I'm in the right directory, there are files in there. – thefrenchnoob Feb 20 '22 at 14:54
  • Following your link, I got on this page https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger.md I don't understand Step 3. I don't see any prompt. Is there a full tutorial that exists somewhere on one single page without having to click multiple links that explain how to be able to code in C# on VisualCode on Linux? A link brings to a new link that brings to a new link and it's just not working, it's very confusing. – thefrenchnoob Feb 20 '22 at 15:07
  • The `dotnet run` command needs to be run from the folder containing a (something).csproj file - that's the project file which tells the compiler where to find your source code and how to compile it.. – sbridewell Feb 21 '22 at 16:52
  • You may find this video helpful https://www.youtube.com/watch?v=WeTesTCzep0 - it walks through everything including installing VS code, installing the C# extension (the step 3 that you're struggling with), creating, running and debugging a hello world program. The only thing to watch out for is that it mentions a project.json file at one point - that's an idea Microsoft were thinking of a few years ago to replace .csproj files, but they seem to have abandoned the idea and stuck with .csproj files. The rest of the video looks sound to me. – sbridewell Feb 21 '22 at 17:10
  • Thank you! Now it finally works. What I did, I used the purge command to completely remove everything related to Visual Code. I went into my home folder, displayed the hidden files, deleted the config and the extensions files and started back from scratch, following the steps on the tutorial. – thefrenchnoob Feb 23 '22 at 15:08
  • Glad you got it working :-) If you feel like you've learned something useful, please consider posting it as an answer to help others who might be facing the same problem. It's fine to answer your own question - see https://stackoverflow.com/help/self-answer – sbridewell Feb 24 '22 at 19:51

0 Answers0