Understanding .Net Core and Mono

2019-07-17 00:31发布

  1. When developing an application in .Net Core, the .NET dependencies and DLLs are embedded in the application? does this mean that I do NOT need to install the .Net dependencies on the client PC?
  2. If I develop a .Net Core console application for Linux, is it necessary to install Mono on the PC with Linux (client)?
  3. Are .Net core applications compatible with Android?

2条回答
Melony?
2楼-- · 2019-07-17 00:45

To your question:

No the dependencies are NOT embedded in the application (no static linking in .NET).
Yes, the dependencies are added as separate files, when you publish (self-contained).
If your application is a .NET-Core application, you do NOT need the .NET-Core framework installed. Neither do you need Mono.
You can do a self-contained deployment for each platform:

Windows-x86-32:

dotnet restore -r win-x86
dotnet build -r win-x86
dotnet publish -f netcoreapp2.0 -c Release -r win-x86

Windows-x86-64:

dotnet restore -r win-x64
dotnet build -r win-x64
dotnet publish -f netcoreapp2.0 -c Release -r win-x64

Linux-x86-32: NOT SUPPORTED BY .NET-Core

Linux-x86-64:

dotnet restore -r linux-x64
dotnet build -r linux-x64
dotnet publish -f netcoreapp2.0 -c Release -r linux-x64

Linux ARM (Android/ChromeOS)

dotnet restore -r linux-arm
dotnet build -r linux-arm
dotnet publish -f netcoreapp2.0 -c Release -r linux-arm

Linux-arm-64: NOT SUPPORTED BY .NET-Core

This adds all dependencies, including the .NET-Core runtime libraries. You can still run into problems if a used DLL references a native-dll (that it provides as embedded resource), but does not provide the necessary C-Runtime-libraries (e.g. when the native-dll/.so is dynamically linked - such as in SkiaSharp).

Also, .NET-Core can be run with the shared-framework, which means deployment size is smaller, but the shared-framework-version must be installed, then.

  1. Since Android is linux - and you're not having an Android that runs on an x86-32 processor or an ARM-64 processor, .NET-Core should be Android-compatible. I never tested that premise. Might entail bugs. ARM-support is sketchy.

However, it is unclear to me what you want to do with .NET Core on Android. Since .NET does not implement any Android-UI interfaces. Xamarin-Forms might support Android-UI with .NET-Core - it certainly does with mono. You could however run a web/other-server on Android, or a console application.

See CoreDroid

查看更多
等我变得足够好
3楼-- · 2019-07-17 00:55

Mono and .NET Core are two separate technologies.

Mono was created by Miguel de Icaza and was originally designed to be a version of .NET Framework for Linux and MacOS. As such, it has a lot of the same APIs that .NET Framework has.

.NET Core is a cross platform implementation of .NET Standard. As such, it only has access to the APIs outlined in the .NET Standard.

Applications built using .NET Core will need the .NET Core run-time to be installed on the target machine in order to run them (depending on whether you do a self contained deploy or a framework dependant deployment). The .NET Core run-time and SDK can be obtained by heading to dot.net/core.

In the same way, applications built with Mono will require the Mono run-time to be installed on the target machine.

As Lexi-Li pointed out, I would take a look at The official documentation for .NET Core in order to learn more about the different deployment options.

查看更多
登录 后发表回答