views:

29

answers:

3

Lets say you open a .NET solution (mine being VS 2010) after you just moved your entire folder to some new location locally. Now one of the projects that was being referenced in that solution is not there and so when you launch VS, it naturally tells you that the project is missing and therefore as always you see the project greyed out in Solution Explorer.

Ok, well I can't go re-add that project (specify a different path for where that project lives) unless I remove the missing project reference and then try to re-add it back to the solution.

But how can I reassociate a project without losing all references in other projects that were referencing that missing project? Is this possible? Otherwise every time I re-add that missing project, I end up having to go through about 8 projects of mine that are referencing it and re-reference it for each one of those projects which is tedious. I guess it makes sense since each project was referencing that missing project at that old path so it would break it there as well but is there an easier way to re-associate a project and references to that missing project without having to take 10 minutes every time to re-associate it all over the place if simply the path has changed?

A: 

Not sure if there's some nice GUI way of doing it, but it might be easier to just use a text editor with Find-In-Files/grep ability to search for all instances of the old file in all project/solution files and then just replace them by hand rather than via the GUI.

ho1
Well in my case I can't just move the project. I'm creating a copy of it to branch it out and I keep my branch folders in a different root that the original was being referenced in.
CoffeeAddict
+1  A: 

You have two solutions:

  1. Move the missing project so that it's in the same location relative to the other projects as it was before.

  2. Readd the project to all the solutions that are referencing it.

I'd go with the former - unless you have other projects referencing that project.

If you just close the solution without saving, move the missing project and then re-open the solution Visual Studio should just find it.

ChrisF
+1  A: 

Open the .sln file in Notepad and change the path in the Project statement near the top of the file. No need to change the path in the <ProjectReference> elements in the .csproj files, they'll get automatically updated.

Hans Passant

related questions