How to rename projects in Visual Studio?
When trying to change the name of a project in Visual Studio I noticed it wasn't as straightforward as I expected it to be. There were several problems when reloading the project and I had to change a lot more files than what I was used to. In order to not have to go through the same hell over and over again I decided to create a little tutorial for this.
Supposedly you have a solution structure as follows as opened in Visual Studio:
--- Solution 'Solution1'
------- ProjectABC
------- Project123
- In Solution Explorer: right click on
Solution 'Solution1'
→Rename
. - In Solution Explorer: right click on
ProjectABC
→Rename
and do the same forProject123
. - In Solution Explorer: right click on
ProjectABC
→Sync Namespaces
and do the same forProject123
to update the namespaces in your project. - Close the solution in
File
→Close Solution
. - In file explorer edit the folder names of the projects.
- Open the
.sln
file in a text editor like Notepad and edit the path to the.csproj
file. For example, change"ProjectABC\ProjectABCD.csproj"
to"ProjectABCD\ProjectABCD.csproj"
.
Possible errors
Solution cannot be renamed because solution files with the specified name already exist**
If you get this error in file explorer navigate to the root of your project and find the .vs
folder. Open this folder and delete the folder with the same name as you want to rename your solution to.
Sources: