One of the problems beginners face when using Visual Studio happens when they try to rename a project since there will be a lot of leftovers in the process. This can be a problem even for professionals if they find out that the project name cannot be used, for example, in patents or copyright situations. Today we are going to fully rename a Visual Studio Project.
Note: This guide works with every version of Visual Studio and every kind of .NET Project.
Renaming the solution is actually the simplest part of the process. Just click on the solution item in Solution Explorer twice (but do not double click) to get an editable field and then type the new name.
In most of the cases your project name will match your solution name so just repeat the steps on the project item instead of the solution.
Renaming the project actually does not change the folder your project is contained. When you do the first step you will have this situation:
<root> |- NewName.sln |- OldName |- NewName.csproj (or vbporj, vcxproj...)
In order to get the new name on the project folder you have to:
- Rename the folder itself
- Open the sln file with a text editor like notepad and do a Find&Replace to replace the old name with the new name.
Note: You can also remove the wrong project inside Soluton Explorer and add the correct one back.
Executable (or Library) Name is actually pretty easy to do: just right-click on your project in Solution Explorer and choose Properties.
In the application ta you will see the Assembly Name text box. Just change these and you are ready to go.
You may not want to keep the namespaces containing the name of your application, especially if you are using a name that you cannot use.
To do this, first of all, change the Default Namespace in the project properties like you did in Step 3. and then you can use Find&Replace to change any reference to the old name in the new one.
Alternatively you can rename the namespace in one of your files and then use the refactoring tool (the little box appearing under the namespace when you edit it) to replace any reference.