CAUTION:This information is outdated. Information about the VisualStudioProjectRenamer can now be found on the info page. The latest releases can be found and downloaded from the download page.

If you ever have tried to rename a project from within Visual Studio, you may have noticed that the renaming process doesn`t really do what you think it would. Renaming the project doesn’t change the assembly name, the root namespace or the physical project folder name. How ever, there are ways to do all these changes manually like Steve Andrews explains in this post.

I wrote a little tool, that does all the work involved in a renaming process. This is for now only tested on my machine and there is a good chance that it contains bugs. So if you download the tool and you find any bugs, please leave a comment and I will try to fix them.

This is how the tool looks after you have fired it up:

VSPR1

If you click the browse button, you can pick your solution file that contains the project you want to rename. Note that the project needs to be located physically under the solution folder.

VSP§2

After selecting the solution and clicking okay, you will see all projects of the selected solution in the combobox. From here you can pick the project that you want to rename:

VSPR3

In the textbox below the combobox you can enter the new name for the project:

VSPR4

If your project is under version control, and for now this tool only supports SVN, you may check the upper checkbox. The difference is, that internally the svn move command is used to rename projects and files, while if the checkbox is unchecked, directory move and file move commands are used.

If you want the changes to be checked in automatically, you may check the “check in changes” checkbox. If you dont, you will have to check in your changes yourself.

If you are satisfied with your new project name, hit the rename button. This will start renaming your project and depending on the checkboxes, check in your changes into your repository.

So how does it all work? There are a few steps that are executed in a chronological order. In the first step, all references to the old project in the solution file are getting replaced with the new ones. In the second step, the project folder is renamed into the new one. In the third step, the project file (.csproj) itself is getting renamed. In the fourth step, all references in the project file are getting replaced. The fifth step takes care of updating the AssemblyInfo.cs file, and replaces all occurences to the old name with the new one. The last step, takes care of adjusting the namespaces in all your class files.

The tool is coded against the .net 4 framework. To use some of its functions, you need to have svn installed. The automatic check ins only work if you have saved your svn credentials. Also I recommend to close the solution in visual studio. Otherwise the tool wont be able to rename the project folder, because visual studio has a handle on that folder while the solution is opened.

Since this is a prototype, there will be a lot changes in the future for example:

  • Support more source control tools like tfs, git..
  • Possibility to enter credentials for the repository..
  • More validation..
  • Rollback on error..
  • Visual Studio extension..(which is already in the works but to be honest, the visual studio sdk api gives me a bit of a headache. There is not much documentation to it either, nor much tutorials.)

VSPR Studio Extension

If you have any ideas or suggestions on how to improve the renaming tool, please feel free to leave a comment.

IMPORTANT:

There is no warranty by any damage this tool may cause. Use it on your own risk. This is a prototype. Always backup your data before using this programm. The Rollback on Error functionallity is not yet implemented. So be carefull.

You can download the prototype from my download page.