我有一个相当复杂的Visual Studio解决方案(2010年,但这不重要),我需要重命名。
我想重命名文件夹以匹配新的解决方案名称,但我无法找到自动重构文件夹名称的方法,而且查看每个项目文件将是一件痛苦的事情。
有官方的做法吗?
我有一个相当复杂的Visual Studio解决方案(2010年,但这不重要),我需要重命名。
我想重命名文件夹以匹配新的解决方案名称,但我无法找到自动重构文件夹名称的方法,而且查看每个项目文件将是一件痛苦的事情。
有官方的做法吗?
当前回答
删除bin和obj子文件夹以删除不正确的引用,然后使用windows搜索旧名称。
编辑任何代码或xml文件发现和重建,现在应该是好的。
其他回答
重命名一个解决方案:
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.
下面是在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打开解决方案文件,并清理和重建项目。 您可能注意到“调试/运行”按钮已被“附加”按钮所取代。如果发生这种情况,只需右键单击项目并选择“设置为启动项目”选项。或者单击“工具>自定义>命令>添加命令>调试”,添加按钮。
你完成了重命名项目,如果你有任何疑问,请随时发帖,我很乐意帮助你!
2021年更新:
重命名项目使这变得毫不费力。一个简单的CLI工具,它甚至在成功时创建一个git提交。
https://github.com/ModernRonin/ProjectRenamer
旧的回答:
我曾经使用Visual Studio扩展“完全重命名项目”来成功地重命名ASP中的项目。NET Core 2解决方案。
我使用ReSharper然后调整名称空间(右键单击项目,重构,调整名称空间…)
https://github.com/kuanysh-nabiyev/RenameProjectVsExtension
我尝试了Visual Studio Project Renamer,但是,它在我尝试的少数情况下抛出异常。
我在CopyWiz上取得了很大的成功。
我与他们没有任何关系,我还没有为它付钱,但我可能很快就要为它付钱了,因为它似乎是唯一一个对我的c#和c++项目都有效的工具。我确实希望他们能赚点钱,并继续改进它。
我是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.
可能会有更多的步骤,但更少或根本不需要输入,只需要点击鼠标。希望 这很有帮助:)