简体   繁体   English

如何从 VS2015 定位 Mono 框架?

[英]How to target Mono framework from VS2015?

I want to deploy ASP.NET web app on Linux with mono installed.我想在安装了 mono 的 Linux 上部署 ASP.NET Web 应用程序。

From what I know Mono is a targeting platform similar to .DNX 4.5.1 or .DNX Core 5.0.据我所知,Mono 是一个类似于 .DNX 4.5.1 或 .DNX Core 5.0 的目标平台。 So I need somehow add it to targeting platforms in my project to compile and debug the project against it.所以我需要以某种方式将它添加到我的项目中的目标平台,以针对它编译和调试项目。

Surprisingly, I didn't managed to find any instructions.令人惊讶的是,我没有设法找到任何说明。 I'm creating a new ASP.NET 5/vNext project, and all I see is 4.5.1 and Core 5.0 compile targets.我正在创建一个新的 ASP.NET 5/vNext 项目,我看到的只是 4.5.1 和 Core 5.0 编译目标。 How to add Mono to that list?如何将 Mono 添加到该列表中?

Compile from Visual Studio and target Mono 从Visual Studio和目标Mono编译

As extract from here 作为从这里提取

You can compile against Mono on Windows, from Visual studio with MonoHelper addin (using xbuild underneath). 您可以在Windows上使用MonoHelper插件(使用下面的xbuild)从Visual Studio编译Mono。

There is also another solution, which is targeting a "Mono" .NET Framework profile from visual studio. 还有另一个解决方案,它是针对visual studio的“Mono”.NET Framework配置文件。 Following steps come from here and it's for VS 2012 (but it should work for other versions). 以下步骤来自这里 ,它适用于VS 2012(但它适用于其他版本)。

  1. Create two registry keys: 创建两个注册表项:

    HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\.NETFramework\\v4.0.30319\\SKUs\\.NETFramework,Version=v4.0,Profile=Mono

    HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\.NETFramework\\v4.0.30319\\SKUs\\.NETFramework,Version=v4.0,Profile=Mono

  2. Make a link to Mono directory inside of Microsoft References Assemblies Directory (you may need to run the following with administrator rights) 链接到Microsoft References Assemblies目录中的Mono目录(您可能需要以管理员权限运行以下内容)

    cd "C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.5\\Profile" mklink /d Mono "C:\\Program Files (x86)\\Mono\\lib\\mono\\4.5" cd Mono mkdir RedistList cd RedistList notepad FrameworkList.xml

  3. Edit FrameworkList.xml 编辑FrameworkList.xml

Paste the following inside FrameworkList.xml 将以下内容粘贴到FrameworkList.xml

<?xml version="1.0" encoding="utf-8"?>
<FileList  Redist="Mono-4.5" Name="Mono 4.5 Profile" RuntimeVersion="4.5" ToolsVersion="4.0" > </FileList>

There was some Mono product/Mono for VS that integrates Mono into VS, but now there is none. 有一些Mono产品/ Mono for VS将Mono集成到VS中,但现在没有。

You should target .NET Core 5 in this case, as it is going to be the ultimate solution. 在这种情况下,您应该以.NET Core 5为目标,因为它将成为最终的解决方案。

Mono does still provide some support for ASP.NET 4.* projects, but it would be difficult to assert compatibility as you need to deploy to Mono on Linux to verify. Mono仍然为ASP.NET 4. *项目提供一些支持,但由于需要在Linux上部署到Mono进行验证,因此很难断言兼容性。 Even in those cases your project should target full .NET Framework just like what you do in the past. 即使在这些情况下,您的项目也应该像过去那样以完整的.NET Framework为目标。 There is no Mono specific profile to target. 目标没有Mono特定的配置文件。

Have a look at pythonnet solution and projects which target multiple CLR runtimes: 看看pythonnet解决方案和针对多个CLR运行时的项目:

https://github.com/pythonnet/pythonnet/blob/master/pythonnet.sln https://github.com/pythonnet/pythonnet/blob/master/pythonnet.sln

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

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