point-platform / dasher

Fast, lightweight, cross platform serialisation tool
Apache License 2.0
7 stars 6 forks source link

Please support .NET Core 1.0? #21

Closed sharpe5 closed 7 years ago

sharpe5 commented 7 years ago

Thanks for the great work on Dasher!

As an aside, I created a new .NET Core 1.0 project in Visual Studio 2015, then attempted to import Dasher. It said "NU1007 Dependency specified was Dasher >= 0.8.0-rc1 but ended up with Dasher 0.8.0.". Yesterday, it said that the project was only compatible with .NET 4.5.

I managed to get my project compatible with .NET Core:

In my project.json file, I specified three builds, one per platform, it automatically put the results in the ./bin/ folder:

See: https://github.com/sharpe5/NetMQ.ReactiveExtensions/blob/master/NetMQ.ReactiveExtensions/project.json

"frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.1"
        }
      },
      "imports": "dnxcore50"
    },
    "netstandard1.6": {
      "dependencies": {
        "NETStandard.Library": "1.6.0"
      }
    },
    "net45": {
      "dependencies": {
        "System.Xml.Linq" : "*" 
      }
    }
  }

And in the .nuspec file, I specified a build per platform: https://github.com/sharpe5/NetMQ.ReactiveExtensions/blob/master/NuGet/NetMQ.ReactiveExtensions.nuspec

  <files>
    <file src="..\NetMQ.ReactiveExtensions\bin\Release\net45\NetMQ.ReactiveExtensions.dll" target="lib\net45"/>
    <file src="..\NetMQ.ReactiveExtensions\bin\Release\net45\NetMQ.ReactiveExtensions.pdb" target="lib\net45"/>
    <file src="..\NetMQ.ReactiveExtensions\bin\Release\netcoreapp1.0\NetMQ.ReactiveExtensions.dll" target="lib\netcoreapp1.0"/>
    <file src="..\NetMQ.ReactiveExtensions\bin\Release\netcoreapp1.0\NetMQ.ReactiveExtensions.pdb" target="lib\netcoreapp1.0"/>
    <file src="..\NetMQ.ReactiveExtensions\bin\Release\netstandard1.6\NetMQ.ReactiveExtensions.dll" target="lib\netstandard1.6"/>
    <file src="..\NetMQ.ReactiveExtensions\bin\Release\netstandard1.6\NetMQ.ReactiveExtensions.pdb" target="lib\netstandard1.6"/>
</files>
drewnoakes commented 7 years ago

You're very welcome.

This .NET Core/Standard stuff is still evolving, but this post from Microsoft suggests:

App Developers: You target the platform TFM you’re writing for (netcoreapp1.0, uap10.0, net452, xamarinios, etc.).

Package/Library Authors: Target the lowest netstandard version you can. You will run on all platforms that support that netstandard version or higher

This suggests a library like Dasher should target netstandard for portability, along with a full framework such as net45. Currently Dasher supports netstandard1.3 and net45. I can't recall why I didn't go lower, though there was something that failed compilation at netstandard1.2. It's possible the code can be reworked for wider support if required.

Let me know your thoughts on this. Best practice is emerging slowly.

sharpe5 commented 7 years ago

Thank you for this comment, especially the practice of package/library authors targeting the lowest netstandard that you can.

I'm going to close this issue for now, until I can complete the learning curve on other projects.

drewnoakes commented 7 years ago

No problem. It seems like a good time to start learning this stuff as it's a lot more stable now than it used to be. The last bit of churn will be the replacement of project.json with some new form of .csproj, but for now project.json is the best option for multi-targeting. Using multiple project files always felt like a cludge.