How do I build a C# file through Mono on Linux command line?
c#, linux, mono
Solution
You should use `gmcs` in order to compile your code, and `mono` to execute the interpreter, as one use `javac` and `java` commands.
You may reread the mono basics:
Let's say you have a C# file with the following code:
using System;
public class HelloWorld
{
static public void Main ()
{
Console.WriteLine ("Hello Mono World");
}
}
Compiling within the shell:
gmcs hello.cs
Executing it from the shell:
mono hello.exe
Problem
I wrote a simple Hello World program in C# using Visual Studio 2013. I tried to compile it on the command line in Linux using: ``` mono --aot test.cs ``` However when I do that, I get the error: ``` Cannot open assembly 'test.cs': File does not contain a valid CIL image. ``` The file is just a typical C# console application using the default template that Visual Studio gives you.