简体   繁体   English

从Windows编译macOS / CentOS的Mono应用程序

[英]Compiling a mono application from windows for macOS/CentOS

Can I compile a C# mono project from Windows for Mac and for CentOS directly? 我可以直接从Windows for Mac和CentOS编译C#mono项目吗? I saw a Video. 我看了一个录像带。 The author installed Mono on Mac/Linux and used the parameter 'Mono Project' to run it on the platform. 作者在Mac / Linux上安装了Mono,并使用参数“ Mono Project”在平台上运行它。 Does the application become compiled on Mac/Linux or does the app run in the Mono environment? 该应用程序是在Mac / Linux上编译的,还是在Mono环境中运行?

Assuming that your code is only "managed code" (ie C# or similar compiling to IL), you should be fine to build on one operating system and run on another, so long as that operating system supports all the libraries you're using. 假设您的代码只是“托管代码”(即C#或类似的IL编译),则可以在一个操作系统上构建并在另一个操作系统上运行,只要该操作系统支持您正在使用的所有库即可。 That's the case even if you're using libraries that themselves contain native code, assuming it's been bundled correctly. 即使您使用的是本身包含本机代码的库(假设已正确捆绑),也是如此。

It becomes trickier if your own code includes native code (eg C++) - at that point you'd need to cross-compile for each operating system and architecture you're targeting. 如果您自己的代码包含本机代码(例如C ++),则将变得更加棘手-那时,您需要针对要定位的每个操作系统和体系结构进行交叉编译。 That's less likely to be the case though. 不过,这种情况不太可能发生。 If you're doing it, you're likely to know you're doing it :) 如果您正在执行此操作,则可能会知道自己正在执行此操作:)

Note that you'll need to work out what you need to ship with your application in terms of libraries etc, and what the requirements are in terms of Mono or .NET Core already being installed. 请注意,您需要确定需要使用库等附带的应用程序,以及已经安装的Mono或.NET Core的要求。

Unless you need Mono-specific libraries, I'd personally suggest using .NET Core at this stage rather than Mono. 除非您需要Mono特定的库,否则我个人建议在此阶段使用.NET Core而不是Mono。 Mono's currently the best solution for mobile deployment (Xamarin, Unity) but if you only need to run on desktops, and you're not using any Mono libraries, I find .NET Core to be a more polished experience. Mono是目前最适合移动部署(Xamarin,Unity)的解决方案,但是如果您只需要在台式机上运行,​​并且不使用任何Mono库,我发现.NET Core会带来更完美的体验。

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

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