如何将项目移动到Visual Studio中的不同文件夹?在我的项目中,我习惯了这种结构。

-- app
---- Project.Something
---- Project.SomethingElse

我想将整个命名空间SomethingElse重命名为SomethingNew,最好的方法是什么(无需手动进入.sln文件)?


当前回答

最简单的方法,我自己找到的

我试了很多次,直到找到一个可行的方法。例如,您想要将项目从sln文件夹移动到mySource文件夹。

Remove your Project: In the SolutionExplorer of Visual Studio select your Project you want to change the directory, Press Delete -> Project gets removed. It still remains in your sln folder. Copy it to your Path: In the windows explorer copy your whole project to your mySource folder. -> Now you are ready to include it. Include back your Project: In the SolutionExplorer of Visual Studio add Existing Project and select your project from mySource folder. -> Project is now back in your Solution. Adjust your Project References: Check every Reference in your Project. On your Project -> Dependencies -> Project -> you see your project references. If there is a yellow Warning sign on a project reference than is it wrong. Delete your project reference and add it new. Rebuild your Project: and let it Run. Afterwards you can delete your project in the sln folder, which is not anymore in use.

这工作。玩得开心!

其他回答

我发现这个方法,这个方法对我有用。

在visual studio 2017社区版中,它在此路径创建一个项目 ”马克C: \用户\ \ \回购\产生来源\产生” 这将产生一个文件访问被拒绝的问题

现在,你可以用这种方法解决这个问题。

close your visual studio process. Then, find your project and copy the project folder But, first make a Sub-folder Named Projects inside of your visual studio 2017 folder in documents. Next, paste the project folder inside of your visual studio 2017 Project folder not the main visual studio 2017 folder it should go into the Sub-folder called Projects. Next, restart Visual studio 2017 Then, choose Open project Solution Then, find your project you pasted in your visual studio 2017 Projects folder Then clean the Project and rebuild it , It, should build and compile just fine. Hope, this Helped out anybody else. Not to sure why Microsoft thought building your projects in a path where it needs write permissions is beyond me.

通过在“解决方案资源管理器”窗口中右键单击项目并选择“删除”,可以从解决方案中删除项目。移动整个项目文件夹,包括您想要移动的子目录。将项目添加回解决方案。

命名空间名称则完全不同,只需编辑源代码即可。

关闭解决方案并将项目移动到新的文件夹/位置 重新打开溶液 项目应该加载的'+'叹息指的是未检查的部分。所有的文件 将显示为“重命名”。 如果重新打开后不工作,右键单击项目,然后单击卸载 重新加载。 它在VS2019中有效

我尝试了删除和重新添加项目的建议,但修复依赖关系可能会很痛苦。

我使用这种方法:

移动项目文件夹。 如果项目在源代码控制中,则使用源代码控制命令执行移动。 在文本编辑器中编辑解决方案文件。你应该只需要改变一条路径。

我希望Git中的更改显示为移动/重命名,而不是删除和添加。 所以我把上面的文章和这篇文章结合起来。

mkdir subdirectory
git mv -k ./* ./subdirectory
# check to make sure everything moved (see below)
git commit

并通过文本编辑器从sln文件中的nuget Pkg中调整项目和组件的路径。