Monday, July 11, 2011

How to Rename projects in Visual Studio

I was trying to rename some of the sample visual studio projects on my laptop. Though it looked like a trivial operation, soon I realized that there is so much more to it than what meets the eye. I am putting together what I gathered below so that someone might profit out of it. So here are the steps:

1.       Make sure that the solution that contains the project (to be renamed) is compiling error free.
2.       Rename the Project by pressing “F2” (or using rename context menu) in the Solution Explorer.
3.       Rename the Assembly name and Default namespace in the Project property(Alt + Enter on project in the solution tree) -> Application tab.
4.       Use Refactor -> Rename context menu(or F2) to rename any classes, if applicable
5.       Find and replace the old name with the new name (where ever applicable) in the whole solution.  This will take care of changes required in AssemblyInfo, comments (xml, user comments), configuration files, namespaces etc.
6.       Rename the windows folder, where the project physically resides to match the new namespace or assembly name. (this is often missed)
7.       Rebuild and ensure that the solution is compiling properly, if not fix all errors.
8.       Do a clean at the solution level to remove all the dlls with old names.
9.       From the root directory of the project do a windows content search on the old project name.
a.       If the search result returns dlls,pdbs, FileListAbsolute.txt  then delete them, otherwise do the necessary fix.

Feel free to throw in your suggestions and additions/corrections.

Praveen