[英]How to create an offline repository for nuget packages in Visual Studio
I have many .nupkg files downloaded and I don't always have an internet connection.我下载了很多 .nupkg 文件,但我并不总是有互联网连接。 So I'd like to change the nuget repository (nuget.org) to Eg.所以我想将 nuget 存储库(nuget.org)更改为 Eg。 D:\\nugetOffline. D:\\nuget离线。 In that folder I'll put the .nupkg files.在该文件夹中,我将放置 .nupkg 文件。
You can control this using %APPDATA%/Roaming/NuGet/NuGet.Config
and adding a config item like:您可以使用%APPDATA%/Roaming/NuGet/NuGet.Config
并添加如下配置项来控制它:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="globalPackagesFolder" value="C:\dev\nuget\packages" />
<add key="repositoryPath" value="C:\dev\nuget\packages" />
</config>
</configuration>
You can also control this on a per solution basis using a NuGet.Config file in the same folder as the .sln file, and/or per project by placing a NuGet.config next to the .csproj file.您还可以使用与 .sln 文件位于同一文件夹中的 NuGet.Config 文件和/或通过在 .csproj 文件旁边放置 NuGet.config 来控制每个解决方案的基础。
See the NuGet.config file reference for more details about all the available options.有关所有可用选项的更多详细信息,请参阅NuGet.config 文件参考。
For globalPackagesFolder (projects using PackageReference only):对于globalPackagesFolder (仅使用 PackageReference 的项目):
The location of the default global packages folder.默认全局包文件夹的位置。 The default is %userprofile%.nuget\\packages (Windows) or ~/.nuget/packages (Mac/Linux).默认为 %userprofile%.nuget\\packages (Windows) 或 ~/.nuget/packages (Mac/Linux)。 A relative path can be used in project-specific nuget.config files.可以在特定于项目的 nuget.config 文件中使用相对路径。 This setting is overridden by the NUGET_PACKAGES environment variable, which takes precedence.此设置由优先的 NUGET_PACKAGES 环境变量覆盖。
For repositoryPath (packages.config only):对于repositoryPath (仅packages.config):
The location in which to install NuGet packages instead of the default $(Solutiondir)/packages folder.安装 NuGet 包的位置,而不是默认的 $(Solutiondir)/packages 文件夹。 A relative path can be used in project-specific nuget.config files.可以在特定于项目的 nuget.config 文件中使用相对路径。 This setting is overridden by the NUGET_PACKAGES environment variable, which takes precedence.此设置由优先的 NUGET_PACKAGES 环境变量覆盖。
Visual Studio.视觉工作室。 In menu bar Tools -> Manage Nuget packages -> Package manager config -> Package origins.在菜单栏工具 -> 管理 Nuget 包 -> 包管理器配置 -> 包来源。 There is the nuget.org repo , click in Add and change the origin and name of the new repo, browse your folder and give a name , just click in update and accept.有 nuget.org 存储库,单击添加并更改新存储库的来源和名称,浏览您的文件夹并命名,只需单击更新并接受。 You can copy the .nupkg files in your selected folder您可以复制所选文件夹中的 .nupkg 文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.