xyncro / chiron

JSON for F#
https://xyncro.tech/chiron
MIT License
173 stars 41 forks source link

Support .NET Core #76

Closed kuznero closed 5 years ago

kuznero commented 7 years ago

Hello!

It would be great to support .NET Core that is getting more and more mature these days.

There is unfortunately the dependency to FParsec, they also got an issue raised on BitBucket: https://bitbucket.org/fparsec/main/issues/38/support-net-core

Thanks in advance!

neoeinstein commented 7 years ago

But alas, you can use Chiron from .NET Core. Chrion is a portable library, which means that it is compatible with .NET Standard 1.0. You may need to modify the imports on your project.json file as in this gist. FParsec is similarly a portable library so you can use that library from .NET Core as well.

kuznero commented 7 years ago

But it does not support netcoreapp1.0 as far as I can understand. Here is the log from dotnet restore:

log  : Restoring packages for C:\Projects\Lambda\app\Lambda\project.json...
log  : Restoring packages for tool 'dotnet-compile-fsc' in C:\Projects\Lambda\app\Lambda\project.json...
error: Package Chiron 6.2.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Chiron 6.2.0 supports:
error:   - net40 (.NETFramework,Version=v4.0)
error:   - portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
error: Package Aether 8.0.2 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Aether 8.0.2 supports:
error:   - net35 (.NETFramework,Version=v3.5)
error:   - portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
error: Package FParsec 1.0.1 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package FParsec 1.0.1 supports: net40-client (.NETFramework,Version=v4.0,Profile=Client)
error: One or more packages are incompatible with .NETCoreApp,Version=v1.0.
log  : Writing lock file to disk. Path: C:\Projects\Lambda\app\Lambda\project.lock.json
log  : C:\Projects\Lambda\app\Lambda\project.json
log  : Restore failed in 2592ms.

And here is the original project.json:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": false,
    "compilerName": "fsc",
    "compile": {
      "includeFiles": [
        "Config.fs",
        "Common.fs",
        "Connection.fs",
        "Logger.fs",
        "HealthReporter.fs",
        "Process.fs",
        "Service.fs",
        "Lambda.fs"
      ]
    }
  },
  "tools": {
    "dotnet-compile-fsc":"1.0.0-preview2-*"
  },
  "dependencies": {
    "Chiron": "6.2.0"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.1"
        },
        "Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629"
      }
    }
  }
}

If I add netstandard1.0, netstandard1.3 or netstandard1.6 to my project.json even then dotnet restore is unable to restore Chiron, Aether and FParsec.

Maybe I am doing something wrong?

neoeinstein commented 7 years ago

In your frameworks section you need to include an imports as shown in the previously mentioned gist.

netcoreapp1.0 can consume any library compatible with netstandard1.6 or less, and Profile259 fits that bill. See this table of framework relationships under the Specification, PCL Compatibility headers: https://docs.microsoft.com/en-us/dotnet/articles/standard/library

neoeinstein commented 7 years ago

One thing that I didn't mention that is called out in that .NET Standard link is that I also added a dependency on Microsoft.NETCore.Portable.Compatibility. That's also called out in the gist file, and provides the "glue" that fits the profile-based PCLs in with the .NET Standard PCLs.

aggieben commented 7 years ago

Since the tooling released, projects are now in an updated MSBuild format and imports are specified using the PackageTargetFallback property. PCLs are supported.

However, it is inconvenient to use the library like this, because any project that uses the library then imposes the need to use a PackageTargetFallback on any other consuming project, which is obviously not an ideal user experience.

I would like to see this library target netstandard1.0 to resolve this issue.

neoeinstein commented 7 years ago

This should be fixed soon. We have an alpha build on top of netstandard1.6. We need to get FParsec set with a stable release before we can make a Chiron stable release. We can't target 1.0 because FSharp.Core targets 1.6.

See PR #81

aggieben commented 7 years ago

@neoeinstein yep, I stumbled on that right after posting my comment :-) Glad to see the new work. edit: moved remark to PR.

ptrelford commented 7 years ago

@neoeinstein RE FParsec dependency, I've put together a small change set that removes the FParsec dependency, replacing it with a small hand rolled parser, see this fork... https://github.com/ptrelford/chiron

ninjarobot commented 6 years ago

The .NET Core world has moved quite a bit since this, and FParsec and Aether both have .NET Standard 1.6 packaging now. Would a PR to do a packaging-only update to use the new SDK and publish for more frameworks be accepted and is anyone here able to deploy a small incremental release to nuget?

ninjarobot commented 6 years ago

Until Chiron 7 is out, this is a repackaging with the current codebase: https://github.com/xyncro/chiron/pull/94/files

panesofglass commented 5 years ago

This is now resolved with the release of 6.3.0 (at least).