I ended my last post by throwing my hands up in despair because adding my .NET Standard project via NuGet triggered the download more than 40 irrelevant dependencies. In this short update, I’m going to explain how to get this working.
Firstly, massive thanks to everyone who commented on my original post or on my submission to /r/dotnet. Special thanks go to /u/kukkimonsuta, who even went as far as to make a pull request on the ConTabs repo. It was great to see the community spring into action to help out a dude in distress.
Anyway, it turns out the trick is to target more than one target framework:
Essentially we’re saying that Core apps can carry on using Standard 1.3, but that modern (4.7 and up) versions of Framework will use either Standard 2.0, while lower versions get good ol’ fashioned Framework 4.5.
By providing three sets of “contracts”, we’re letting the NuGet client work out what dependencies are needed. Since all our bases are covered, all targets will be satisfied and we won’t need to install dozens of dependencies.
I’m feeling like this is a huge win for open source. Through the assistance of the community, I’ve been able to fix the issue and publish an updated package – all within 24 hours of my original blog post. Thanks again guys!
If you want the updated, bloat-free package, it’s available in the NuGet gallery.