nuget的自定义配置

Custom configuration of nuget

我需要 nuget 包的自定义配置。 到目前为止,我是如何理解的,有两种方法可以管理 nugets。 第一个是PackageReference,另一个是package.config

当一个人使用 PackageReference 包被下载到 computer/user 广泛的存储库中并通过引用直接在项目中使用。

当使用 package.config 时,软件包被下载到 packageSources 文件夹(来自 NuGet.Config)并安装到 repositoryPath 文件夹。 因此每个包至少在磁盘上两次。

我想使用 nugets 分发可能很大的内容。

是否可以将 nugets 配置为包只在磁盘上一次?有点像 PackageReference 但不使用全局存储库,只使用项目存储库?

Is it possible to configure nugets in a way that the packages are on a disk only once? Somehow like PackageReference but not using the global wide repository, only the project repository?

是的,您可以在解决方案旁边放置一个 NuGet.Config 文件,内容如下:

<?xml version="1.0" encoding="utf-8"?>
  <configuration>
    <config>
      <add key="globalPackagesFolder" value=".\packages"/>
    </config>
</configuration>

然后重启Visual Studio,重新打开解决方案右击解决方案,select恢复NuGet包。所有包都存储在项目存储库中。

希望对您有所帮助。