Skip to content

Instantly share code, notes, and snippets.

@dhamaso
Forked from n3dst4/renaming.markdown
Created September 17, 2020 01:59
Show Gist options
  • Save dhamaso/52ccfbf216b99680d9c331b39031d493 to your computer and use it in GitHub Desktop.
Save dhamaso/52ccfbf216b99680d9c331b39031d493 to your computer and use it in GitHub Desktop.
How to rename Visual Studio solutions and projects

How to rename solutions and projects in Visual Studio

  1. Don't.

How to rename solutions and projects that were created in Visual Studio

  1. Close Visual Studio and don't open it again until I tell you. Visual Studio is not competent at renaming things.

  2. Assuming you're using git, clean the working folder to remove anything that's not in version control (this will help the search-and-replace step because it won't have to go through a bunch of generated files)

    git clean -fdx

  3. Rename the solution file (.sln), the project folders, and the project files (.csproj, .fsproj)

  4. Open the project folder in any good text editor.

  5. Search-and-replace across the whole folder and replace and text occurrences of the old name with the new name. Sublime Text and Atom have a tree view where you can right click -> Search in folder. Notepad++ has a "Find in files" option.

  6. Hunt around for any weirdly mis-spelt versions of the old name that may not have been caught by the search-and-replace.

  7. Specifically, look for a package.nuspec (Nuget package manifest) and check the package name in there. It should probably be the same as the solution.

  8. (Finally) Open VS again and see if the project loads.

  9. See if it builds.

  10. Commit and push everything.

  11. Don't forget to update any corresponding servcies and integrations, such as:

    • Github repositories
    • Continuous Integration configs

Update 2020-09-04

ModernRonin has written an automated tool for doing this - give it a go before trying the manual steps here, and let us know how it goes!

https://github.com/ModernRonin/ProjectRenamer

https://www.nuget.org/packages/ModernRonin.ProjectRenamer/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment