.NET Standard 2.1 adds a lot of new stuff I would like to use from a project targeting .NET Core 3 and Mono 6+. I can get the .NET Standard 2.1 libraries built easily enough, but I can't find a single TFM that I can use for the executable references the .NET Standard 2.1 libraries.
I can target .NET Core 3, but then I get extra libraries in there mono doesn't have, so I have to be careful never to use any of the unsupported functions.
I can't target .NET 4.8 or any framework library. This works in Mono, but can't link to the Net Standard 2.1 libraries.
Does there exist a runtime framework I can target that has all the .NET Standard 2.1 functions but none of the .NET Core 3 functions?
Framework 4.8 implements Standard 2.0 + additional framework only functions
.net core implements Standard 2.0 + the extras from .net standard 2.1 + additional Core only functions
Any gaps must be provided by the libraries you include in your project. Some things are inherently incompatable due to different design decisions.
These are by-design compatibility divergences. If you wish to target both core and framework, you can only directly use 2.0. In some circumstances you can target Framework, if you can have shim libraries to provide the missing implementations for the "additional framework only functions" for when you run under core
I don't actually wish to target framework though. The announcement info for standard 2.1 said mono was compatible, which I can tell it is because if I run a core app with those functions it works.
https://docs.microsoft.com/en-us/dotnet/standard/net-standard
The main documentation even says Mono 6.4 is supported. I just can't figure out how to target that specific runtime.
You can't target Mono because it doesn't have a separate TFM (target framework moniker) on the desktop. This means the same limitations apply as for .NET Framework when you compile a library even though it would actually run fine on the Mono runtime.
If that is the case, then that page I linked above should be updated so say Mono cannot support .NET Standard 2.1. Because there is no way to actually run something targeting .NET Standard 2.1 without targeting Core, which is definitely not something recommended.
Mono can load and run .NET Standard 2.1 libraries, the issue is in producing an executable that can reference said libraries :)
It's basically outside of Mono's control since MSBuild/nuget is preventing you from doing this (if you compiled with csc directly and passed the right reference assemblies it would work).
I agree that the docs page should add a remark about this.
I actually got it to work by setting a project targeting .NET Standard 2.1 to OutputType exe, and Mono will actually start the resulting dll. Interesting.
@akoeplinger Is this still the case? Can the documentation please be updated, including this page?
I'm interested in this as well; using a .netstandard2.1 library from a Mono application is something I would very much like to be able to do. Running the application as a published .netstandard2.1 assembly technically works, but I'm getting (in my use case) VTable setup errors from System.Text.Json, which I assume is due to type redirections not working properly.
Most helpful comment
Mono can load and run .NET Standard 2.1 libraries, the issue is in producing an executable that can reference said libraries :)
It's basically outside of Mono's control since MSBuild/nuget is preventing you from doing this (if you compiled with
cscdirectly and passed the right reference assemblies it would work).I agree that the docs page should add a remark about this.