Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to target Mono framework from VS2015?

I want to deploy ASP.NET web app on Linux with mono installed.

From what I know Mono is a targeting platform similar to .DNX 4.5.1 or .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. How to add Mono to that list?

like image 613
yaapelsinko Avatar asked Oct 09 '15 02:10

yaapelsinko


People also ask

How do I target multiple frameworks in C#?

To target multiple frameworks, change <TargetFramework> to plural <TargetFrameworks> and include monikers for different frameworks you want to target separated by ; . Here, we will support two more frameworks . NET Framework 4.0 & 4.6. So include net40 and net46 monikers respectively as shown below.


2 Answers

Compile from Visual Studio and target Mono

As extract from here

You can compile against Mono on Windows, from Visual studio with MonoHelper addin (using xbuild underneath).

There is also another solution, which is targeting a "Mono" .NET Framework profile from visual studio. Following steps come from here and it's for VS 2012 (but it should work for other versions).

  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)

    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

Paste the following inside 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>
like image 125
Fab Avatar answered Sep 20 '22 20:09

Fab


There was some Mono product/Mono for VS that integrates Mono into VS, but now there is none.

You should target .NET Core 5 in this case, as it is going to be the ultimate solution.

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. Even in those cases your project should target full .NET Framework just like what you do in the past. There is no Mono specific profile to target.

like image 21
Lex Li Avatar answered Sep 20 '22 20:09

Lex Li