简体   繁体   English

配置Visual Studio 2012以使用Mono的C#编译器代替默认的csc.exe

[英]Configure Visual Studio 2012 to use Mono's C# compiler instead of the default csc.exe

I work in a game engine called Unity3D whose scripting system runs on Mono. 我在一个名为Unity3D的游戏引擎中工作,该引擎的脚本系统在Mono上运行。 By default Unity uses a modified version of Mono to develop/compile script. 默认情况下,Unity使用Mono的修改版本来开发/编译脚本。 I am in the process of setting up my Visual Studio to better work with Unity projects and its various gotchas with regards to .NET. 我正在设置Visual Studio,以更好地使用Unity项目及其有关.NET的各种陷阱。

I am currently stuck trying to configure Visual Studio to handle compilation of my various assemblies. 我目前无法尝试配置Visual Studio来处理各种程序集的编译。 Unity uses a modified version of an old Mono compiler, and as such I cannot use the default csc.exe to build assemblies. Unity使用的是旧版Mono编译器的修改版,因此,我无法使用默认的csc.exe来生成程序集。

My ideal solution would be for Visual Studios's Build Solution option to process my projects with a compiler I point it to, perhaps through configuring the MSBuild (.csproj) file? 对于Visual Studios的“ 构建解决方案”选项,我的理想解决方案是使用我指向它的编译器处理我的项目,也许是通过配置MSBuild(.csproj)文件? Falling short of this is there another way I can build from within Visual Studio using Mono's mcs/gmcs compiler? 达不到这个要求,我还有另一种方法可以使用Mono的mcs / gmcs编译器在Visual Studio中进行构建吗?

One approach would be to write an MSBuild/PSake script that you could run via a shortcut key from within VS. 一种方法是编写一个MSBuild / PSake脚本,您可以通过VS中的快捷键来运行该脚本。 I've written a blog post about hooking a build script up via a shortcut key . 我写了一篇有关通过快捷键连接构建脚本的博客文章。 Basically, you would write a batch file that executes the MSBuild script and assign a keyboard shortcut to it, say ALT-1. 基本上,您将编写一个执行MSBuild脚本的批处理文件,并为其指定键盘快捷键,例如ALT-1。 You would then hit ALT-1 instead of CTRL-SHIFT-B to compile the project. 然后,您将按ALT-1而不是CTRL-SHIFT-B来编译项目。

I did a project where Unity was running on my Mac and ran Windows/VS2008 on Parallels. 我做了一个在Mac上运行Unity并在Parallels上运行Windows / VS2008的项目。 In my Visual Studio solution I referenced the appropriate Mono dlls instead of the normal .NET dlls (ie System, System.Xml, etc.) and used the typical .. I also wrote all my unit tests using the nUnit dlls provided with the Mono distribution. 在我的Visual Studio解决方案中,我引用了适当的Mono dll,而不是普通的.NET dll(即System,System.Xml等),并使用了典型的..我也使用Mono提供的nUnit dll编写了所有单元测试。分配。 Since Unity is (or at least was) using just the .cs files, simply copying (via Post Build Script) them into my Unity project structure worked great. 由于Unity仅(或至少曾经)仅使用.cs文件,因此只需简单地将它们复制(通过后期生成脚本)到我的Unity项目结构中即可。 Unity would detect the change and update the scripts. Unity将检测到更改并更新脚本。 This method was very effective, however I was using it about 2 years ago so I'm not sure if it still applies. 这种方法非常有效,但是大约2年前我就在使用它,所以我不确定它是否仍然适用。

In addition it appears that someone went through the trouble of making a video on how to do this: http://forum.unity3d.com/threads/120327-Video-Tutorial-How-to-use-Visual-Studio-for-all-your-Unity-development 此外,似乎有人在制作有关如何执行此操作的视频时遇到了麻烦: http : //forum.unity3d.com/threads/120327-Video-Tutorial-How-to-use-Visual-Studio-for-你们所有的团结发展

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM