Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Reset HintPath After Changing Repository Path

I have a Visual Studio 2012 solution with several projects. All the projects are unable to build because the location NuGet is restoring packages to is different than what is indicated by all the hintPath tags inside the various VS projects.

How do I cause all the hintpaths in all projects throughout the solution to be reset or deleted - so that the proper location of the dependencies can be established?

Ok, how I got myself into this mess is as follows:

  1. Create a nuget.config file in the directory above the VS solution. The nuget.config points to repository folder "Alpha".
  2. Add projects to the VS solution, and add NuGet package references throughout.
  3. Build, everything works.
  4. Close Visual Studio and edit the nuget.config file (from step 1) so that it now points to the "Bravo" repository folder
  5. Open Visual Studio and reload the VS solution.
  6. If package manager says that packages are missing, allow it to download the missing packages.
  7. Attempt to build - countless errors emerge saying that I may have forgotten to declare namespaces.

All the packages are downloaded successfully, and placed into the new repository location, but the VS projects still have hintpaths that point to the old location. Even worse, Visual Studio is unable to recognize that the referenced assemblies are no longer there. Instead of showing a yellow warning by each missing reference in the solution explorer, it acts as if they are found.

Changing the NuGet repository path should not leave the solution crippled and practically unfixable. Requiring a developer to regex search/replace hundreds of hintpaths manually through each project is gauche.

like image 682
Brent Arias Avatar asked Jun 11 '14 23:06

Brent Arias


1 Answers

You could try reinstalling all the NuGet packages. You can do this in the Package Manager Console window:

Update-Package -reinstall -ignoredependencies

I would make sure you have a backup of the source code or have the code in source control before running this command.

like image 154
Matt Ward Avatar answered Oct 20 '22 10:10

Matt Ward