我当前重命名项目文件夹的解决方案是:

从解决方案中删除项目。在Visual Studio外部重命名文件夹。将项目重新添加到解决方案中。

有更好的方法吗?


当前回答

首先,关闭localhost,然后右键单击该文件夹。您将获得重命名选项。(Visual Studio 2022)。这对我有用。若你们并没有获得重命名选项,那个么就通过其他解决方案。

其他回答

有一种更简单的方法在Visual Studio 2013 Update 1中进行了测试,适用于TFS连接的项目:

打开Visual Studio,但让解决方案关闭。打开源代码管理器并重命名所需的文件夹(如果您尚未先关闭解决方案,则将为您关闭该解决方案)。右键单击解决方案(也可以从源资源管理器)并选择签入。打开解决方案。你会被告知有新项目加入。接受以获得更改。从解决方案中删除项目并再次添加,然后签入。检查内部参考是否正常。

我们最近上传了一个免费Visual Studio扩展的测试版,它为您提供了这些功能。

查看Visual Studio Gallery:Gallery下载

这就是我在VS19中重命名现有项目的方式。

关闭visual studio项目重命名并打开驱动器上的每个项目文件夹名称重命名每个.csproj打开.sln文件并重命名每个.csproj事件的项目目录前缀。在visual studio中打开.sln文件并重建通过浏览每个文件或使用ReplaceAll,用新的名称空间引用更新以前的名称空间

我经常遇到在VisualStudio中重命名项目并编辑文件夹名、项目名和.sln文件以实现这一点的问题。我刚刚写了一个VBScript脚本来完成这一切。您必须小心选择要替换的字符串。

您只需将.vbs文件与解决方案的.sln文件放在同一目录中即可。

' Script parameters'
Solution = "Rename_Visual_Studio_Project" '.sln'
Project = "Rename_Visual_Studio_Project" '.csproj'
NewProject = "SUCCESS"

Const ForReading = 1
Const ForWriting = 2

Set objFso = CreateObject("Scripting.FileSystemObject")
scriptDirr = objFso.GetParentFolderName(wscript.ScriptFullName)

' Rename the all project references in the .sln file'
Set objFile = objFso.OpenTextFile(scriptDirr + "\" + Solution + ".sln", ForReading)
fileText = objFile.ReadAll
newFileText = Replace(fileText, Project, NewProject)
Set objFile = objFSO.OpenTextFile(scriptDirr + "\" + Solution + ".sln", ForWriting)
objFile.WriteLine(newFileText)
objFile.Close

' Rename the .csproj file'
objFso.MoveFile scriptDirr + "\" + Project + "\" + Project + ".csproj", scriptDirr + "\" + Project + "\" + NewProject + ".csproj"

' Rename the folder of the .csproj file'
objFso.MoveFolder scriptDirr + "\" + Project, scriptDirr + "\" + NewProject

首先,关闭localhost,然后右键单击该文件夹。您将获得重命名选项。(Visual Studio 2022)。这对我有用。若你们并没有获得重命名选项,那个么就通过其他解决方案。