How do you compile a managed dll with mono/mcs targeting a specific framework?

I have been using mono/mcs to compile dynamically generated (Protocol Buffer) code into managed DLLs for use in Unity. As of Unity 5.5, it looks like it will no longer load DLLs compiled against the 4.0 framework (I believe it wants 2.0).

I have seen how to do this in MonoDevelop or Visual Studio, but I would like to do this on the command line because the protobuf code is dynamically generated so it makes it much easier to use a shell script to compile.

In the shell script we do something like this:

mono --runtime=v2.0.50727 <stuff>

mcs -langversion:ISO-2 -sdk:2 -r:$unityengine_dll -target:library -out:$output <stuff>

When we do this, we've always had warnings come up in the following form (which makes it look like the target runtime is not actually being set correctly). Even with these warnings, in Unity 5.4.x it would load the dll fine and compile. In Unity 5.5+ it doesn't seem to be able to load the dll and dies on compilation errors (where it doesn't find things which should be defined in the dll)

WARNING: The runtime version supported by this application is unavailable.
Using default runtime: v4.0.30319
No framework specified; defaulting to 4.0.30319.42000

What do we need to change? I have been playing around with the --runtime, --langversion, and -sdk -lib options of mono/mcs to no avail. What should these be set to for compiling for unity? Have also tried using both a current up-to-date version of mono to compile and also the mono that comes with Unity, both have the same issue.

Enviornment: osx sierra 10.12.3, unity 5.5, mono 4.6.2.16


看起来像我只需要将mono和mcs指向/Library/Frameworks/Mono.framework/Versions/3.12.1/中的版本,然后他们拿起正确的程序集来构建!

链接地址: http://www.djcxy.com/p/87290.html

上一篇: 通过PHP中的HTTP PUT发送文件

下一篇: 你如何编译一个托管的dll与mono / mcs针对特定的框架?