I am migrating an MVC ASP.NET Visual Studio 2010 project to Visual Studio 2019.
The Visual Studio 2010 project uses some old jQuery NuGet packages that I can't update to current ones due to time constraints and the numerous changes through out the project that doesn't fit into my current scope.
The migrated 2019 project shows a number of errors all relating to the NuGet packages:
NuGet Package restore failed for project MyWebProject: Unable to find version '3.2.0' of package 'Microsoft.jQuery.Unobtrusive.Ajax'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'Microsoft.jQuery.Unobtrusive.Ajax.3.2.0' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
Please see Error List window for detailed warnings and errors.
NuGet Package restore failed for project MyWebProject: Unable to find version '2.1.1' of package 'jQuery'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'jQuery.2.1.1' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
Please see Error List window for detailed warnings and errors.
...
...
...
In the Visual Studio 2019 project, when I view the NuGet Installed packages, I see the packages listed but with a message Not available in this source
According to the error messages, Visual Studio is looking for the packages in C:\Program Files(x86)\Microsoft SDKs\NuGetPackages; however it should be looking in a directory named "packages" that actually contains the packages.
I have placed the packages directory within the same directory as the project (but it would be better to put them in a common resource directory so that the team can find them when/if they are working on this project). I have also edited the repositories.config file within the packages directory to point to the packages.config file for the project.
I can restore all of this back to default if required.
Nothing I have done has helped me get past this problem.
How do I direct Visual Studio 2019 to use the packages that exist within a directory that is not the Program Files directory?
Thanks
How do I direct Visual Studio 2019 to use the packages that exist within a directory that is not the Program Files directory?
According to your error message: Please go Tools=>Options=>Nuget Package Manager to check your settings about Package sources.
Maybe you haven't checked the nuget.org as your package sources. Please check this settings:

In VS, when you click the Restore Nuget Packages option, it will search the packages from available sources. Most of the time the package which we need to restore comes from Nuget Gallery. Just like the JQuery 2.1.1, so by default we will set nuget.org as our necessary package sources.
I've checked if I uncheck the nuget.org then I got the same issue like yours.
So please:
1.Check the nuget.org as your package sources, if it not exists, just click the green + to create a new sources and set its source as https://api.nuget.org/v3/index.json
2.If the nuget.org exists with checked status, make sure its link is correct In addition:
however it should be looking in a directory named "packages" that actually contains the packages.
If the packages folder you mean is the one locates in Solution directory: In my opinion, Restore Nuget Package doesn't mean searching sources from the packages folder, instead it will search packages from available package sources and install them to packages folder if something is missing in the packages folder.(for packages.config format)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With