简体   繁体   English

如何使用 Mono 的 mcs 来编译和运行 csproj 文件?

[英]How can you use Mono's mcs to compile and run a csproj file?

I'm a Unix guy who needs to try and compile some C# code for work.我是一名 Unix 专家,需要尝试编译一些 C# 代码才能工作。 I've downloaded Mono for Mac, and the mcs command line tool.我已经下载了适用于 Mac 的 Mono 和 mcs 命令行工具。 There's a csproj file attached to this library which contains XML with all of the files I need to compile.该库附加了一个 csproj 文件,其中包含带有我需要编译的所有文件的 XML。

Can Mono/mcs read this csproj file and generate a DLL from it? Mono/mcs 可以读取这个 csproj 文件并从中生成 DLL 吗?

If you don't want to use MonoDevelop and want to use the command-line, you can use xbuild.如果你不想使用 MonoDevelop 而想使用命令行,你可以使用 xbuild。 xbuild is the Mono equivalent of MSBuild. xbuild 是 MSBuild 的 Mono 等价物。

xbuild /p:Configuration=Release HelloWorld.csproj

The easiest way is to head over to monodevelop and download their IDE.最简单的方法是前往monodevelop并下载他们的 IDE。 It can open project files generated by Visual Studio.它可以打开由 Visual Studio 生成的项目文件。

Now you can also use the convenience of aptitude as below:现在您还可以使用 aptitude 的便利,如下所示:

sudo apt-get install monodevelop mono-gmcs

This question is old and answers are deprectated.这个问题很旧,答案已被弃用。 I succeed to generate and run DLL from a csproj by following theses steps:我通过以下步骤成功地从 csproj 生成并运行 DLL:

Then, use dotnet build YourProject.csproj to compile the project and dotnet run YourProject.csproj to run it.然后,使用dotnet build YourProject.csproj编译项目并使用dotnet run YourProject.csproj运行它。

For Ubuntu, and probably other Debian-based distributions:对于 Ubuntu,可能还有其他基于 Debian 的发行版:

sudo apt-get install monodevelop mono-gmcs

( mono-gmcs may be needed to compile .net 2.0 or 3.5 projects) (编译 .net 2.0 或 3.5 项目可能需要mono-gmcs

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

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