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

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

有官方的做法吗?


当前回答

我是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,它工作得很好

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.

如果在加载Xamarin等共享项目时遇到问题,请记住在csproj文件中更改对共享库的引用。我开发了一款CocosSharp游戏,但Droid/iOS/WP81项目不想加载。我不得不在每个csproj文件(Driod/iOS/WP81)中更改下面的行,其中引用了共享库。这是由于文件夹名称更改造成的,因此将YOUR_PREVIOUS_NAMESPACE替换为文件夹的新名称。

<Import Project="..\YOUR_PREVIOUS_NAMESPACE.Shared\EmptyProject.Shared.projitems" Label="Shared" />

另外,我注意到对于. driod项目,项目属性中的程序集名称不能使用Visual Studio更改(我使用2015年)。我必须在. droid中手动更改程序集名称。csproj文件。

<AssemblyName>YourNameSpace</AssemblyName>

然后我加载解决方案,在项目属性视图新名称出现。重建dll后生成该名称。

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

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

我尝试了Visual Studio Project Renamer,但是,它在我尝试的少数情况下抛出异常。

我在CopyWiz上取得了很大的成功。

我与他们没有任何关系,我还没有为它付钱,但我可能很快就要为它付钱了,因为它似乎是唯一一个对我的c#和c++项目都有效的工具。我确实希望他们能赚点钱,并继续改进它。