How to rename a Project Folder from within Visual

2019-01-01 13:49发布

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?

30条回答
若你有天会懂
2楼-- · 2019-01-01 14:20

See item 3 in linked article.

  1. Close the solution and the IDE.
  2. In Explorer: Change the directory name to the new name.
  3. In Explorer: Open the .sln file with a text editor.
  4. Change the directory name to the new name and save.
  5. Restart the IDE and open the solution from the File, Recent Files menu if it doesn't start automatically.
  6. Click on the Project folder of the Solution Explorer and check the path property in the properties at the bottom. It will now be referencing to the new project folder.

It worked for me.

查看更多
旧人旧事旧时光
3楼-- · 2019-01-01 14:20

Proven solution for Visual Studio extension for Data Tools for Business Intelligence (SSDT-BI 2013):

  1. Move the Project folder to its new location (don't rename anything yet)
  2. In Solution Explorer, rename the Project / Solution.
  3. Close (and save) the newly-renamed project.
  4. Rename the project's folder and .sln file.
  5. Use a text editor and open the newly-renamed project solution file (.sln) (I used Notepad++)
  6. In line number 6 you'll see: "Project {fdjfksdjk4387!...} = "OLDPROJECT", "OLDFOLDER\OLDPROJECT.rptproj". Rename everything with the new names used in step 4. (i.e. ... = "NEWPROJECT", "NEWFOLDER\NEWPROJECT.rptproj"... )
  7. That's it!

Tested 100% and worked flawlessly on my case.

NOTE: Can't confirm if it works under different project templates a/o Visual Studio versions. As always, do backup everything beforehand.

查看更多
临风纵饮
4楼-- · 2019-01-01 14:21

When using TFS step 2 is actually to rename the folder in source control and then get the latest before reopening the solution.

查看更多
闭嘴吧你
5楼-- · 2019-01-01 14:24

Similar issues arise when a new project has to be created, and you want a different project folder name than the project name.

When you create a new project, it gets stored at

./path/to/pro/ject/YourProject/YourProject.**proj

Let's assume you wanted to have it directly in the ject folder:

./path/to/pro/ject/YourProject.**proj

My workaround to accomplish this is to create the project with the last part of the path as its name, so that it doesn't create an additional directory:

./path/to/pro/ject/ject.**proj

When you now rename the project from within Visual Studio, you achieve the goal without having to leave VS:

./path/to/pro/ject/YourProject.**proj

The downside of this approach is that you have to adjust the default namespace and the name of the Output binary as well, and that you have to update namespaces in all files that are included within the project template.

查看更多
人气声优
6楼-- · 2019-01-01 14:25

After changing the folder name, open the .sln file in notepad and change the path to new path.

查看更多
还给你的自由
7楼-- · 2019-01-01 14:26

We recently uploaded a beta of an free VS extension which does this stuff for you. Have a look at VS Gallery: Gallery Download

查看更多
登录 后发表回答