如何将项目移动到Visual Studio中的不同文件夹?在我的项目中,我习惯了这种结构。
-- app
---- Project.Something
---- Project.SomethingElse
我想将整个命名空间SomethingElse重命名为SomethingNew,最好的方法是什么(无需手动进入.sln文件)?
如何将项目移动到Visual Studio中的不同文件夹?在我的项目中,我习惯了这种结构。
-- app
---- Project.Something
---- Project.SomethingElse
我想将整个命名空间SomethingElse重命名为SomethingNew,最好的方法是什么(无需手动进入.sln文件)?
当前回答
通过在“解决方案资源管理器”窗口中右键单击项目并选择“删除”,可以从解决方案中删除项目。移动整个项目文件夹,包括您想要移动的子目录。将项目添加回解决方案。
命名空间名称则完全不同,只需编辑源代码即可。
其他回答
我尝试了删除和重新添加项目的建议,但修复依赖关系可能会很痛苦。
我使用这种方法:
移动项目文件夹。 如果项目在源代码控制中,则使用源代码控制命令执行移动。 在文本编辑器中编辑解决方案文件。你应该只需要改变一条路径。
在VS 2015
在解决方案资源管理器中卸载项目 创建一个新的解决方案 将项目复制到新解决方案的文件夹中 右键单击解决方案,添加现有项目。 如果使用MVC等框架,则可能需要在引用管理器中添加引用。
我希望Git中的更改显示为移动/重命名,而不是删除和添加。 所以我把上面的文章和这篇文章结合起来。
mkdir subdirectory
git mv -k ./* ./subdirectory
# check to make sure everything moved (see below)
git commit
并通过文本编辑器从sln文件中的nuget Pkg中调整项目和组件的路径。
最简单的方法,我自己找到的
我试了很多次,直到找到一个可行的方法。例如,您想要将项目从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.
这工作。玩得开心!
这在VS2012中很简单;只需使用变更映射特性:
创建要将解决方案移动到的文件夹。 签入所有项目文件(如果您想保留更改),或回滚任何签出的文件。 关闭解决方案。 打开源代码控制资源管理器。 右键单击解决方案,并选择“高级-> Remove Mapping…” 将“Local Folder”的值更改为步骤#1中创建的值。 选择“改变”。 通过在源代码控制资源管理器中双击解决方案来打开解决方案。