Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add existing project to Visual studio 2012 after renaming the project path

I had a C# class library project as part of my solution. I later updated the root folder of the project. Since the solution was pointing to the wrong path, I had to "delete" the project and then re-add it. However, when I add the existing project, it says "The project file \myproject.csproj' has been moved, renamed or is not on your computer".

This is baffling because the .sln file has no reference to the project. (I checked the text contents) How does VS cache the project with it's old folder path? The solution is version controlled in TFS, but the mappings point to the new folder structure, so it's even more confusing as to where it's trying to get the old folder path from.

Edit: I checked the .csproj file, the .csproj.vspscc and none of them have a path variable in them. I have also tried deleting the .suo file.

like image 289
arviman Avatar asked Sep 19 '14 06:09

arviman


People also ask

How do I add an existing project to Visual Studio?

To add an existing project to a solutionOn the File menu, point to Add, and click Existing Project. In the Add Existing Project dialog box, locate the project you want to add, select the project file, and then click Open. The project is added to the selected solution.

How do I change the path of a project in Visual Studio?

In Visual Studio, click Tools > Options. Expand Projects and Solutions and click Locations. The Projects location field defines the default location for storing new projects. You can change this path if you are using a different working folder.


1 Answers

This has been a trouble with Visual Studio for years now. In such a case, deleting the hidden .suo file in the root folder and restart VS will reconstruct a proper .suo file and almost always eliminate the issue.

If you use TFS, take a look at Just TFS' comment in the original post to avoid this problem in the future.

like image 102
Patrice Gahide Avatar answered Oct 02 '22 03:10

Patrice Gahide