My current solution for renaming the project folder is:
- Remove the project from the solution.
- Rename the folder outside Visual Studio.
- Re-add the project to the solution.
Is there a better way?
My current solution for renaming the project folder is:
Is there a better way?
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:
.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.)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:
Also consider modifying the values of the following assembly attributes:
AssemblyProductAttributeAssemblyDescriptionAttributeAssemblyTitleAttributeThere is another way doing this, using the *.sol, *csproj files.
It will be like this (relative to the *.sol file):
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shani.Commands.Impl", "Shani.Commands.Impl\Shani.Commands.Impl.csproj", "{747CFA4B-FC83-419A-858E-5E2DE2B948EE}"
And just change the first part to the new diretory for example:
Impl\Shani.Commands.Impl\Shani.Commands.Impl.csproj
Of course, don't forget to move the whole project to that directory.
Currently, no. Well, actually you can click the broken project node and in the properties pane look for the property 'Path', click the small browse icon, and select the new path.
VoilĂ :)
For those using Visual Studio + Git and wanting to keep the file history (works renaming both projects and/or solutions):
Close Visual Studio
In the .gitignore file, duplicate all ignore paths of the project you want to rename with renamed versions of those paths.
Use the Git move command like this:
git mv <old_folder_name> <new_folder_name>
See documentation for additional options: https://git-scm.com/docs/git-mv
In your .sln file: Find the line defining your project and change the folder name in path. The line should look something like:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "<Project name>", "<path-to-project>\<project>.csproj"
Open Visual Studio, and right click on project → Rename
Afterwards, rename the namespaces.
I read that ReSharper has some options for this. But simple find/replace did the job for me.
Remove old .gitignore paths.
Using Visual Studio 2019, I followed below steps to make the project name change successful:
What worked for me in Visual Studio 2017:
It said something like "re-adding project". I rebuilt everything and everything was good to go.
I've had to do this lots of times. It's really useful to be able to repurpose an existing project, but be able to rename text in namespaces, files, and folders (including file / directory names).
Using a recursive find and replace starting at the root folder means the rename doesn't break links to projects in the solution files and project references.
To this end, I have created a project to do just this. The application also makes an effort to ignore version control folders such as .git, .svn and the .vs settings file. More information is in the README.
https://github.com/garethrbrown/vs-project-rename

I just solved this problem for myself writing a global dotnet tool (that also takes into account git+history).
Install via
dotnet tool install -g ModernRonin.ProjectRenamer, use with renameproject <oldName> <newName>.
Documentation/Tinkering/PRs at
This worked well for me in Visual Studio 2019.
Please comment on and correct anything above that does not work.
This is how I renamed my existing project in VS19.
I am recently working on .Net 6 project with VS2022. and I need to rename my templatemicroservice to my UserMicroservice.
.Net 6 changes most of the things for you. like AssemblyNames and NameSpaces. Also, it changes the ProjectName references in .sln automatically. So, this answer will really help you to rename your service with no hurdles.
So, Steps I followed:
Open the solution in Visual Studio and did these steps:
TemplateServiceSolution to UserServiceSolution.TemplateService to UserService.namespace TemplateService and replaced all by namespace UserService. Do this step in each project. Also relplace using TemplateService to using UserService.launchsettings.json, and rename anything related to old service, as I had few things in profiles of launchsettings.json.Closed the solution from Visual Studio and did these steps:
TemplateService to UserService.TemplateService to UserService.

Open the solution in Visual Studio. Most of your Dependencies will be loaded as soon as you Load your solution in Visual Studio Code. and you are ready.
Rename the project in the solution and the project folder
Delete the project from the solution
Add the existing project to the solution (your renamed project)
It works for me. TFS will also track the new project.
You cannot rename a folder if your project is currently running
right-click > rename or F2)Open .sln in a text editor, and in the following line change <FolderName> to your new folder name Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ricky", "\.csproj", "{021CC6B0-8CFB-4194-A103-C19AF869D965}"
Go to the .sln file, right click, open with Notepad++ (or any editor; Notepad++ is the fastest), find the path, change it.
Or simply, copy all the codes, open a new project with the desired name, and paste the code. Run debug and then delete the previous project. Done!
It worked for me!
The other answers provide lots of details on how to do it. Here's a shortcut, though, that can save you some work:
.csproj fileThat way you don't have to mess around tediously with the Visual Studio GUI. You can also fix the namespace that way. You can use source control to validate the changes (e.g. open TortoiseGit Commit and look at the changes).
The simplest way:
Project -> Export Template... -> Project Template -> FinishFile -> New Project -> Find the template -> Give it the name you want -> Add to existing solution or just as newThat's it, you're done, you can now delete the other project if you want, but make sure the new one works as expected first. The template should retain all dependencies and project settings.
A bit late to the party but in VS2022 your suggested way was still the easiest for me (I do not like editing .sln files directly).
That is:
Remove the project from the solution.
Rename the folder outside
Re-add the project to the solution.
For example if you want to rename Project 'HelloWorld' to 'HelloStackOverflow'.