Create a NuGet-Package

danielleinweber

Daniel Leinweber

Posted on February 23, 2023

Create a NuGet-Package

In my day-to-day job we have a lot of projects that need to pull in the same internal libraries over and over again.

So we decided to create NuGet-Packages for these libraries and create a local feed, from which we can pull in the NuGet-Packages from our different projects.

These are the steps to create your own NuGet-Packages and use your own local feed.

1. Create a manifest

The .nuspec file is the NuGet-Packages manifest and defines the different values of the package. Like the name, description, version, etc..

You can run the following command in a developer command line to create the manifest file.

nuget spec
Enter fullscreen mode Exit fullscreen mode

2. Create a package

You can execute the following command in a developer command line to actually create the package, based on the previously created manifest.

nuget pack
Enter fullscreen mode Exit fullscreen mode

3. Add NuGet-Package to local feed

To add the created NuGet-Package to a local feed you can execute the following command in a developer command line.

nuget add MyPackage.1.0.0.nupkg --source \\my_server\my_local_feed_share
Enter fullscreen mode Exit fullscreen mode

4. Add local feed to Package sources

To actually find the NuGet-Packages from the local feed, you need to add it to the package sources.

In Visual Studio navigate to Tools > Options > Nuget Package Manager > Package Sources and click on the green + icon to add a new source. Provide a name and a source for your local feed.

After that you are able to browse your local feed when managing NuGet-Packages for a project.

💖 💪 🙅 🚩
danielleinweber
Daniel Leinweber

Posted on February 23, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Create a NuGet-Package
dotnet Create a NuGet-Package

February 23, 2023