Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

How to Configure Local Nuget Repository

, 3 Dec 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
How to configure a local Nuget repository

Introduction

After my last posts about Nuget packaging, I wanted to share another useful experience with Nuget.
You can create a local repository to store all the packages you need and not download those every time.

  1. To do this, I have created a folder C:\NugetConfig\Repo and I have copied there the Newtonsoft.Json.4.5.10.nupkg package file.
  2. To make both solutions use this local repository, all I have to do is to change the following settings in the NuGet.targets file:
    <ItemGroup Condition=" '$(PackageSources)' == '' ">
        <!-- Package sources used to restore packages. 
        By default will use the registered sources under %APPDATA%\NuGet\NuGet.Config -->
        <!--
            <PackageSource Include="https://nuget.org/api/v2/" />
            <PackageSource Include="https://my-nuget-source/nuget/" />
        -->
    </ItemGroup>

    and adding a new PackageSource location:

    <ItemGroup Condition=" '$(PackageSources)' == '' ">
        <!-- Package sources used to restore packages. 
        By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
        <!--
            <PackageSource Include="https://nuget.org/api/v2/" />
            <PackageSource Include="https://my-nuget-source/nuget/" />
        -->
        <PackageSource Include="C:\NugetConfig\Repo" />
    </ItemGroup>

    And that's it. This will make the solution search for the used packages in the given folder and you will get ? meaningful error if the package could not be found.

  3. Furthermore you can add your local repository to the Visual Studio package sources so that you will be able to search and add packages from it to any new solution:

As usual, you can find the code here.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Vasil Trifonov
Software Developer (Senior) Telerik
Bulgaria Bulgaria
No Biography provided
Follow on   Twitter   Google+

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.141022.2 | Last Updated 4 Dec 2012
Article Copyright 2012 by Vasil Trifonov
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid