我有一个相当复杂的Visual Studio解决方案(2010年,但这不重要),我需要重命名。
我想重命名文件夹以匹配新的解决方案名称,但我无法找到自动重构文件夹名称的方法,而且查看每个项目文件将是一件痛苦的事情。
有官方的做法吗?
我有一个相当复杂的Visual Studio解决方案(2010年,但这不重要),我需要重命名。
我想重命名文件夹以匹配新的解决方案名称,但我无法找到自动重构文件夹名称的方法,而且查看每个项目文件将是一件痛苦的事情。
有官方的做法吗?
当前回答
如果要重命名解决方案,可以执行以下步骤。
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细节……
其他回答
删除bin和obj子文件夹以删除不正确的引用,然后使用windows搜索旧名称。
编辑任何代码或xml文件发现和重建,现在应该是好的。
我尝试了Visual Studio Project Renamer,但是,它在我尝试的少数情况下抛出异常。
我在CopyWiz上取得了很大的成功。
我与他们没有任何关系,我还没有为它付钱,但我可能很快就要为它付钱了,因为它似乎是唯一一个对我的c#和c++项目都有效的工具。我确实希望他们能赚点钱,并继续改进它。
2021年更新:
重命名项目使这变得毫不费力。一个简单的CLI工具,它甚至在成功时创建一个git提交。
https://github.com/ModernRonin/ProjectRenamer
旧的回答:
我曾经使用Visual Studio扩展“完全重命名项目”来成功地重命名ASP中的项目。NET Core 2解决方案。
我使用ReSharper然后调整名称空间(右键单击项目,重构,调整名称空间…)
https://github.com/kuanysh-nabiyev/RenameProjectVsExtension
连同这个链接的答案
https://stackoverflow.com/a/19844531/6767365
重命名这些文件。 我把我的项目重命名为MvcMovie,它工作得很好
唯一的解决方案,为我在Visual Studio 2013在一个WEB项目:
假设我想将“project1”重命名为“project2”。 假设我的.sln文件的物理路径是: c: \ \ \ project1 \ project1.sln路径
因此,我的.csproj文件以及bin和obj文件夹的路径应该是: c: \我\ \ project1 \ project1 \路径
Open the solution in VS by double clicking the project1.sln file. In Solution Explorer, right-click the project (NOT the solution!!!), 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 like Global.asax for example), 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:
名称空间project1
4.1在“解决方案资源管理器”中,右键单击项目(不是解决方案!!),选择“重命名”,并输入新的名称。
请确保:Properties/AssemblyInfo.cs中的AssemblyTitle和AssemblyProduct被设置为新名称(“project2”)。
1 [assembly: AssemblyTitle(“这里的新名称”)] 2 [组装:AssemblyDescription (" ")) 3. [组装:AssemblyConfiguration (" ")) 4 [组装:AssemblyCompany (" ")) 5 [assembly: AssemblyProduct(“这里的新名称”)] 6 [assembly: AssemblyCopyright(“版权©2013”)] 7 [组装:AssemblyTrademark (" ")) 8 [组装:AssemblyCulture (" "))
关闭Visual Studio。 从物理上删除bin和obj目录。 重命名父文件夹和源文件夹为新名称(project2):
在这个例子中: 我c: \ \路径\ project1 \ project1
将会是: c: \ \ \ project2 \ project2路径
重命名SLN文件名右键单击该SLN文件转发重命名。 最后打开SLN文件(在记事本或任何编辑器内),复制并替换(Ctrl+h)任何旧名称到新名称。 打开VS,点击BUILD -> Clean Solution 点击构建->构建解决方案,然后F5运行… 注1:如果你得到这样的东西:编译错误 CS0246:无法找到类型或名称空间名称“project2”(您是否缺少using指令或程序集引用?)
c:\Users\Username\AppData\Local\Temp\Temporary ASP. exe网络文件\ \ 78 dd917f \ d0836ce4 \ App_Web_index.cshtml.a8d08dba.b0mwjmih.0.cs根源
然后进入“临时ASP。NET Files”文件夹并删除所有文件。
注2:如果你试图“另存为”到一个新命名的项目,并保留旧的项目,考虑通过修改web中的connectionStrings来复制你的db。配置和重新启动迁移(如果项目中有迁移的话)。