DEV Community

Roel
Roel

Posted on • Updated on

[How-To] A guide on how to test (new versions of) your .nuget packages locally

Last week I had to test a new version of a package. The problem was that the package was released on a nuget feed, but to test it properly I had to first test it in another solution.

By creating a local Nuget feed on your development machine, and publishing your nuget package to this feed we can very easily test and work with your package.

Create a local feed

Create a local folder where you want to store your local nuget packages. For example on your C:\ drive.

  • Create a new folder called local.nuget

Image description

  • Open visual studio and navigate to Tools > NuGet Package Manager > Settings Image description
  • Navigate to Package Sources and click on the green + button.
  • Give it a name and point the directory to your local nuget folder we just created. Image description
  • Click Ok

Publish the package to the feed

Now to create the package and publish it to our custom feed.

  • Open the project you want to publish and open the .csproj file of the project.
  • Change the <version> tag to a version which is easily recognizable. (To avoid caching problems you can use something not easily used in production, such as 99.0.0.)

  • Right click the project and click Pack to publish the nuget package to your /bin folder.
    Image description

  • Copy the .nupkg to your local nuget folder in C:\local.nuget.

Using the package

  • Open the solution that uses the package
  • Open the Package manager for this solution
  • Navigate to the Browse tab and change the 'Package source' to nuget.local

Image description

  • Use the new version of the package!

That's all there is to it! ###

Top comments (0)