Home: Reload Visual Studio package sources when nuget.config is modified manually

Created on 8 Oct 2015  路  17Comments  路  Source: NuGet/Home

Visual Studio should reload nuget.config settings after the config files have been manually modified outside of Visual Studio. Today sources are only reloaded when the Tools > Options dialog is used.

This could be achieved by re-initializing settings before package restores and before package operations. Note: SourceRepositories should be kept between reloads to avoid losing cached data such as index.json.

Settings Backlog 2 VS.Client Feature

Most helpful comment

Yes please 馃槃

All 17 comments

Another alternative is to have a file watcher on all folders to indicate a change to nuget.config (need to track add/remove/move/change)

Yes please :smile:

FWIW, in WTE, NuGet.config changes will trigger a restore on .NET Core projects, but PMC and NuGet GUI still don't update to include latest sources.

We should fix this IMO.

Yes please 馃槃

Please, please!

This bit me recently several times as well, AFAIK it's not documented anywhere and it's hella confusing. "Just restart Visual Studio" is unfortunately becoming a more and more common answer from me in resolving problems. While this is far from the only issue, things like this contribute to the whole picture a user experiences.

I sure hope priority 1 makes this happen seeing how this issue is rather old considering how relevant it is

This should not just be restricted with package sources, I'll be fine with an explicit option to reload all applicable nuget.config files but at least some option instead of reload the solution itself.

Or maybe reload just happens (gets triggered) on any edit of package sources?

This is hitting me a lot. .NET Core projects are _not_ immune. Even if those projects do re-run a restore when nuget.config changes, they do so with the old content of nuget.config. Package restore fails if the changes to nuget.config added a package source that restore then needs.

I hit this on branch switch, pull, or manually modifying the file. I have to reload the solution in VS before package restore will work again.

4 years later and still getting the same issue, is there a fix for this yet?

/cc: @karann-msft

I hit this on branch switch, pull, or manually modifying the file. I have to reload the solution in VS before package restore will work again.

鈽濓笍 is one of the main scenarios for auto-loading the nuget.config file. At the minimum NuGet should not require a solution reload. IMO, the reload button should be overloaded to refresh the nuget.configs as well. We may need to also work on the positioning of the button to imply this overload.
image

Discussed possible solutions as a team today...

Scenarios missing:

  • Branch Switch
  • Git Pull

Possible solutions:

  • listen to "branch switch" or "pull" type events in VS
  • File watcher (existing nuget.config)
  • watch for new files created in right directories
  • Manual refresh in UI somewhere
  • Overload in build/rebuild
  • etc...

No slam dunk solution, but we are thinking about it.

Please make sure you're watching the file for changes independently of a git HEAD change. If having the file is valid, changing the file is valid too. :)

A note for the implementer that the IVSPathContextProviderX API should be considered when making this change.

Was this page helpful?
0 / 5 - 0 ratings