NUGET恢复包没有文件夹?

时间:2018-05-06 06:54:42

标签: nuget nuget-package nuget-package-restore

是否可以选择将NuGet包恢复为repositoryPath中定义的确切路径,忽略任何包ID?

在Visual Studio 2017 \ 2015中进行还原时,我得到路径.. \ Bin \ PackageID。 我希望文件恢复到.. \ bin。

我的软件包里面没有文件夹,只包含文件。

  • 我使用的样本解决方案没有以前的NuGet包。
  • 文件将恢复到正确的文件夹(.. \ bin \但将PagackgeID作为添加的文件夹)。

我的Nuget.config

<configuration>
    <config>
        <add key="repositoryPath" value="../Bin" />
    </config>
</configuration>

我的PackageCode

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>Bint</id>
    <version>1.0.0</version>
    <title></title>
    <authors>admin</authors>
    <owners>admin</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>My package description.</description>
    <dependencies>
      <group targetFramework=".NETFramework2.0" />
      <group targetFramework=".NETFramework3.5" />
      <group targetFramework=".NETFramework4.0" />
      <group targetFramework=".NETFramework4.5" />
      <group targetFramework=".NETPortable0.0-Profile259" />
      <group targetFramework=".NETPortable0.0-Profile328" />
      <group targetFramework=".NETStandard1.0" />
      <group targetFramework=".NETStandard1.3" />
      <group targetFramework=".NETStandard2.0" />
    </dependencies>
  </metadata>
</package>

我将不胜感激。

1 个答案:

答案 0 :(得分:0)

您可能使用PackageReference,这意味着您无法使用repositoryPath

来自nuget.config reference

  

repositoryPath仅适用于使用packages.config的项目。

  

我希望将文件恢复到.. \ bin \

您可以使用RestorePackagesPath属性指定还原包文件夹,但保存PackageIdentity的文件夹结构。我认为改变这种行为是不可能的,无论如何关于这个的文档我都没有看到。

来自NuGet settings in MSBuild

  

用户包文件夹的路径。所有下载的包都是   在这里提取。相当于--packages中的dotnet restore