简体   繁体   中英

Manage Nuget Packages Outside Visual Studio

My organization wants to segregate all the development machines on a network without internet access.

I found this article that gives that gives some nuget host product, so that the packages are available offline.

My problem is that I can't find a way to manage the package update, because the machines that have and internet access won't have Visual studio installed.

I was looking if there is a tool that reads a folder where all nupkg files are stored and check if a newer version is available and downloads it, or otherwise reads a manually created packages.config file checks for newer version and download them on a folder.

Does anyone have an idea how to manage nuget packages in this way? I spent the last week trying to find a way but I had no look.

Does anyone have an idea how to manage nuget packages in this way?

According to the NuGet CLI reference :

The update command also updates assembly references in the project file, provided those references already exist.

So when we use NuGet.exe update the package, we are not only need the packages.config but also need the solution/project, otherwise, you will get the error:

"Unable to locate project file for 'D:\\NuGetServer\\packages.config'

You can copy a simple project from the machine, which have Visual Studio installed, then use below command line to update the nuget package in the package.config file:

nuget update "YourProjectPath\packages.config"

But NuGet will update the packages into the packages folder under the solution folder by default, so we need change the packages folder to the folder where all nupkg files are stored before update packages.

Detail steps :

  1. Download the nuget.exe from nuget.org , set it to your local machines.

  2. Create a NuGet folder under the path %appdata% , add the NuGet.Config file and change the packages folder by repositoryPath , just set it " D:\\NuGetServer ":

 <?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> </packageSources> <config> <add key="repositoryPath" value="D:\\NuGetServer" /> </config> </configuration> 
  1. Copy a solution from other machine, add the packages in to the package.config file:

     <?xml version="1.0" encoding="utf-8"?> <packages> <package id="EntityFramework" version="6.1.0" targetFramework="net45" /> <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" /> <package id="NUnit" version="3.7.0" targetFramework="net45" /> </packages> 
  2. Open a CMD file, switch to the path where NuGet is stored in step 1, then use the update command:

在此处输入图片说明

You will find packages in the packages.config are updated to the latest version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM