How can I rename a project folder from within Visual Studio?

TFS users: If you are using source control that requires you to warn it before your rename files/folders then look at this answer instead which covers the extra steps required.


To rename a project's folder, file (.*proj) and display name in Visual Studio:

  • Close the solution.
  • Rename the folder(s) outside Visual Studio. (Rename in TFS if using source control)
  • Open the solution, ignoring the warnings (answer "no" if asked to load a project from source control).
  • Go through all the unavailable projects and...
    • Open the properties window for the project (highlight the project and press Alt+Enter or F4, or right-click > properties).
    • Set the property 'File Path' to the new location.
      • If the property is not editable (as in Visual Studio 2012), then open the .sln file directly in another editor such as Notepad++ and update the paths there instead. (You may need to check-out the solution first in TFS, etc.)
    • Reload the project - right-click > reload project.
    • Change the display name of the project, by highlighting it and pressing F2, or right-click > rename.

Note: Other suggested solutions that involve removing and then re-adding the project to the solution will break project references.

If you perform these steps then you might also consider renaming the following to match:

  1. Assembly
  2. Default/Root Namespace
  3. Namespace of existing files (use the refactor tools in Visual Studio or ReSharper's inconsistent namespaces tool)

Also consider modifying the values of the following assembly attributes:

  1. AssemblyProductAttribute
  2. AssemblyDescriptionAttribute
  3. AssemblyTitleAttribute

This is straightforward in Visual Studio 2015 (possibly works in older versions)

  1. In Solution Explorer, right click on Main solutionRename
  2. In Solution Explorer, right click on project (under solution) → Rename
  3. In Solution Explorer, double click, or right click on Properties → goto Application Tab, rename Assembly name and Default namespace to match.
  4. If you wish to also rename the namespace, open one of your class files. Right click the namespace → Rename.... This should search and replace all references to your namespace throughout the project.
  5. Close the project → rename the project folder.
  6. Edit the .sln file in Notepad, and change the path to the csproj, i.e., fu\bar.csprojbar\bar.csproj.