简体   繁体   English

如何在 Visual Studio 中为 nuget 包创建离线存储库

[英]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.

相关问题 Visual Studio 2017仅具有适用于.NET Core 2.x的脱机Nuget包。如何获得在线套餐? - Visual Studio 2017 only has offline Nuget Packages for .NET Core 2.x. How to get online packages? 如何恢复 Visual Studio nuget 包? - How to restore visual studio nuget packages? 无法找到包 ***。 源中不存在具有此 ID 的包:“Local Nuget”、Microsoft Visual Studio 离线包、nuget.org - Unable to find package ***. No packages exist with this id in source(s): "Local Nuget", Microsoft Visual Studio Offline Packages, nuget.org Visual Studio中缺少Nuget软件包 - Nuget Packages are missing in Visual Studio Visual Studio:执行“还原NuGet包”时如何添加nuget包作为引用 - Visual Studio: how to add nuget packages as references when doing “Restore NuGet packages” 错误 NU1101:无法找到包 &#39;&#39;。 源中不存在具有此 ID 的包:Microsoft Visual Studio 离线包,nuget.org - error NU1101: Unable to find package ''. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org Nuget包在Visual Studio中无法正常工作 - Nuget Packages not working correctly in Visual Studio Visual Studio NuGet无法还原包 - Visual Studio NuGet Cannot Restore Packages 通过TFS Visual Studio恢复Nuget包 - Visual Studio restoration of Nuget packages through TFS 在Visual Studio中添加Nuget软件包时出错 - Error adding Nuget packages in visual studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM