Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio retrieving an incorrect path to a project from somewhere

Visual Studio (and possibly TFS) has somehow (I think perhaps during a source control merge) become confused about the path of a project within my solution.

It thinks it is here (example paths for simplicity):

C:\My Projects\ExampleSolution\ExampleProjectWrong\ExampleProjectCorrect.csproj 

whereas actually, the project file is located here:

C:\My Projects\ExampleSolution\ExampleProjectCorrect\ExampleProjectCorrect.csproj 

I cannot for the life of me get it to recognize the correct location. I have tried:

  • Removing and re-adding the project from the correct location. An error message comes up saying The project file at C:\My Projects\ExampleSolution\ExampleProjectWrong\ExampleProjectCorrect.csproj could not be found.

  • Manually editing the .sln file to ensure all references to ExampleProjectCorrect.csproj have the correct paths.

  • Doing a find in files on the solution directory for both the correct and incorrect paths, to try and track down where studio is hiding the incorrect path.

  • Deleting the cache directories for VS and TFS

I'm tearing my hair out because I can't recreate the solution as it has near as makes no difference 100 projects in and is tied in to source control with several other developers working on it.

Can anyone point me in the right direction as to where it is storing this incorrect path and/or how to reset it so the damn thing will load correctly?

like image 659
Charlie Drewitt Avatar asked Oct 06 '11 10:10

Charlie Drewitt


People also ask

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.

Should you place solution and project in the same directory Visual Studio?

If you have a web application project, the project file is typically placed in the same folder as the web files. If you add more projects to your solution, you can choose where to store the solution.

How do I find the file path in Visual Studio?

Did you know you can right click on the tab in the code editor window to access the file path or to open the folder in Windows Explorer? Check it out. By default, the file path for Visual Studio projects is very long.


2 Answers

  1. Go to Manage Workspaces (either through the File/Source Control menu or the workspace drop down in Source Control Explorer)
  2. select edit for your workspace.
  3. You should see, under working folders, a mapping for the source control directory to the old/wrong project directory.
  4. Select it and click remove.
  5. Close VS and delete the suo file.

It still references the wrong directory. Maybe rebinding might work at this point but I didn't try that. Reload your project and you should be good to go.

like image 150
Benjamin Potts Avatar answered Sep 24 '22 02:09

Benjamin Potts


Simply deleting the solutions .suo file worked for me.

like image 29
Lloyd Powell Avatar answered Sep 23 '22 02:09

Lloyd Powell