使用 SVN 时更改 Visual Studio 中的文件夹名称
我将 VS2008/VS2010 与 Resharper 5、TortoiseSVN 1.6.8.19260-x64 和 AnkhSVN 2.1.8420.8 一起使用。我在 Visual Studio 中执行的大多数操作都可以在 SVN 中正常反映,但是,当我尝试提交更改时,重命名项目中的文件夹可能会导致问题。此外,重命名文件夹下的 C# 源文件中的所有命名空间都需要更新以反映名称更改。
重命名主项目文件夹或任何子文件夹并确保 SVN 没有问题的最佳方法是什么?应该在 Visual Studio 之外完成吗?
更新所有命名空间更改的最佳方法是什么?搜索/替换是唯一的方法吗?
是否有关于文件夹名称及其内容的最佳实践?
I am using VS2008/VS2010 with Resharper 5, TortoiseSVN 1.6.8.19260-x64, and AnkhSVN 2.1.8420.8. Most operations I do in Visual Studio are reflected fine in SVN, however, renaming folders in a project can cause problems when I try to submit my changes. Also all the namespaces in the C# source files under the renamed folder need to be updated to reflect the name change.
What is the best way to rename the main project folder or any sub folders and ensure there are no issues with SVN? Should it be done outside Visual Studio?
What is the best way to update all the namespace changes? Is search/replace the only way?
Are there any best practices regarding folder names and their contents?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,请在 Visual Studio 之外重命名。在 Windows 资源管理器中使用 TortoiseSVN,通过相关文件夹的 TortoiseSVN 上下文菜单进行重命名。 Visual Studio 中的项目将检测磁盘上的更改并要求您重新加载。
您还可以从 Visual Studio 中的项目中排除,然后重命名并重新包含新路径。
编辑: 根据下面的 @Sander Rijken,AnkhSVN 跟踪重命名并确保重命名在 svn 工作副本中正确注册。
如果除了 TortoiseSVN 之外您还没有安装 AnkhSVN,那么这将不起作用,您必须按照我上面所说的进行操作。
Yes do your rename outside of Visual Studio.Using TortoiseSVN in windows explorer, do your rename via the TortoiseSVN context menu on the folder in question. The project in Visual Studio will detect the changes on disk and ask you to reload.
You could also do an exclude from project in Visual Studio, then rename and then re-include the new path.
Edit: As per @Sander Rijken below, AnkhSVN tracks the rename and makes sure the rename is correctly registered in the svn working copy.
If you don't have AnkhSVN installed in addition to TortoiseSVN though this will not work and you have to do as I said above.
运行 AnkhSvn 时,您应该能够重命名 Visual Studio 内的文件夹。此外,当使用 Resharper 等重构工具根据新文件夹名称更改命名空间时,一切都按我的预期进行。
You should be able to rename folders inside Visual Studio when running AnkhSvn. Also when using refactoring tools like Resharper to change the namespace according to the new folder name, everything works as expected for me.
Agent SVN 插件实现了 MS-SCCI 接口,使其能够与 Visual Studio 集成。
由于MS-SCCI定义了文件重命名操作,这意味着代理SVN可以在IDE中进行文件重命名,任何也实现MS-SCCI的插件也应该这样做>。
The Agent SVN plug-in implements the MS-SCCI interface which allows it to integrate with Visual Studio.
Since the MS-SCCI defines a file rename operation, that means Agent SVN can do file renames from within the IDE, as should any plug-in that also implements the MS-SCCI.
当必须执行文件夹重命名时,我通常要做的就是首先使用 tortoiseSVN 重命名文件夹,然后排除/包含 VS 中的文件夹,最后重命名所有命名空间(使用 Resharper,只需逐个文件和 Alt+Enter( ing) 在命名空间指令上进行适当的重命名。
What I typically do when having to perform a folder renaming is first renaming the folder using tortoiseSVN, then Excluding/Including the folder in VS and finally renaming all the namespaces (with Resharper it's just a matter of going file by file and Alt+Enter(ing) on the namespace directive to rename as appropriate.