Skip to content

Instantly share code, notes, and snippets.

@miseeger
Forked from n3dst4/renaming.markdown
Created January 26, 2020 13:31
Show Gist options
  • Save miseeger/a0fb154b3320620c1f8b17686c0b9609 to your computer and use it in GitHub Desktop.
Save miseeger/a0fb154b3320620c1f8b17686c0b9609 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment