Tech

Consuming a Nuget Package using Visual Studio

In the article we discussed how to deploy a private Nuget server, we saw the merits of giving versioning and dependency management to projects or solutions, being worked on in a team, for instance.

To consume the package(s) pushed to the feed through the nuget.exe command prompt, we need to add the package source to Visual Studio. This can be done by:

  1. Clicking “Tools”.
  2. Clicking on “Options”.
  • Expanding the “Nuget package manager” list item and selecting package sources.

The next thing to be done is to browse the pushed packages. You do this by:

  1. Clicking on “Tools”.
  2. Clicking on “Nuget Package Manager”
  3. Clicking on “Manage NuGet Packages for Solution”.

  1. Clicking on “Browse”.
  2. Selecting the “Package Source” dropdown to choose the “NugetSimulationSource” created.
  3. The “ProjectServer.dll” propagates in the list.
  4. Clicking on the ProjectServer.dll.
  5. Selecting the Project you wish to install the ProjectServer.dll package and clicking on “Install”.

The screenshot below shows the “ProjectServer.dll” package installed in the project.

At this stage, the intuitive thing to be done is to create a project, from which we can consume the new package already created and deployed.

This can be done by creating a new project, for example, “TestProjectServer”, below:

Then:

  1. Clicking on “Tools” in the newly created project.
  2. Clicking on “NuGet Package Manager”.
  3. Clicking on “Manage NuGet Packages for Solution”.

Furthermore, you can go on to:

  1. Specifying the package source in the top right corner of the window layout.
  2. Clicking on Browse.
  3. The required package propagates and then,
  4. Clicking on the “ProjectServer.dll”.

Then,

  1. Selecting the “ProjectServer.dll”.
  2. Clicking on the Project the package is to be installed in. In this case, “TestProjectServer”.

The figure below shows the consumed package file in the new test project, and this can be replicated in several other projects simultaneously.

In Conclusion

Perhaps the major disadvantage of the Nuget.Server approach is that it does not keep state: it does not rely on a local database to store download counts, user logins, etc.

Apart from that it relays a distributed way of keeping track of pushed packages in the package source and making same available to related programmers.

Also, one has the option of enabling or disabling “allowOverrideExistingPackageOnPush” so as to allow or disallow overriding of packages in a feed.

This is the best option for package redistribution in a contained environment.

 


If you have any comments or questions, please use the comment box below.

Facebook Comments

A thinker and a realist. Computer science background with a knack for philosophy and abstract thoughts.

 30 Posts 0 Comments 4863 Views

What's your say?