10

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.

Grayson Mitchell
  • 1,187
  • 4
  • 22
  • 43
  • Are you renaming it within VS, via Windows Explorer (your normal file browser), or via your source control client? – jyoungdev Jul 09 '10 at 00:31
  • When you open the solution, can it load the project in question? – Igor Zevaka Jul 09 '10 at 00:33
  • possible duplicate of [How do I rename a Project Folder from within Visual Studio?](http://stackoverflow.com/questions/211241/how-do-i-rename-a-project-folder-from-within-visual-studio) – Tim Abell May 23 '14 at 22:26

4 Answers4

19

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}"
Igor Zevaka
  • 74,528
  • 26
  • 112
  • 128
  • 4. Change the old folder's name to the new name – Hexo Jan 30 '14 at 14:29
  • another answer says that after you rename project namespace, on properties of solution Unload it, then close project, rename project's folder, load it again, then on properties can point to correct path (it allows to edit it) and then (as a additional step npot mentioned) delete reference to that project and add it again (if it cannot compile) – FabianSilva Aug 25 '14 at 13:30
2

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.

sunetos
  • 3,448
  • 1
  • 23
  • 14
0

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
Jim Lahman
  • 2,691
  • 2
  • 25
  • 21
0

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.

Grayson Mitchell
  • 1,187
  • 4
  • 22
  • 43