jingwood / d2dlib

A .NET library for hardware-accelerated, high performance, immediate mode rendering via Direct2D.
MIT License
234 stars 40 forks source link

Fix .NET Core and .NET 5 support #40

Closed drewnoakes closed 3 years ago

drewnoakes commented 3 years ago

Fixes #38, follows #39.

This PR fixes creation of the package for .NET Core and .NET 5 users, maintaining .NET Framework support.

It converts the projects from legacy csproj to newer SDK-style projects, which enable several new features such as native multi-targeting and NuGet pack from the project without a .nuspec file.

In future, to create a new version of the package:

  1. Update the single <Version> element in Directory.Build.props. This controls the assembly and package version in a single place.
  2. Pack the D2DWinForm project in VS (or via dotnet pack).

I've also enabled deterministic builds and SourceLink. Consumers of the package can now step into the library's code, and Visual Studio will download the source from GitHub directly.

A second .snupkg file is created alongside the .nupkg file, which will be uploaded to nuget.org automatically via nuget.exe push foo.nupkg. Users can download this when debug symbols are needed. The format of these symbols is portable across runtimes/frameworks.

The package icon is now embedded in the .nupkg file, rather than downloaded from github.com.

The package license is now an SPDX expression ("MIT") rather than an embedded file.

I added an .editorconfig to avoid breaking code conventions in the editor (i.e. accidentally converting leading tabs to spaces).

See individual commit messages for more details.

jingwood commented 3 years ago

@drewnoakes Thanks so much! I need a little time to learn the changes about this. I will merge it.

drewnoakes commented 3 years ago

@jingwood sure, no problem. Take your time. I wanted to use this in a .NET 5 application, and with the changes in this PR was able to do so using a local package file. So I am unblocked for now, though of course I'd rather use a public package.

I'm happy to answer any questions you may have.

jingwood commented 3 years ago

@drewnoakes Thanks! The project config looks very cool and professional, it resolved my early questions such as how to package a native DLL.

I am going to publish a new package with these latest changes. Should I publish two packages for 32bit and 64bit target platform? if you have any ideas please let me know!

drewnoakes commented 3 years ago

@jingwood I'm glad to hear the changes work for you.

I don't think you need to create two packages. It is possible to support both platforms in a single NuGet package. We will need more changes here though. I'm curious to learn how to do that, so I'll take a look.

drewnoakes commented 3 years ago

Hmm, this seems more difficult than I hoped it would be.

See:

It may be easier to produce two packages.

jingwood commented 3 years ago

@drewnoakes Thank you very much!

I am trying to set a different package id like this https://github.com/jingwood/d2dlib/pull/41 And the new packages have been published.