开发者

how do I compile with mono targetting C# / .net 4

开发者 https://www.devze.com 2023-04-09 11:49 出处:网络
I have an installation of mono 2.10.4 on linux and have been attempting to compile a .NET C# 4dependent codebase.I have been able to compile in MonoDevelop, but need to be able to do from the command

I have an installation of mono 2.10.4 on linux and have been attempting to compile a .NET C# 4 dependent codebase. I have been able to compile in MonoDevelop, but need to be able to do from the command line / build tool.

executing:

gmcs -langversion:4 -target:library -out:foo.dll ... <sources>

produces the following error:

error CS1617: Invalid -langversion option `4'. It must be `ISO-1', `ISO-2', `3' 
or `Default'

The compiler version gmcs --version:

Mono C# compiler version 2.10.4.0

Further notes:

  1. ubuntu 11.04
  2. install开发者_高级运维 in /opt/mono-2.10
  3. mono install first in path


I think you want to run dmcs instead of gmcs. From the CSharp Compiler page:

Starting with Mono version 2.6 a new compiler dmcs is available as a preview of C# 4.0 (a preview since Mono 2.6 will ship before C# 4.0 is finalized).

(That's a little out of date as I'm now running 2.10.5.0, but never mind.)

EDIT: Alternative, use mcs as specified here, as you're running 2.10.

It doesn't support a specific -langversion of 4, but then neither does the Microsoft compiler:

/langversion:<string>      Specify language version mode: ISO-1, ISO-2, 3,
                           or Default
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号