C# compile with 'release' option

877 Views Asked by At

There isn't much to say, so I'll keep it short. I have been using the MonoDevelop IDE along with the 'dmcs' (aka 'mcs') for as long as I have been using Linux. However, this is the first time I consider constructing a C# program that uses input passed as an argument from command line, and so I thought I would compile my code directly from Bash. The compiler seems to generate a debug release by default, and takes a -debug option in case user wants to specify, but a -release option does NOT exist. I can just select the Release|x86 from the drop-down menu in the IDE, but my code will be compiled/run on other computers I have that don't have the IDE installed, so the only way to go about doing what I am trying to accomplish is to tell the compiler to produce a release version directly from Bash. Any help would be highly appreciated.

1

There are 1 best solutions below

0
On BEST ANSWER

You should be able to see the arguments passed to dmcs in the Build Output when you compile. The Build Output is inside the Error List window. Select View | Pads | Error List, then click the Build Output icon.

For a release build typically the two arguments that make it a release build are:

/debug- /optimize+

Mono's C# compiler has similar arguments to the Microsoft's C# compiler so the information on the MSDN could be used to understand what these arguments mean.

If you are using xbuild to compile your project then you may not see the arguments being passed. However you can drop down to the command line and run xbuild from there to see the arguments being passed:

xbuild YourSolution.sln /t:Rebuild