Sorry, you need to enable JavaScript to visit this website.

NuGet Packages & Command Lines for Sharing Common Components

NuGet Packages & Command Lines for Sharing Common Components
April 17, 2015


It is a common problem when a team in an organization creates a component which can be leveraged by multiple teams, but does not keep it in a common shareable repository to which everyone has access.

Most of the teams depend on checking in the common component in to a shared source control to which other teams get a reference to use it. This process of adding a reference has several challenges:

  1. Version control of the component
  2. Accidently deleting the component
  3. Authorization ( Permissions) at the source control

In this blog, I will illustrate the creation and use of a local NuGet repository that would facilitate the leverage of common components.

Creating a package:

  1. Get the NuGet command line ( )
  2. Open Command prompt and navigate to directory path where NuGet command line has been installed.
  3. Run “nuget spec”. This will create a “Package.nuspec” file. This is the base file which holds the schema to create a NuGet package.
  4. Navigate to the directory where Package.nuspec has been created and create a folder “Content”. Use the “Content” folder to drop the required libraries to be referenced.
  5. Open Package.nuspec in a notepad and edit it.


  6. Save the file and close it.
  7. Open command prompt and run “nuget pack”. On success, a .nupkg file will be created.
  8. Copy the *.nupkg file and place it in a shared folder.

Adding the package source:

  1. Open Visual Studio and navigate to Tools > Library Package Manager > Package Manager Settings.

    Visual Studio

  2. Click on OK and a new Package source will be added.

Using the package:

  1. Right click on the project and select “Manage Nuget Packages”.

    Manage Nuget Packages

  2. Click on the package we created and the assemblies added in the “Content” folder of the package will be added as reference in your project.

Shared NuGet packages take advantage of all the functionalities offered by NuGet packages. These include version management, adding components locally, and modifying the configuration.