【问题标题】:Package destination of restore of .net-core projects is always global package directory.net-core 项目恢复的包目的地始终是全局包目录
【发布时间】:2018-04-28 21:38:07
【问题描述】:

我们有一个解决方案,其中一些项目是 .net-core 项目,而一些是“正常”的 .net 4.6.1 项目。 在解决方案级别,我们有一个 NuGet.config-File 来设置 repositoryPath:

<configuration>
  <config>
    <add key="repositoryPath" value="packages" />
  </config>
</configuration>

项目 packages.config-Files 中列出的包被下载到 Nuget.config -> repositoryPath 中指定的路径,但 .net-core 项目文件中指定的包(通过 PackageReference)全部下载到全局C:\Users\USERNAME\.nuget\packages 中的包目录。

无论我是使用 Visual Studio 2017 还是通过 nuget.exe 手动操作都没有关系。 .net-core 项目只是忽略 NuGet.config。

我们在这里做错了什么?

【问题讨论】:

  • 你没有做错什么。这是新项目系统处理 nuget 包的方式
  • @D.J.这有点不直观。我想决定把包裹放在哪里。

标签: nuget .net-core nuget-package-restore


【解决方案1】:

好的。知道了。将以下标签添加到 .csproj 文件就可以了:

    <PropertyGroup>
      ...
      <RestorePackagesPath>packages</RestorePackagesPath>
    </PropertyGroup>

来源:https://github.com/NuGet/Home/wiki/%5BSpec%5D-NuGet-settings-in-MSBuild

【讨论】:

    【解决方案2】:

    respositoryPath 用于 packages.config 项目

    globalPackagesFolder 用于 PackageReference 项目

    由于 packages.config 和 PackageReference 使用不同的文件夹格式,这些项目类型不能为包使用相同的文件夹,这就是为什么有两个不同的配置设置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多