Visual Studio - 将解决方案移动到新文件夹和命名空间

发布于 2024-08-10 12:20:03 字数 180 浏览 4 评论 0原文

我目前正在编写一个小型命令行应用程序,它将采用整个 Visual Studio 解决方案,将其复制到新文件夹并更改所有项目的名称空间。

看起来需要一些正则表达式魔法才能使其正常工作(并且需要相当多的努力)。

我是在重新发明轮子吗? - 视觉工作室或其他任何地方有什么可以为我做这件事吗?

提前致谢!

I'm currently writing a little cmd line app that will take an entire visual studio solution, copy it to a new folder and change the namespaces of all the projects.

Looks like its going to take some regex magic to get this working properly (and quite a bit of effort).

Am I reinventing the wheel? - is there anything in visual studio or anywhere else that will do this for me?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

七堇年 2024-08-17 12:20:03

当我需要更改整个解决方案的命名空间并移动到另一个目录时,我使用“搜索和替换”...我只需删除该项目并从另一个目录中的源代码管理中再次打开它(如果您不使用 SCM)工具,只需将项目的根目录及其下面的任何内容复制到新位置)

所有路径都应该相对于根目录。

I use Search and Replace when I need to change namespace of an entire solution, and to move to another directory... I just delete the project and open it again from source control in a different directory (if you don't use a SCM tool, just copy the root of the project and whatever beneath it to the new location)

all paths should be relative to the root.

趴在窗边数星星i 2024-08-17 12:20:03

重构->重命名不起作用?它不会将其移动到新目录,但会找到所有引用并更改它们。

Refactor->rename doesn't work? It won't move it to a new directory but will find all references and change them.

兲鉂ぱ嘚淚 2024-08-17 12:20:03

不幸的是,这不是一个简单的搜索替换,即使使用 Visual Studio 提供的简单重构完成,这也会变得很棘手。
例如,您可以通过选择要重命名的命名空间来开始重构。但是,如果您有任何资源字符串或程序集设置,您可能会感到惊讶,即使应用程序编译,它也可能在运行时找不到资源。
有时,只需在文本编辑器(而不是在 Visual Studio 上)中打开该资源或设置文件,然后更正错误字符串即可。
然而,尝试手动(或通过定制脚本)完成此操作可能会更糟糕。

Unfortunately, this is not a simple search-replace, and this gets tricky even when done with simple refactoring provided by Visual Studio.
For example, you can start the refactoring by selecting the namespace you want to rename. But if you have any resource strings or assembly settings, you're probably going to be surprised that even if the application compiles, it may not find the resources at runtime.
Sometimes, it's as simple as opening that resource or settings file in a text editor (not on Visual Studio), and correcting the culprit string.
However, it may be worse trying to accomplish this by hand (or via a custom-made script).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文