
NuGet
Episode Thirty One
Intro
I'm Peter and this is the RoguePlanetoid Podcast where you will find insights about Microsoft or related platforms and technology, along with so much more whether you are beginner or an experienced professional or just interested in technology. Keep Current, Keep Coding!
Welcome
Welcome to episode thirty-one of the RoguePlanetoid Podcast about NuGet. Create .NET applications faster with NuGet by consuming existing packages publish packages to share with the community. NuGet is the package manager for .NET, which forms an essential tool for any modern development platform where .NET developers can create, share and consume useful libraries and packages. NuGet client tools provide the ability for .NET developers to produce and consume packages via the central package repository, used by all package authors and consumers. NuGet has almost ten million versions of over four hundred and fifty thousand unique packages, that have been downloaded over seven hundred and twenty billion times.
About
NuGet is the Microsoft-supported mechanism for sharing .NET code which is a single ZIP file with a “.nupkg” extension, that contains compiled code assemblies and related files along with a manifest containing information such as the version number. Developers with code to share can create a NuGet package and publish it privately for use within an organisation or publish publicly to nuget.org. Developers can target a specific framework such as Windows App SDK and Blazor or can target .NET standard which all legacy .NET Framework and modern .NET applications can consume. Developers who need to target features outside of .NET standard need to create separate assemblies for each of the different frameworks they wish to target, and when these packages are installed only the assemblies needed are extracted, although these multi-targeted packages are harder to maintain.
NuGet not only hosts packages but also provides a variety of tools used by package creators and consumers, this includes the dotnet Command Line Interface, nuget.exe which is a Command Line Interface to create NuGet packages and the Package Manager Console in Visual Studio. NuGet provides and easy way to build the work of others and manages a lot of the complexity for you, allowing you to focus on using the packages directly in a project which can consume other packages, and NuGet takes care of these dependencies including finding the versions of packages that satisfies all consumers of a package. NuGet makes the process of sharing projects between developers easier by just maintaining a simple reference to the packages needed by the project, which can then be installed or restored when needed either from private hosts or from nuget.org. To find out more about NuGet or to browse or search the available NuGet packages then visit nuget.org or check out the link in the show notes.
Consuming
Developers want to focus on creating new or innovative features of their applications, and the last thing they want to do is reinvent the wheel and do something someone else out there probably already has created and that's where NuGet comes in. Developers can browse or search for packages from NuGet that suit their such as common functionality needed, like the most popular package on NuGet of Newtonsoft.Json, which is a high-performance JSON framework for .NET which has over six and a half billion downloads having been used directly in thousands of applications or indirectly by other packages. Logging libraries such as Serilog, resilience and transient fault handling with Polly, Moq for mocking in testing along with Automapper for mapping between objects and MediatR for request or responses within applications are just some of the popular packages available on NuGet.
NuGet offers the benefit of tried and tested packages for developers that are trusted by other developers and often contributed to by the community, this ensures can benefit from a whole catalogue of useful functionality without having to implement their own, which risks creating less resilient or more security prone implementations, as no matter how good a developer is, the work of many developers tried and tested by thousands of other developers is going be better and more robust. However, should the worst happen, and a package has a problem then this can be fixed, pushed and consumed by applications quickly and easily with many services such as Dependabot, which automates dependency updates on GitHub to make sure applications there are always able to be quickly and easily updated with the latest required updates to NuGet packages. Developers can also take advantage of additional functionality in the latest version of a package to leverage even more useful functionality they don't have to write themselves.
NuGet helped solve the problem of how to get functionality from other developers in a single easy-to-use manner, before NuGet you would obtain this from a variety of sources with different installers which would install these dependencies directly onto your computer, and anyone else who needed to work on the same project would have to seek out and install these dependencies themselves, and if you needed to update any packages you would have to do this yourself, and there wouldn't be an easy single way to find out if any packages had a problem, and if they did you'd need to find this out and install this new fixed version yourself. Organisations can take advantage of the workflows that NuGet offers without needing to publish packages publicly, this can be done with a private NuGet server, allowing the same benefits of the public NuGet offering without sharing anything outside the organisation. NuGet packages don't just have to be for a project for a small piece of functionality but can be the entire application, allowing them to be built once and then deployed through a continuous integration and continuous delivery pipeline, so that code is built once, tested once and never changes throughout the deployment process.
NuGet has saved .NET developers like me so much time and effort, not only to provide functionality that would have taken time to produce, but also in a way that can be trusted implicitly having the reputation of many more developers such as myself to count on, who also depend on those packages. There's simply no need to reproduce functionality that is already available, and this saved time can be used to focus on specific functionality, which itself could be a private NuGet package for use within an organisation. Some popular packages on NuGet these days often have commercial licensing to ensure the resources are available to maintain them, and for organisations saving thousands of pounds on development, this is probably a small price to pay to leverage this functionality. However, in some cases there are free alternatives to popular packages, but it is worth considering that the investment in these may vary, but if they are popular then they should benefit from the same drive from the community, to ensure that they deliver what they need and any issues are resolved or new features are implemented for those packages on NuGet.
Producing
Developers who create new or innovative functionality for their own applications and consider it worth sharing can publish this as a package for everyone to benefit from on NuGet. Packages are most often Class Libraries which can be created by any developer for themselves, and simply by updating the project information to include name, description and version along with an icon plus a readme file in Markdown, is the only preparation you need to get something publishable and once you're happy with a package can then publish this on NuGet. When developing NuGet packages for use by others, it is important they are robust enough so having plenty of tests is a must or at least make sure you've tested it enough yourself, and as you add new features that tests are created for these too. Projects can be open-source which not only allows developers to share more about how their package works, but to also to track any issues that have been reported by other developers, as well as being able to have fixes contributed to by other developers, who can also provide tests and leverage any existing tests to make sure their contributions work along with the existing functionality.
NuGet accepts packages from any .NET developer, so you can be a solo developer working from home or part of a team of developers from just a few to dozens or hundreds who want to share something interesting and useful with the community, this can then allow other developers to take advantage of it. Many package authors gain support as their packages become more popular, with many dedicating most of their time to the upkeep of the package or are supported by their employer to allow them to contribute or manage the contributions of others to their package. If you build a .NET Standard package for NuGet this can be used by any .NET application, or if support as many options for targets as possible, then this allows the package to be used in the broadest set of applications or even be leveraged by other packages to enhance their functionality. Packages don't have to be massive undertakings, although many of them are that offer a wide range of functionality, but many are small packages offering useful features for other developers to be able to use in their own applications.
NuGet allows .NET developers like myself to be able to publish their own packages for other developers to use, and many are supported by donations and popular packages will get a lot of support from the community, although there's no guarantee of getting rich or even paid at all, NuGet packages can be a great way to build a reputation the community or within an organisation you wish to join. When talking about your personal projects having one or more packages published on NuGet is probably a great way of demonstrating your willingness to share, and even if you don't write your own packages you could contribute to a package to make them better. One of my own packages had a contribution to add a source generator to produce one of the enums which was a really great way of doing what I needed to do, so was a much-appreciated addition that has made updating the package much easier. You can always add new features to a package, fix issues or even create new packages to bring even more functionality to the community, or there may be certain things that an application may do that may be worth making available developed by an organisation so that everyone can benefit from the functionality you've created. This can be a great way of returning the favour of having used functionality from existing packages on NuGet.
Packages
NuGet packages that I've written started with one back in 2018 for Universal Windows Platform which were some controls based on fun ideas from tutorials I had written including dice, clock, dial, 7-segment and dot matrix displays along with playing cards, directional pad and domino. This package was quite popular and remains my second most popular package with over seven thousand downloads from NuGet! My most popular package came from a music service, but probably not the one you're thinking of which is Groove Music, which used to be called Xbox Music which followed up from the Zune music service which was something of an interest of mine! Groove Music had a fantastic API and SDK for a music service include clever ways to get an artist image that used face detection, so no matter which size you asked for it would find an appropriate image cropped to show a whole band for example. I worked with this SDK for a while and learned quite a lot of things from it and when Groove Music shut down and switched to Spotify, I looked at their API and documentation and found it shared a lot in common with Groove Music so worked on creating my own SDK, which became Spotify.NetStandard in 2019 which I evolved over the years and has gained over fifteen thousand downloads from NuGet.
I returned to creating new packages on NuGet in 2022 with a toolkit for .NET Standard with Comentsys.Toolkit offering basic databinding and foundation for my asset packages, and another toolkit of Comentsys.Toolkit.WindowsAppSdk for the successor to Universal Windows Platform, which included controls with updated ones from my original package including playing cards, dice and directional pad along with being updated more recently with new functionality including support for Widgets in Windows 11. I was also working on my own tutorials for Windows App SDK such as games so decided to create some asset packages that used the fun and open-source Fluent Emoji from Microsoft so that I could use them more easily, and make them available for other developers including Comentsys.Assets.FluentEmoji for the flat style and recently updated to reference the static and animated 3D styles of emoji hosted on GitHub, along with Comentsys.Assets.FluentEmoji.Shaded for the colour style and Comentsys.Assets.FluentEmoji.Contrast for the high contrast style of emoji.
My other packages on NuGet include assets used by my own tutorials for games with Comentsys.Assets.Games such as chess and mahjong based on public domain or permissive licenced assets from Wikipedia, these have recently been joined by more assets for playing cards as well as my own designs for dice, dominoes, game pieces and game boards along with for flags of the world with Comentsys.Assets.Flags. Not only have my tutorials inspired packages but also my workshops have too, such as Comentsys.Assets.Display updating the 7-segment and dot matrix displays I had created previously, which was used by a workshop to build a widget for Windows 11 along with creating packages that may be useful in the future, such as Comentsys.Assets.FluentIcons for the regular fluent system icons, and Comentsys.Assets.FluentIcons.Filled for the filled fluent system icons designed by Microsoft. If you want to see all my NuGet packages, then visit comentsys.com/packages or check out the link in the show notes.
Conclusion
NuGet has seen all my toolkit and asset packages updated in the last couple months to add new functionality or make them easier to use or understand with metadata or improved documentation. Many of these packages have been downloaded around a thousand times and more, and I look forward to having many more developers leverage these packages in their applications. I've really enjoyed the process of creating and updating my asset packages, which not only just take these resources from GitHub or Wikipedia but process them in a way to make them more flexible, including adding the ability in most cases to customise the colours of assets, to allow for an infinite number of combinations of assets to be used by .NET developers.
NuGet is a fantastic platform for developers to be able to consume packages, including my own, to include functionality they don't have to spend time doing themselves, or to leverage tried and tested features to allow them to focus on the core functionality of their applications. Packages can also build upon other packages, to extend them to offer more options that other developers can take advantage of allowing everyone to build richer applications. Packages themselves can be developed to allow functionality to be shared with the community, which can evolve over time with contributions or fixes when needed allowing everyone to benefit. Whether you are writing your own applications and need some specific functionality or have some specific functionality you want to share with the community, then the best place to do this for .NET developers is NuGet.
Outro
Thanks for listening to the RoguePlanetoid Podcast where each episode you will find insights about Microsoft or related platforms and technology, along with so much more wherever you listen to your podcasts or at rogueplanetoid.com/podcasts for the RoguePlanetoid Podcast whether you are a beginner or an experienced professional or just interested in technology. Keep Current, Keep Coding!
- Website - rogueplanetoid.com/podcast
- X - x.com/rogueplanetoid
- YouTube - youtube.com/@rogueplanetoid
- NuGet - nuget.org
- Comentsys.Toolkit - nuget.org/packages/Comentsys.Toolkit
- Comentsys.Toolkit.WindowsAppSdk - nuget.org/packages/Comentsys.Toolkit.WindowsAppSdk
- Comentsys.Assets.FluentEmoji - nuget.org/packages/Comentsys.Assets.FluentEmoji
- Comentsys.Assets.FluentEmoji.Shaded - nuget.org/packages/Comentsys.Assets.FluentEmoji.Shaded
- Comentsys.Assets.FluentEmoji.Contrast - nuget.org/packages/Comentsys.Assets.FluentEmoji.Contrast
- Comentsys.Assets.Games - nuget.org/packages/Comentsys.Assets.Games
- Comentsys.Assets.Flags - nuget.org/packages/Comentsys.Assets.Flags
- Comentsys.Assets.Display - nuget.org/packages/Comentsys.Assets.Display
- Comentsys.Assets.FluentIcons - nuget.org/packages/Comentsys.Assets.FluentIcons
- Comentsys.Assets.FluentIcons.Filled - nuget.org/packages/Comentsys.Assets.FluentIcons.Filled
- Comentsys Packages - comentsys.com/packages
RoguePlanetoid Podcast is a production of cluarantonn.com
Hosted, Written, Produced and Edited by Peter Bull
Music based on Like a Tiger by Jo Wandrini
Production Company Name by Granny Robertson