我有一个相当复杂的Visual Studio解决方案(2010年,但这不重要),我需要重命名。
我想重命名文件夹以匹配新的解决方案名称,但我无法找到自动重构文件夹名称的方法,而且查看每个项目文件将是一件痛苦的事情。
有官方的做法吗?
我有一个相当复杂的Visual Studio解决方案(2010年,但这不重要),我需要重命名。
我想重命名文件夹以匹配新的解决方案名称,但我无法找到自动重构文件夹名称的方法,而且查看每个项目文件将是一件痛苦的事情。
有官方的做法吗?
当前回答
重命名一个解决方案:
In Solution Explorer, right-click the project, select Rename, and enter a new name. In Solution Explorer, right-click the project and select Properties. On the Application tab, change the "Assembly name" and "Default namespace". In the main cs file (or any other code files), rename the namespace declaration to use the new name. For this right-click the namespace and select Refactor > Rename enter a new name. For example: namespace WindowsFormsApplication1 Change the AssemblyTitle and AssemblyProduct in Properties/AssemblyInfo.cs. [assembly: AssemblyTitle("New Name Here")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("New Name Here")] [assembly: AssemblyCopyright("Copyright © 2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] Delete bin and obj directories physically. Rename the project physical folder directory. Open the SLN file (within notepad or any editor) and change the path to the project. Clean and Rebuild the project.
其他回答
The Rename operations in Visual Studio only change the filename, i.e. *.prj for a project, and *.sln for a solution. You will need to rename folders separately using the filesystem, and you will need to remove and re-add the projects since they will have new folder names. However, note that the solution and project files are respectively text and xml files. You could write your own program that parses them and renames both the folder names, filenames, and fixes the project/solution files internally.
连同这个链接的答案
https://stackoverflow.com/a/19844531/6767365
重命名这些文件。 我把我的项目重命名为MvcMovie,它工作得很好
如果在遵循建议的解决方案之后,您已经设法重命名了一个新的解决方案(假设从www.oldsite.com重命名为www.newsite.com),但仍然使用旧的Web站点项目名称,因为您有一个旧的“ASP。Net Web站点”,然后遵循这些额外的步骤(假设从project1到project2)。
安装和旧的Visual Studio 2017 用它打开项目,右键单击项目->添加->新建项目。 选择“已安装-> Visual c# -> Web ->以前版本-> ASP. exe”。NET空网站”并将其命名为“www.newsite.com” 将Visual Studio 2017中的所有文件和文件夹从旧站点移动到新站点,直到旧站点仍然为空。 右键单击“www.oldsite.com”并删除它。
现在您可以保存所有内容,并使用Visual Studio 2022再次打开它。所有这些都是需要的,因为VS2019/VS2020不支持“旧的”ASP。Net网站创建,但只编辑。
下面是在Visual Studio 2013中逐步重命名整个解决方案的方法
假设我们正在更改一个名为“HelloWorld”的项目。到Section1to5.ui
转到解决方案资源管理器(截图如下),右键单击您希望重命名的项目,并选择“重命名”。输入所需的新名称。
Right click on the Project that you have just renamed, and click on "Properties". Under the Application tab, change the "Assembly name" and "Default namespace". In the main Program.cs file (or any other code files that you may have created), rename the namespace declaration to use the new name. For this right-click the namespace and select Refactor > Rename enter a new name. For example: namespace HelloWorld.ui ----> namespace Section1to5.ui Next, expand the "Properties" and double click on AssemblyInfo.cs file. You will notice the below code fragment:
[组装:AssemblyTitle(“HelloWorld.ui”)] [组装:AssemblyDescription (" ")) [组装:AssemblyConfiguration (" ")) [组装:AssemblyCompany(“微软”)] [组装:AssemblyProduct(“HelloWorld.ui”)] [assembly: AssemblyCopyright("Copyright©Microsoft 2015")] [组装:AssemblyTrademark (" ")) [组装:AssemblyCulture (" "))
您需要将Properties/AssemblyInfo.cs中的AssemblyTitle和AssemblyProduct更改为新名称,在本例中为“HelloWorld”。“Section1to5.ui”。更改完名称后,保存并关闭Visual Studio。
在项目目录中,进入“HelloWorld”文件夹。删除bin和obj目录。 完成后,将文件夹重命名为“HelloWorld”。到新的项目名称。 用文本编辑器(如Notepad或notepad++)打开重命名的解决方案文件,并编辑以下行: Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld. "ui”、“HelloWorld.ui \ HelloWorld.ui。csproj”、“{39 fc65a3 - 3 - ae7 4 - ec9 b8f7 - 74 f971636c70}”
替换“HelloWorld”的所有实例。你为你的项目选择的新名称,在本例中是“Section1to5.ui”。这将把项目的路径更改为步骤6中重命名的目录。
使用visual studio打开解决方案文件,并清理和重建项目。 您可能注意到“调试/运行”按钮已被“附加”按钮所取代。如果发生这种情况,只需右键单击项目并选择“设置为启动项目”选项。或者单击“工具>自定义>命令>添加命令>调试”,添加按钮。
你完成了重命名项目,如果你有任何疑问,请随时发帖,我很乐意帮助你!
删除bin和obj子文件夹以删除不正确的引用,然后使用windows搜索旧名称。
编辑任何代码或xml文件发现和重建,现在应该是好的。