1
votes

Is there an option to restore a NuGet package the the exact path defined in repositoryPath, ignoring any Package ID?

When restoring in Visual Studio 2017\2015 I get the path ..\Bin\PackageID. I want the files to restored to ..\bin.

My package contains no folders inside, only the files.

  • I use sample solution with no previous NuGet packages.
  • Files are restored to the correct folder (..\bin\ but have the PagackgeID as added folder).

My Nuget.config

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

My 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>

I will appreciate any help.

1
Im sorry there was an answer here ,it is now deleted maybe i did it by mistake , if so please repostgalsi

1 Answers

0
votes

Probably you use PackageReference, it's mean you can't use repositoryPath.

From nuget.config reference:

repositoryPath apply only to projects using packages.config.


I want the files to restored to ..\bin\

You can use RestorePackagesPath property for specify restore packages folder, but folder structure with PackageIdentity will save. I think to change this behavior isn't possible, anyway documentation about this I didn't saw.

From NuGet settings in MSBuild:

Path to the user packages folder. All downloaded packages are extracted here. Equivalent to --packages in dotnet restore.