Does anyone know of a way to make Visual Studio apply the NuGet package sources configuration per solution instead of across all solutions? I keep having versioning problems because I work on multiple projects that each have their own private NuGet repositories. It's a pain in the *** to keep remembering which NuGet repo belongs with which project and going back and applying the correct one to the correct project.
相关问题
- How to know full paths to DLL's from .csproj f
- Importing NuGet references through a local project
- Visual Studio 2019 - error MSB8020: The build tool
- 'System.Threading.ThreadAbortException' in
- VS2017 RC - The following error occurred when tryi
相关文章
- dotnet restore还原nuget包时无法加载 https://api.nuget.org/
- How to show location of errors, references to memb
- How to track MongoDB requests from a console appli
- Visual Studio Hangs on Loading UI Library
- How to use Mercurial from Visual Studio 2010?
- Copy different file to output directory for releas
- Edit & Continue doesn't work
- “Csc.exe” exited with code -1073741819
I want to add to the excellent answer provided by BenAlabaster. I had somewhat the opposite problem:
The company globally configured their custom private nuget feed for use on all solutions by default, and I wanted to make a "prototype" app using the public nuget feed.
With this (in the directory of that solution), the public nuget feed is available to my specific solution only, while keeping the company's feed the default for all other solutions:
The key was to clear all upwards disabled feeds, since they deliberately disabled the public feed in their NuGet.config in %APPDATA%\NuGet.
TLDR: Yes
NuGet uses a hierarchical application of package sources starting with the NuGet.config at the level of your Windows User Profile and then applying more and more granular configuration starting at the root of the file path that contains your solution, finally ending with the directory containing your solution file.
So here's what I've managed to figure out - courtesy of a helpful Twitterer pointing me to this document:
https://docs.nuget.org/consume/nuget-config-file
When you edit the NuGet package sources in Visual Studio's
Tools > NuGet Package Manager > Package Manager Settings: Package Sources
option, it applies those changes by default to the NuGet.config file found in your%APPDATA%\NuGet
directory. To override these settings on a per-solution (or per group of solutions) basis, you need to add a strategically placed NuGet.config file somewhere along the path of your solution or solutions.All will become clear if you read the NuGet document, the solution I provide below will quickly allow you to specify a configuration for a single Visual Studio solution:
If you want a configuration to apply to multiple solutions, ensure your solution folders are all contained within a common directory and put the NuGet.config for the package sources relevant for those solutions in that common directory, ensuring that any solution folders for projects that aren't to use these package sources are not contained in this common folder.