Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix .NET Core and .NET 5 support #40

Merged
merged 6 commits into from
Dec 15, 2020

Conversation

drewnoakes
Copy link
Collaborator

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.

This commit produces a package that works correctly for consumers using
.NET Core and .NET 5.

The project files are converted from legacy csproj to the newer SDK-style
projects. These originated with .NET Core, but still allow targeting .NET
Framework.

In addition, this commit:

- Removes the .nuspec file, specifying properties in .csproj files.
- Moves common MSBuild properties to Directory.Build.props file.
- Removes all post-build steps, and use reference items instead.
- Correctly specifies the runtime library, without using a .targets file.
- Removes the "binary" folder from the repo.
- Adds several files as solution items, making them easier to edit in Visual Studio.
This helps editors enforce code style.
SourceLink allows a consumer of the package to step into this library's source code in Visual Studio.

Deterministic builds allow a user to reproduce the exact same binary on their own machine to validate the that the binaries in the package were built as advertised.
@jingwood
Copy link
Owner

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

@drewnoakes
Copy link
Collaborator Author

@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 jingwood merged commit 2ab3823 into jingwood:master Dec 15, 2020
@jingwood
Copy link
Owner

@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 drewnoakes deleted the fix-net-core-and-sourcelink branch December 15, 2020 21:46
@drewnoakes
Copy link
Collaborator Author

@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
Copy link
Collaborator Author

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

See:

It may be easier to produce two packages.

@jingwood
Copy link
Owner

jingwood commented Dec 16, 2020

@drewnoakes Thank you very much!

I am trying to set a different package id like this #41
And the new packages have been published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Package doesn't appear to work under .NET Core or .NET 5
2 participants