1

I have a nuget.config for my project and have specified a repositoryPath. I also have specified the globalPackagesFolder.

<config>
<add key="globalPackagesFolder" value="c:\p" />
<add key="repositoryPath" value="c:\p" />
</config>

Now I want to install a third party package to my project. This package is located correctly at my specified path.

When I try to install another package, that has a dependency to System.Net.Http which has other sub-dependencies, nuget is not able to install this package, because the path is too long.

The direct dependecies are located in my specified repositoryPath from the nuget.config. The problem is, that sub-dependencies are not located at this path. A file search in this repositories resulted in no matches.

The only reason I specified a repositoryPath in nuget.config is that I wanted to move the sub-dependencies to another folder, because otherwise the path is too long and nuget can't install the package. This is not a problem for my co-workers.

How can I change this behavior?

If this is not possible, is there another solution to my problem? A co-worker sugested to shorten my Windows login, but this is not a solution. I also can't shorten our Teamcity user login name.

The package I try to install is developed by my company. So if I have to change settings in the package, this is not a problem.

I tried with Visual Studio 2017 Pro and Enterprise with Nuget 4.6.0 and Visual Studio 2019 RC with Nuget 5.0.0. Target Framework is .NET Core 2.1

When I add the package System.Net.Http to my project manualy and install the package, there is no problem, but i would rather don't do this, unless there is no other solution.

Edit: To clarify the situation: If I install Package A that has a dependency to package B and B has a dependency to Package C, Package A is in my specified Path, but B and C are not. I don't even know, where Package B and C are located.

4
  • You mean the dependency System.Net.Http is in the specified path but the dependencies of System.Net.Http are not in that path? What are the dependencies, or all dependencies of System.Net.Http are not in that path? And what is your target framework?
    – Leo Liu
    Commented Mar 4, 2019 at 9:09
  • I want to install package A. That has a dependency to System.Net.Http. System.Net.Http has other dependencies, which I can't install, because the path is too long. A co-worker has everything installed. Package A is located under the specified repositoryPath, but there is no System.Net.Http in this path. And that is my problem. I want all packages in repositoryPath, not just the top level ones. I want to include the sub-dependencies in this path. Seems like they are in some cache in my user folder. My target Framework is .NET Core 2.1 Commented Mar 4, 2019 at 9:28
  • Thanks for your reply. To confirm more info, Are you set something in the nuget.config like this: <add key="repositoryPath" value="SpecifiedPath " />? If yes, you may have done something wrong, this set is for package.config, not for .net core project. But why the package A set in the Specified Path, that strange.
    – Leo Liu
    Commented Mar 4, 2019 at 9:40
  • I tried repositoryPath and globalPackagesFolder in the config section of nuget.config. I have no NUGET_PACKAGES environment variable. <add key="globalPackagesFolder" value="c:\p" /> and <add key="repositoryPath" value="c:\p" /> We have core and standard, so that is why we have both entries in the config. Commented Mar 4, 2019 at 9:43

1 Answer 1

1

nuget.config ignores dependencies of dependencies (sub-dependencies)

This is the correct behavior for .NET Core project.

In dotnet core, or projects that use PackageReference, reference to only the immediate dependencies are listed and only download the immediate dependencies to the package cache.

That is the reason why you install Package A that has a dependency to package B and B has a dependency to Package C, Package A is show up in your project file like:

<PackageReference Include="PackageA" Version="1.0.0" />

and cache in your specified Path, but B and C are not.

This is a one of the biggest advantages of PackageReference where we don't clutter the project file with gazillion dependencies which the consumer probably doesn't care about. Install your nuget package to a project, navigate to the project_root/obj/project.assets.json and open this json, you'd see your package listed along with its dependencies. If you see your intended dependencies here, it validates that package is authored correctly. But NuGet will not restore the dependencies to the packages cache unless you install these dependencies directly.

Hope this helps.

3
  • Okay thanks. So I stick with adding all references to my project directly, where the path is too long? I hope that Nuget will remove the character limitation soon. Commented Mar 5, 2019 at 10:29
  • But if you add all references to your project directly and with the setting <add key="globalPackagesFolder" value="c:\p" />, those references will cached at c:\p. Then you still get the path is too long error?
    – Leo Liu
    Commented Mar 5, 2019 at 11:51
  • no, then I won't get this error. But for me that is just a temporary fix. Commented Mar 6, 2019 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.