NUGET is THE repository of projects of .NET (including C#)
It is integrated with Visual Studio but it is also possible to runs under CLI.
A bit of stats
- 21,145,360,813 package downloads
- 1,696,723 package versions
- 156,686 unique packages
Mainly because visibility but also to collaborate to the open source community.
Some people claim that they collaborate to the community but they are all barks but no bites. Sharing is caring.
Of course, we don't want to share our private project.
Microsoft is mainly closed-source but there are two trends of open source:
- Full Open source. (Stallman & friends)
- Mixed (open and closed-source)
Microsoft embraces the last one so it is fine.
In this example, I want to share a library called RutChile. It is a small library to work with the national Id (called RUT) from my country. I also published a repository on GitHub (also owned, I say pwned by Microsoft) https://github.com/EFTEC/RutChile
- Create a project of the type: Class Library C# Standard. A standard library works with Net Framework and Core so it works for both.
- Right button under our project - properties - packages
We will need a license but we could generate one online. I added the license as LICENSE.txt to my project.
We could also use a GitHub repository, where we could update an image and use as a repository but it is optional.
It will generate a file called YOURPROJECT.1.0.0.nupkg. It is a zip file.
(https://www.nuget.org) it's easy to create one and it is for free.
The nupkg generated has an incomplete file. Let's rename our *.nupkg project as .zip and open it.
There is a file called YOURPROJECT.nuspec, edit this file
<?xml version="1.0" encoding="utf-8"?> <package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"> <metadata> .... <title>Rut Chile</title> <summary>Libreria para validar y generar RUT chilenos</summary> .... </metadata> </package>
Inside "metadata", there are two tags that are missing "title" and "summary". Edit it manually, then rename your file back to .nupkg so you could upload it.
You could use a CLI to download it but it is a chore (keys and whatnot). It's way easy to use the website.
The library is up and running.
However, it could take a long while to be shared globally.