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 | build | publish do not respect nuget.config repository path

See original GitHub issue

Steps to reproduce

use cli to restore | build | publish a project which has a nuget.config with a specific repository path.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <add key="enabled" value="True" />
  </packageRestore>
...
  <config>
    <add key="repositoryPath" value=".\utpackage" />
  </config>
...
</configuration>

however if you create the following global.json in the same directory it functions as expected:

{
  "packages": "utpackage"
}

Expected behavior

dotnet cli should respect both global.json packages property and nuget.config repositoryPath

Actual behavior

if only the nuget.config is present packages are restored to and referenced from the global packages cache

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc2-002468)

Product Information: Version: 1.0.0-rc2-002468 Commit Sha: a2f3c531fb

Runtime Environment: OS Name: Windows OS Version: 10.0.14318 OS Platform: Windows RID: win10-x64

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
emgartencommented, Apr 28, 2016

The order should be:

  1. --packages
  2. NUGET_PACKAGES
  3. globalPackagesFolder from nuget.config
  4. default location

dotnet restore reads the packages parameter first here: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Commands/RestoreCommand/RequestFactory/RestoreArgs.cs#L68-L80

Then checks the environment variable and settings here: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Configuration/Utility/SettingsUtility.cs#L127-L154

The global folder path in global.json was deprecated and is not used by NuGet.

repositoryPath refers to to the packages folder for packages.config and should not be used with project.json

0reactions
TheRealPiotrPcommented, Jan 20, 2017

I reread the issue and realized I offered a workaround instead of a fix. Will open an issue on nuget/home instead, link to this one, and then close this one. It is up to nuget xplat to honor this configuration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dotnet restore does not honour nuget.config 'repositoryPath'
The model is the identity is id + version and that's it. The repository path will never be respected. It is the path...
Read more >
dotnet restore command - .NET CLI
Specify feeds. To restore the dependencies, NuGet needs the feeds where the packages are located. Feeds are usually provided via the nuget.
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 >
NuGet packages in the Package Registry
Publish NuGet packages in your project's Package Registry. Then, install the packages whenever you need to use them as a dependency.
Read more >
Dotnet restore clean. cs files) Removing information from ...
For example: msbuild <file name>. The folder does not have any spaces in it. The NuGet package restorer used to restore solution packages....
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