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

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

有官方的做法吗?


当前回答

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.

其他回答

2021年更新:

重命名项目使这变得毫不费力。一个简单的CLI工具,它甚至在成功时创建一个git提交。

https://github.com/ModernRonin/ProjectRenamer


旧的回答:

我曾经使用Visual Studio扩展“完全重命名项目”来成功地重命名ASP中的项目。NET Core 2解决方案。

我使用ReSharper然后调整名称空间(右键单击项目,重构,调整名称空间…)

https://github.com/kuanysh-nabiyev/RenameProjectVsExtension

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

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细节……

使用notepad++的“在文件中查找”功能对我来说很好(ctrl + H,在文件中查找)。

http://notepad-plus-plus.org/download/v6.2.2.html

您可以:

点击file-> new ->从现有项目创建项目 选择您的原始文件,例如。方案1,并输入新的文件名方案2 2 .在新方案中修改项目名称

删除bin和obj子文件夹以删除不正确的引用,然后使用windows搜索旧名称。

编辑任何代码或xml文件发现和重建,现在应该是好的。