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

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

有官方的做法吗?


当前回答

连同这个链接的答案

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.

我是vs的新手,我只是遇到了同样的问题:需要在工作几周后重新命名一个已经开始的项目。我就是这么做的,而且成功了。

Just in case, make a backup of your folder Project, although you won't be touching it, but just in case! Create a new project and save it using the name you wish for your 'new' project, meaning the name you want to change your 'old' project to. Build it. After that you'll have a Project with the name you wanted but that it does not anything at all but open a window (a Windows Form App in my case). With the new proyect opened, click on Project->Add Existing Ítem and using Windows Explorer locate your 'old' folder Project and select all the files under ...Visual Studio xxx\Projects\oldApp\oldApp Select all files in there (.vb, .resx) and add them to your 'new' Project (the one that should be already opened). Almost last step would be to open your Project file using the Solution Explorer and in the 1st tab change the default startup form to the form it should be. Rebuild everything.

可能会有更多的步骤,但更少或根本不需要输入,只需要点击鼠标。希望 这很有帮助:)

连同这个链接的答案

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

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

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

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

如果在遵循建议的解决方案之后,您已经设法重命名了一个新的解决方案(假设从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网站创建,但只编辑。