如何在Visual Studio中重命名项目文件夹? [英] How can I rename a project folder from within Visual Studio?
问题描述
我当前用于重命名项目文件夹的解决方案是:
My current solution for renaming the project folder is:
- 从解决方案中删除项目.
- 重命名Visual Studio外部的文件夹.
- 将项目重新添加到解决方案中.
有更好的方法吗?
推荐答案
TFS users: If you are using source control that requires you to warn it before your rename files/folders then look at this answer instead which covers the extra steps required.
要在Visual Studio中重命名项目的文件夹,文件(.*proj
)和显示名称:
To rename a project's folder, file (.*proj
) and display name in Visual Studio:
- 关闭解决方案.
- 重命名Visual Studio外部的文件夹. (如果使用源代码管理,请在TFS中重命名)
- 打开解决方案,忽略警告(如果要求从源代码管理中加载项目,请回答否").
- 浏览所有不可用项目,然后...
- 打开项目的 properties 窗口(突出显示项目,然后按 Alt + Enter 或 F4 ,或右键单击>属性).
- 将属性"文件路径"设置为新位置.
- Close the solution.
- Rename the folder(s) outside Visual Studio. (Rename in TFS if using source control)
- Open the solution, ignoring the warnings (answer "no" if asked to load a project from source control).
- Go through all the unavailable projects and...
- Open the properties window for the project (highlight the project and press Alt+Enter or F4, or right-click > properties).
- Set the property 'File Path' to the new location.
- If the property is not editable (as in Visual Studio 2012), then open the
.sln
file directly in another editor such as Notepad++ and update the paths there instead. (You may need to check-out the solution first in TFS, etc.)
注意:其他建议的解决方案,包括删除项目然后将其重新添加到解决方案中,将会破坏项目引用.
Note: Other suggested solutions that involve removing and then re-adding the project to the solution will break project references.
如果执行这些步骤,则可能还会考虑重命名以下内容以匹配:
If you perform these steps then you might also consider renaming the following to match:
- 组装
- 默认/根命名空间
- 现有文件的命名空间(使用Visual Studio中的重构工具或 ReSharper的命名空间不一致工具)
- Assembly
- Default/Root Namespace
- Namespace of existing files (use the refactor tools in Visual Studio or ReSharper's inconsistent namespaces tool)
还考虑修改以下程序集属性的值:
-
AssemblyProductAttribute
-
AssemblyDescriptionAttribute
-
AssemblyTitleAttribute
AssemblyProductAttribute
AssemblyDescriptionAttribute
AssemblyTitleAttribute
这篇关于如何在Visual Studio中重命名项目文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- If the property is not editable (as in Visual Studio 2012), then open the