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:34

There's a simpler approach which was tested in VS 2013 Update 1 and applicable for TFS-connected projects:

  • Open VS but let the solution closed
  • Open Source Explorer and rename the desired folder (the solution will be closed for you if you didn't already close it first)
  • Right-Click on the solution (from Source Explorer also) and select check-in
  • Open the solution, you'll told that there're new projects added, accept to get the changes.
  • Remove the project from the solution and add it again, then check-in
  • Check that the internal references are OK
查看更多
骚的不知所云
3楼-- · 2019-01-01 14:34

The simplest way is to go to the property of the window change name of default namespaces then the rename is done

查看更多
孤独寂梦人
4楼-- · 2019-01-01 14:37

There is another way doing this, using the *.sol, *csproj files.

  1. open your solution file
  2. search for the *.csproj you would like to change
  3. it will be like this (relative to the *.sol file):

    Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shani.Commands.Impl", "Shani.Commands.Impl\Shani.Commands.Impl.csproj", "{747CFA4B-FC83-419A-858E-5E2DE2B948EE}"

  4. and just change the first part to the new diretory for example:

    Impl\Shani.Commands.Impl\Shani.Commands.Impl.csproj

  5. of course don't forget to move the whole project to that directory

Have fun.

查看更多
临风纵饮
5楼-- · 2019-01-01 14:38

@andersjanmyr's Solution: you may press Alt+Enter to bring up the Properties Page for the unavailable project and set the "File Path" property there; since it is not available in the right-click_context-menu of the unavailable project (in VS2008).

查看更多
梦寄多情
6楼-- · 2019-01-01 14:39

For VS2017 you can use my visual studio extension

download

It will rename project in:

  • project location folder
  • solution file
  • reference in other projects
  • assembly name, information
  • default namespace
查看更多
看风景的人
7楼-- · 2019-01-01 14:40
  1. Rename project in solution and the project folder

  2. Delete project from solution

  3. Add existing project to solution(your renamed project)

It works for me. TFS will also track new project.

查看更多
登录 后发表回答