I'm trying to use Mono.Options under .NET Core,¹ using its command-line tools.
I initially tried loading it from NuGet using a dependency declaration in my project.json file, but dotnet restore complains that the package is not compatible with the dnxcore50 framework.²
I therefore decided to try building it from source. I noticed in the Mono.Options source code that it has a PCL build option. Thinking that maybe PCL was a close-enough approximation to .NET Core, I tried creating a DLL project to build it with that setting enabled:
{
"version": "0.0.0-d95ccb2ca5",
"compilationOptions": {
"emitEntryPoint": false,
"define": [ "PCL" ],
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23811"
},
"compile": [ "*.cs" ],
"frameworks": {
"dnxcore50": { }
}
}
I then placed a copy of Options.cs downloaded from the link above in the same directory and said dotnet build, which gives these errors:
.../Mono/Options.cs(137,22): error CS0234: The
type or namespace name 'Serialization' does not exist in the namespace
'System.Runtime' (are you missing an assembly reference?)
.../Mono/Options.cs(729,27): error CS0246: The
type or namespace name 'KeyedCollection<,>' could not be found (are you
missing a using directive or an assembly reference?)
...plus several others all stemming from those two key errors.
That finally brings me to my questions:
Why is
System.Runtime.Serializationmissing? According to the docs, it is supposed to be part of .NET Core.I later added explicit dependencies for the parent packages of the two namespaces the compiler is complaining about:
... "frameworks": { "dotnet5.4": { "dependencies": { "System.ObjectModel": "4.0.*", "System.Runtime": "4.1.0-rc2-23811" } } }dotnet restorethen succeeds, and most of the build errors go away, but the first error aboutSerializationcontinues to occur. Is .NET Core simply incomplete at this time?Is there a workaround other than just waiting for this class to be ported over?
I used
dnxcore50in the initial project file because that's howdotnet newgenerated it. The change todotnet5.4seems to be necessary according to the ASP.NET 5 package search engine, but is that change kosher with .NET Core?³
Asides
Why? Because it's 2016 and .NET still doesn't have command-line option parsing built-in. Grrrr. Maybe Microsoft's acquisition of Xamarin will result in
Mono.Optionsbeing included in .NET Core. Meanwhile...Mono.Options4.2.2.1 — released after this question was asked — solves this compatibility problem.The ASP.NET 5 package search results imply that
netcore50should also work for my purposes, but then I get complaints aboutno run-time assembly compatible with osx.10.10-x64.This is happening on an OS X 10.10 machine with Mono 4.2.1 installed.
Mono.Optionsdoes build under that, obviously. This question came up because I'm trying to switch some of my simpler existing projects to this new, lighter runtime.