DEV Community

jokoyoski
jokoyoski

Posted on

Generating a nuget package and use locally for .Net developers

What is a Nuget Package ?
NuGet is a free and open-source package manager designed for the Microsoft development platform (formerly known as NuPack). Since its introduction in 2010, NuGet has evolved into a larger ecosystem of tools and services.
NuGet is distributed as a Visual Studio extension. Starting with Visual Studio 2012, NuGet comes pre-installed by default. NuGet is also integrated with SharpDevelop. NuGet can also be used from the command line and automated with scripts.
It supports multiple programming languages, including:
· .NET Framework packages
· Native packages written in C++, with package creation aided by CoApp
Generating a nuget package takes a simple steps.
Step 1. Right-click on your project and go to properties , select the package tab. Fill in the necessary information about the nuget package you are trying to create
Step 2: Change your project from Debug to Release. Then right-click on the project and select “Pack”. This build the project and a “.nupkg” extension file is been generated, To get the file, Open file explorer and navigate to your project, then navigate to bin>Release.
To add the nuget package to your local repo, you must first install package console CLI . Use the following Command line to install
“Install-Package NuGet.commandline”
Step 3. Create a folder which you have an access to and drop the nupkg file in the folder . Let us say the name of our nupkg is “FileA.1.0.0.nugpkg” Then use the following command to add the nuget package in the nuget repo .
PM >nuget add “FileA.1.0.0.nugpkg -source C:\Users\Kafka
where “C:\Users\Kafka” is the folder where our nupkg is
The above command add the nuget to our local repo . To remove the nuget from our local repo we use the following command
PM >nuget remove “FileA.1.0.0.nugpkg -source C:\Users\Kafka

Top comments (0)