Cover image for Creating a project for NUGET (C#)

Creating a project for NUGET (C#)

jorgecc profile image Jorge Castro Updated on ・3 min read

What is NUGET?

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

Why do you want to publish a library on NUGET?.

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.

But Microsoft is Anti Open source is it?.

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.

Creating a new project using Visual Studio (Community)

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

First, we need to create a new visual studio project

  • Create a project of the type: Class Library C# Standard. A standard library works with Net Framework and Core so it works for both.

Second, we create our library.

Third, we modify the properties of our project

  • 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.

Fourth, we pack the project

It will generate a file called YOURPROJECT.1.0.0.nupkg. It is a zip file.

Fifth, we need a NUGET account

(https://www.nuget.org) it's easy to create one and it is for free.

Sixth. this part is tricky (but optional).

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">
    <title>Rut Chile</title>
    <summary>Libreria para validar y generar RUT chilenos</summary>

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.

Seventh. Upload your library


You could use a CLI to download it but it is a chore (keys and whatnot). It's way easy to use the website.

And finally, wait 15 minutes and that's it!.


The library is up and running.

However, it could take a long while to be shared globally.

Posted on by:

jorgecc profile

Jorge Castro


You are free to believe in whatever you want to, me too. So, stop preaching your religion, politics, or belief. Do you have facts? Then I will listen. Do you have a personal belief? Sorry but no.


markdown guide

I recommend using <GeneratePackageOnBuild> directive instead of manually creating/editing/packing nuspec file. Also, seeing as your project is on GitHub you should really set up a CI/CD environment as soon as possible, there's no excuse for not having automated build and delivery processes anymore.