My current solution for renaming the project folder is:
- Remove the project from the solution.
- Rename the folder outside Visual Studio.
- Re-add the project to the solution.
Is there any better way?
My current solution for renaming the project folder is:
Is there any better way?
For those using Visual Studio + git and wanting to keep file history (works renaming both projects and/or solutions):
1) Close Visual Studio
2) In .gitignore file duplicate all ignore paths of project you want to rename with renamed versions of those paths.
3) Use git move command like this:
See documentation for additional options: https://git-scm.com/docs/git-mv
4) In your .sln file: Find the line defining your project and change the folder name in path. The line should look something like:
5) Open Visual Studio, right click on project -> Rename
6) Afterwards rename the namespaces. I read that resharper has some options for this. But simple find/replace did the job for me.
7) Remove old .gitignore paths
Or simply,
Copy all the codes then open a new project with the desired name and paste the code. Run debug and then delete the previous project. Done!
It worked for me!
Although this question has already been answered I wanted to share my approach to solving this problem. I often had the same problem of renaming a project in VS and editing the folder name, project name and .sln file in order to accomplish that. I just wrote a VBScript that accomplishes all that. You have to be careful with the strings you choose for replacing.
EDIT: You just have to put the .vbs file in the same directory as the .sln file of the solution.
In andersjanmyr's answer its easier to rename the project first.
Also, after those steps are carried out you might want to rename other references to your old project name.
In project properties, update the Assembly Name and Default Namespace. This will update the following in the project file...
...and will get rid of the error "Namespace does not correspond to file location, should be: 'SomeProjectName'"
Rename your root namespace (if you have resharper right click the Namespace and go Refactor -> Rename).
Change all occurences of your old project name in AssemblyInfo.cs
Well I did it my way
What worked for me in 2017:
It said something like "re-adding project", I rebuilt everything and everything was good to go.