Search code examples
nuget

NuGet Pack -- Failed to retrieve information from remote source


I am trying to run:

nuget pack project.csproj

but because of the directory structure of the project:

A\B\C\Project

it keeps saying:

NuGet.Protocol.Core.Types.FatalProtocolException: Failed to retrieve information from remote source 'A\B\Packages', which it really should be 'A\Packages'. How do I change where NuGet looks for packages while establishing dependencies.

I have tried putting a NuGet.config in both the project directory as well as the Solution (in .nuget). I added this to the file:

<config>
    <add key="repositoryPath" value="A\Packages" />
</config>

in both places and it made no difference (it always says A\B\Packages).


Solution

  • The error is a bit weird, but is already mentioned here.

    It looks like NuGet by default expects a packages folder at the same location as the .csproj file.

    I also had a custom project structure where the .sln was located in another folder.

    At least I worked around this by creating a Symbolic link like this (open cmd with admin rights):

    cd <your .csproj location>
    mklink /d packages "C:\path\to\actual\packages"
    

    This way NuGet thinks the packages folder exists and should be able to create your package.