Create Nuget Package Visual Studio

NuGet packages a hugely important part of the .NET ecosystem. Learn how to get NuGet packages installed and running on your machine.

Create a class library project. You can use an existing.NET Standard Class Library project for the code you want to package or create a simple one as follows: Step 1. In Visual Studio, choose File New Project, expand the Visual C#.NET Standard node, select the 'Class Library (.NET Standard)' template, name the project ownNuGet,. To test the Nuget package, we can create a local feed of Nuget packages in Visual Studio. To create a local feed, create a new folder called MyLocalFeed on any drive. (You can name the folder as you like. I have created the folder on my E: drive.) Then add the Nuget package that was created earlier to this folder. This will is displayed in Visual Studio after your package is installed, and is written using markdown. You can check out our readme file here. Building Your Package. Once you've created your.nuspec file, it's now time to build your package! Nuget.Org provides an application nuget.exe that is used.

Create Nuget Package Visual Studio

Join the DZone community and get the full member experience.

Join For Free

Introduction

NuGet packages are pre-defined pieces of code which are reusable for other developers. You can add a NuGet package to your project and use it's functionality wherever you want in your project. We can also say that NuGet behaves like a platform, where developers can create and share code with the world. It contains code that's compiled as DLL which is nearly impossible to decrypt.

Prerequisites

  • Visual Studio

Step 1: Create a Project

  • We can install NuGet packages in any .NET project which supports the same target framework as our project.
  • For this demo, I'm using a standard MVC Project.

Step 2: Open the NuGet Package Manager

Now, there are two options for opening the Nuget Package Manager window.

  1. Select Tools > Nuget Package Manager > Manage Nuget Packages for Solution.

Create Nuget Package Visual Studio

2. Go to your Solution Explorer, right-click on References, and choose Manage NuGet Packages.

Step 3: Search and Install Your Required NuGet Package

  • In this window, you can search for, install, uninstall and update any Nuget Package. You can also see a full list of your installed NuGet packages.
  • Once you click on the Install button and click on 'I Agree' in the permissions pop-up window, then that particular package will be installed/added to your project.
  • Here, I am installing the EntityFramwork Nuget Package.
Create nuget package visual studio 2017 .net framework

Once the package is installed successfully, this message will be displayed.

Here, You can see your installed project. Go to Solution Explorer > Reference, and expand it.

Now you can access that package/code from your project.

Generate nuget package on build

Note: You can also install NuGet packages for multiple projects at the same time and in the same place.

Installing NuGet Using the Package Manager Console

Create Nuget Package Visual Studio 2013

VisualCreate Nuget Package Visual Studio

Step 1: Select Tools > NuGet Package Manager > Package Manager Console

It will open the console at the bottom of the window.

Step 2: Select Your Project and Execute the Below Command to Install the Package

If your command is valid, then the package will be installed in your project.

visual studio,.net,nuget packages,tutorial,web dev

Opinions expressed by DZone contributors are their own.

Create Nuget Package Visual Studio 7

Popular on DZone