Grayson Mitchell
Grayson Mitchell

Reputation: 1187

how to rename a project without killing solution

When I rename a project within a solution, and then try and build that project, I get the error: "The project file "xyz.csproj" was not found. Where xyz is the old project file name!

The annoying thing is that I can search my project & solution for the old project file name, and the search will come up with nothing, and when I click on the error VS does nothing.

So there seems to be no way of finding where the old reference is.

This is a .web project hosting a silverlight page, if that makes any difference.

Upvotes: 10

Views: 4654

Answers (4)

Jim Lahman
Jim Lahman

Reputation: 2757

I also had to rename the namespace and point the project's startup object to the renamed program:

<old_project>.Program to <new_project>.Program

Upvotes: 0

Grayson Mitchell
Grayson Mitchell

Reputation: 1187

OK this was my problem. I deleted the service reference to the project I renamed, but still got the error message, then via some trial and error adding and removing projects I found that there is a "WCF Ria Services Link" Project property, doh.

That's a bit of a trap.

Upvotes: 0

Igor Zevaka
Igor Zevaka

Reputation: 76550

These are steps I follow when I rename a project:

  1. Click on the project in the solution and rename it. This renames the .proj file and the project name(but not the directory containing the project).
  2. Close solution, rename the project folder. At this stage, the solution still references the old folder.
  3. Open sln file and replace the old folder name with the new one. This should only be in one place. it will look something like this.
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SolutionName", "OldProjectName\NewProjectName.csproj", "{98644DD0-5AB5-4CAC-8D83-CCB8EEEFE234}"

You will need to make it look like this:

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SolutionName", "NewProjectName\NewProjectName.csproj", "{98644DD0-5AB5-4CAC-8D83-CCB8EEEFE234}"

Upvotes: 19

sunetos
sunetos

Reputation: 3508

With all visual studio projects, you can usually just close visual studio, edit the solution/project files with a text editor, and reopen visual studio. They're just XML. As long as you're careful not to change anything major, a search & replace in a text editor should do the trick.

Upvotes: 2

Related Questions