Sukhjeevan
Sukhjeevan

Reputation: 3156

How to convert a class library project into NuGet package

We have below in .sln file.

1.Website project

2.Service project

2.Framework ClassLibrary project

We want to create a NuGet package of this ClassLibrary project which will be used in any other project. As of now website & service project contains direct reference to CL project so 1st step is to decouple CL project from website & service project but if we do we'll get compile time error while building website project. Does that means we have to change whole code in CL project before decouple.

After successful decouple , we'll remove this CL project from solution and will reference like NuGet package.

NuGet package can be created as explained in this link Create NuGet package

Upvotes: 2

Views: 15110

Answers (3)

Sarath Baiju
Sarath Baiju

Reputation: 294

  1. first create nuspec file use nuget spec command from your root directory
  2. create .nupkg from nuspec use nuget pack command from the directory where the nuspec file contains

Note : nuget should install your system, other ways install nuget.exe and copy that to your project root directory

Upvotes: 0

Rohan Patel
Rohan Patel

Reputation: 1

1) Create class library 2) Set target framework to .NET Standard 1.4 from property > Library tab

Fro more help go to this link https://learn.microsoft.com/en-us/nuget/guides/create-net-standard-packages-vs2015

Upvotes: 0

Muthukumar Palaniappan
Muthukumar Palaniappan

Reputation: 1670

Here are some steps you can follow.

  1. Please follow this link to create a nuget pacakge for the Class library. https://learn.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-visual-studio

  2. Once you have created the nuget package, you can manage the packages in a shared drive location.

  3. In your visual studio, go to tools -> nuget package manager -> Package manager settings -> Package source. Where you can provide the shared drive url. so that your visual studio can probe in the location for any nuget package.

  4. Remove the existing dll reference in your 2 projects. Right click on your web/services project and click manage nuget package. you will be listed with your newly created pacakge, which you can choose and add.

There wouldn't be any code change required

Upvotes: 4

Related Questions