question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dotnet restore does not honour nuget.config 'repositoryPath'

See original GitHub issue

Steps to reproduce

  1. dotnet new in an empty directory
  2. Add the following nuget.config to the same directory
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <config>
        <add key="repositoryPath" value="c:\packages" />
    </config>
    <packageSources>
        <clear />
        <add key="NuGet" value="https://api.nuget.org/v3/index.json" />
    </packageSources>
</configuration>
  1. dotnet restore in the same directory

Expected behavior

Packages for the solution are restored to c:\packages

Actual behavior

Packages for the solution are restored to c:\users<username>.nuget\packages

Environment data

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information: Version: 1.0.0-preview1-002702 Commit Sha: 6cde21225e

Runtime Environment: OS Name: Windows OS Version: 6.3.9600 OS Platform: Windows RID: win81-x64

Additional

I understand that the packages path can be passed as an argument to the dotnet restore command, however this only works at the CLI level, what happens when Visual Studio does a restore? Previously, the packages path could be provided in the global.json (for DNX/RC1 ASP.NET projects) but this also no longer works.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
Kierantiescommented, May 21, 2016

@emgarten Thank you, I think that clears up the issue.

To confirm, creating a config as follows

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <config>
        <add key="globalPackagesFolder" value="c:\packages" />
    </config>
    <packageSources>
        <clear />
        <add key="NuGet" value="https://api.nuget.org/v3/index.json" />
    </packageSources>
</configuration>

and performing dotnet restore at the root of a solution restores packages to c:\packages

I can also confirm that performing restore in Visual Studio also recognised the configuration and restored to the configured path.


Question: Setting the value to simply packages (or any relative path) creates a packages folder relative to the project.json for each project in a solution that is restored. Is that expected behaviour?

9reactions
vcsjonescommented, May 19, 2016

I think dotnet and nuget in general prefer using the NUGET_PACKAGES environment variable now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dotnet restore does not honour nuget.config 'repositoryPath'
I understand that the packages path can be passed as an argument to the dotnet restore command, however this only works at the...
Read more >
NuGet Package Restore
NuGet Package Restore restores all of a project's dependencies that are listed in either a project file or a packages.config file. You can...
Read more >
Nuget package restore not respecting my repository path ...
(2) I edited the csproj file and noticed that the entry for packages.config had a <SubType>Designer</SubType> inner tag, which I removed. I ...
Read more >
Visual-studio – Change NuGet package location folder
I want to change NuGet package folder, but it does not change it. ... Dotnet restore does not honour nuget.config 'repositoryPath'. Update:.
Read more >
nuget package not found when using local nuget.config ...
error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found