我有一个相当复杂的Visual Studio解决方案(2010年,但这不重要),我需要重命名。

我想重命名文件夹以匹配新的解决方案名称,但我无法找到自动重构文件夹名称的方法,而且查看每个项目文件将是一件痛苦的事情。

有官方的做法吗?


当前回答

下面是在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打开解决方案文件,并清理和重建项目。 您可能注意到“调试/运行”按钮已被“附加”按钮所取代。如果发生这种情况,只需右键单击项目并选择“设置为启动项目”选项。或者单击“工具>自定义>命令>添加命令>调试”,添加按钮。

你完成了重命名项目,如果你有任何疑问,请随时发帖,我很乐意帮助你!

其他回答

如果要重命名解决方案,可以执行以下步骤。

Backup.First things first, make sure to always create a backup file.Simply copy your project to a different directory. 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". Open any .cs and rename all namespace Change the AssemblyTitle and AssemblyProduct in Properties/AssemblyInfo.cs. 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. Cleans and Rebuild the project

https://learn.microsoft.com/en-us/answers/questions/1028483/rename-solution-and-related-projects-in-a-aspnet-w.html细节……

您还可以导出模板,然后从导出的模板创建一个新项目,根据自己的喜好更改名称

连同这个链接的答案

https://stackoverflow.com/a/19844531/6767365

重命名这些文件。 我把我的项目重命名为MvcMovie,它工作得很好

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.

重命名网站:

http://www.c-sharpcorner.com/Blogs/46334/rename-website-project-in-visual-studio-2013.aspx

定位并编辑IISExpress的applicationhost。配置,在这里找到: C: \用户{username} \ \ IISExpress \ config文件