Hosting your own NuGet Server and Feed for build artifacts with BaGet
NuGet is the package management system underlying the .NET programming platform. Just like Ruby Gems or NPM Packages, you can bring in 3rd party packages or make your own. The public repository is hosted at http://nuget.org BUT the magic is that there's alternatives! There are lots of alternative servers, as well as alterative clients like Paket.
There's a whole ecosystem of NuGet servers. You can get filtered views, authenticated servers, special virus scanned repositories, your own custom servers where your CI/CD (Continuous Integration/Continuous Deployment) system can publish daily (hourly?) NuGet packages for other teams to consume.
Ideally in a team situation you'll have one team produce NuGet Packages and publish them to a private NuGet feed to be consumed by other teams.
Here's just a few cool NuGet servers or views on NuGet.org:
- FuGet.org
- FuGet is "pro nuget package browsing!" Creating by the amazing Frank A. Krueger - of whom I am an immense fan - FuGet offers a different view on the NuGet package library. NuGet is a repository of nearly 150,000 open source libraries and the NuGet Gallery does a decent job of letting one browse around. However, https://github.com/praeclarum/FuGetGallery is an alternative web UI with a lot more depth.
- Artifactory
- Artifactory is a, ahem, factory for build artifacts of all flavors, NuGet being just one of them. You can even make your own internal cache of NuGet.org. You can remove or block access to packages you don't want your devs to have.
- NuGet Gallery
- You can just run your OWN instance of the NuGet.org website! It's open source
- NuGet.Server
- NuGet.Server is an MVP (Minimum Viable Product) of a NuGet Server. It's small and super lightweight but it's VERY limited. Consider using BaGet (below) instead.
- GitHub Packages
- GitHub has a package repository with a small free tier, and it also scales up to Enterprise size if you want a "SaaS" offering (software as a service)
- Azure Artifacts
- Azure Artifacts can also provide a SaaS setup for your NuGet packages. Set it up and forget it. A simple place for your automated build to drop your build artifacts.
- MyGet
- MyGet can hold packages of all kinds, including NuGet.They are well known for their license compliance system, so you can make sure your devs and enterprise are only using the projects your org can support.\
- Sleet
- Sleet is a NuGet v3 static feed generator. It's a Nuget Server, that's totally STATIC. Just like a static site generator this means that you can make feeds and host them directly on Azure Storage or Amazon S3 with no compute required.
- LiGet
- A NuGet server with a Linux-first approach
- BaGet (pronounced baguette)
- This is one of my favorites. It's a new fresh NuGet server written entirely in ASP.NET Core 3.1. It's cross platform, open source, and runs in Azure, AWS, Google Cloud, behind IIS, or via Docker. Lovely! It's also a great example of some thoughtfully architected code, good plugin model, nice separation of concerns, and a good test suite. If you are using NuGet.Server now, move over to BaGet!
Let's focus on BaGet for now! Go give them some love/stars on GitHub!
Setting up a cross platform personal NuGet Server with BaGet
BaGet is a lovely little server. So far it supports:
- Cross-platform
- Dockerized
- Cloud ready
- Supports read-through caching
- Can index the entirety of nuget.org. See this documentation
- Coming soon: Will supports private feeds
The most initially powerful feature in my opinion is the Read-through caching.
This lets you index packages from an upstream source. You can use read-through caching to:
- Speed up your builds if restores from nuget.org are slow
- Enable package restores in offline scenarios
This can be great for folks on low bandwidth or remote scenarios. Put BaGet in front of your developers and effectively make a NuGet "edge CDN" that's private to you.
If you are familiar with Docker, you can get a BaGet NuGet server up in minutes. You can also use Azure or AWS or another cloud to store your artifacts in a scaleable way.
NOTE: You'll notice that the docs for things like "running BaGet on Azure" aren't complete. This is a great opportunity for YOU to help out and get involved in open source! Note that BaGet has a number of open issues on their GitHub *and* they've labeled some as "Good First Issue!"
If you want to try running BaGet without Docker, just
- Install .NET Core SDK
- Download and extract BaGet's latest release
- Start the service with
dotnet BaGet.dll
- Browse
http://localhost:5000/
in your browser
That's it! All the details on Getting Started with BaGet are on their GitHub. Go give them some love and stars.
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter
thanks for listing out several Nuget alternatives.
Please add a warning to "Artifactory" at the moment the "Nuget" implementation is badly implemented.
If you are using it as your corporate Nuget-Proxy you can't proxy several feeds like Azure Artifacts as they don't handle the protocolls metadata. See this open and ignored issue: https://www.jfrog.com/jira/browse/RTFACT-17258
Kind regards,
Bjego
I know its possible to add specific NuGet packages as "scanners" to the Visual Studio project, but I was looking for that as a separate build task.
It's kind of like asking someone to sideload an app on their phone asking them to use some third party run service.
additionally sharing in delicious. And of course, thank
you in your effort!
Comments are closed.