我有一个相当复杂的Visual Studio解决方案(2010年,但这不重要),我需要重命名。
我想重命名文件夹以匹配新的解决方案名称,但我无法找到自动重构文件夹名称的方法,而且查看每个项目文件将是一件痛苦的事情。
有官方的做法吗?
我有一个相当复杂的Visual Studio解决方案(2010年,但这不重要),我需要重命名。
我想重命名文件夹以匹配新的解决方案名称,但我无法找到自动重构文件夹名称的方法,而且查看每个项目文件将是一件痛苦的事情。
有官方的做法吗?
当前回答
使用notepad++的“在文件中查找”功能对我来说很好(ctrl + H,在文件中查找)。
http://notepad-plus-plus.org/download/v6.2.2.html
其他回答
如果您正在Visual Studio 2010中创建网站。您可以按照如下方式修改项目名称。
步骤1:在Visual Studio 2010中,SLN文件将存储在Visual Studio 2010的项目文件夹下,源文件存储在Visual Studio 2010的网站文件夹下。
步骤2:重命名文件夹右键单击该文件夹通过重命名,其中包含您的SLN项目。
步骤3:重命名SLN文件名右键单击该SLN文件转发重命名。
第四步:在Visual Studio 2010的Website下重命名包含SLN文件Source的文件夹。
步骤5:然后最后双击您的SLN文件,并更改您的SLN源文件夹的根。
删除/添加项目文件方法
这个方法完全是为了重命名项目的目录,就像在Windows资源管理器中看到的那样。
使用GIT、SVN或WinZip(很重要!)等工具备份整个项目。 在Visual Studio中的解决方案中,删除项目。 在Windows资源管理器中重命名目录。 在Visual Studio中再次添加项目。
优势
您可以使Windows资源管理器中的目录与解决方案中的项目名称相匹配。
缺点
如果删除一个库,它将从其他项目中删除对该库的任何引用。在此之后,解决方案可能无法编译,直到您将该库的引用添加回(这非常简单)。这就是第一步(备份)如此重要的原因。 如果您有源代码控制,则会丢失文件的历史记录。
右键单击一个项目并选择“在Windows资源管理器中打开文件夹”对于跟踪项目在执行此过程中的存储位置非常有用。
重命名一个解决方案:
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.
您还可以导出模板,然后从导出的模板创建一个新项目,根据自己的喜好更改名称
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.