如何重构Visual Studio的项目布局并与VSS项目匹配?

发布于 2024-09-08 02:10:07 字数 1939 浏览 1 评论 0原文

我正在从 VS2008 升级到 VS2010,想做一些清理工作。我的主要解决方案在平面文件空间中包含 20 个左右的项目。然而,项目有一个分组(一些库、一些客户端程序、一些测试程序等),我想以适当的方式重新组织项目的物理磁盘布局。此外,我的源代码控制是 VSS(1),因此我希望使其文件结构与物理磁盘结构保持一致,并保留整体文件历史记录。

那么有哪些工具可以做到这一点呢?或者我是否最好将解决方案切成碎片并在所需位置重新组装?

有一些关于解决方案的最佳布局的问题,但我见过没有一个问题可以告诉您如何从 A 到 B

如何在 Visual Studio 中重构大型项目

Visual Studio 中磁盘上的项目布局

例如,我想从“A”转到

Solution
  |
  |-Project1
  |-Project2
  |-Project3
  |-Project4

“B”

Solution
  |
  |-Group1
  |   |
  |   |-Project1
  |   |-Project2
  |
  |-Group2
      |
      |-Project3
      |-Project4

更新 1

我应该提到我尝试了为“Group1”和“Group2”创建解决方案文件夹的明显方法,然后将项目拖动到每个文件夹下的新位置。这对于在 VS2010 中创建项目的逻辑组织非常有效,但不会更改磁盘上项目的物理位置。

更新 2

我尝试从解决方案中删除项目,将其物理移动到磁盘上,然后将其添加到解决方案文件夹下。这样就实现了磁盘上的重定位,但是项目记住了它原来在VSS中的位置并与那些文件链接起来,而不是VS2010在VSS中构建新的项目结构

Update 3

想了一下我意识到我所要求的更多的是在 VS2010 中移动项目后如何重新调整 VSS 项目与物理磁盘布局。解决此问题需要修改 VSS 项目布局和 VS2010 项目内部结构。所以我更新了标签和问题标题。

更新 4 - 我的手动解决方案

好的,我已经制定了一个非常手动密集的方法来移动东西:

  1. 从 VS2010 中删除项目 解决办法

  2. 将其移动到磁盘上的新位置

  3. 从项目中删除所有与 VSS 相关的文件

  4. 在文本编辑器中打开项目文件,并删除所有与 VSS 相关的条目(所有以“Scc”开头的条目)

  5. 将项目添加回解决方案并重新建立任何项目到项目引用

  6. 检查解决方案和项目返回 VSS 并关闭 VS2010

  7. 打开 VSS 并从 VSS 中的新项目位置删除仅代码文件

  8. 从 VSS 中的旧位置共享文件

  9. 从旧位置删除文件在 VSS 中

  10. 在 VSS 中删除旧项目位置

这是执行此操作的最佳/唯一方法吗?

(1) 是的,我知道 - VSS。然而,在我使用它的情况下,它工作得很好,我没有让它出错,虽然我已经探索了其他选项,但我现在不打算改变。所以,请不要评论我应该如何转向源代码控制中的下一个最好的东西。如果这还没有让您烦恼,那么这样怎么样:我实际上使用了当前可用且受到积极支持的商业产品,该产品使用 VSS 作为后端版本控制数据存储!

I am in the process of upgrading from VS2008 to VS2010 and want to do some cleaning up. My main solution has 20 or so projects under it in a flat file space. However there is a grouping to the projects (some libraries, some client programs, some test programs etc) and I wanted to reorganise the physical disk layout of the projects in the appropriate manner. In addition my source control is VSS(1) so I want to keep its file structure aligned with the physical disk structure and keep the overall file history.

So what sort of tools are available to do this? Or am I better off cutting the solution to pieces and reassembling it in the desired locations?

There are a few SO questions that talk about the best layout for a solution, but none that I have seen that tell you how to get from A to B

How to refactor large projects in visual studio

Project layout on disk in visual studio

For example I want to go from "A"

Solution
  |
  |-Project1
  |-Project2
  |-Project3
  |-Project4

to "B"

Solution
  |
  |-Group1
  |   |
  |   |-Project1
  |   |-Project2
  |
  |-Group2
      |
      |-Project3
      |-Project4

update 1

I should have mentioned that I tried the obvious method of creating solution folders for "Group1" and "Group2" and then dragging the projects into their new locations under each folder. This works well for creating a logical organization of the projects within VS2010, but does not change the physical location of the projects on disk.

Update 2

I tried removing a project from the solution, physically moving it on disk and then adding it under a solution folder. This achieves the relocation on disk, but the project remembered where it was originally in VSS and linked up with those files, rather than VS2010 building a new project structure in VSS

Update 3

After thinking about it for a bit I have realized that what I am asking for is more how to realign VSS projects with the physical disk layout after I move the projects in VS2010. Fixing this will entail modifications to both the VSS project layout and the VS2010 project internals. So I have update the tags and question heading.

Update 4 - My manual solution

OK so I have worked out a very manually intensive method for moving things around:

  1. Remove the project from the VS2010
    solution

  2. Move it to the new location on disk

  3. Delete all VSS related files from the project

  4. Open the project file in a text editor and strip out all VSS related entries (all those start with "Scc" )

  5. Add the project back into the solution and re-establish any project to project references

  6. Check the solution and the project back into VSS and close down VS2010

  7. Open up VSS and delete the code only files from the new project location in VSS

  8. Share in the files from the old location in VSS

  9. Delete the files from the old location in VSS

  10. Delete the old project location in VSS

Is this the best/only way of doing this?

(1) Yes I know - VSS. However in the context that I am using it, it works perfectly fine and I have not had it put a foot wrong, and while I have explored other options I'm not about to change right now. So please, no comments about how I should move to the next best thing in source control. And if that doesn't get your hackles up, how about this: I actually use a currently available and actively supported commercial product that uses VSS as a backend, versioning data store!

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

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

发布评论

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

评论(1

深爱不及久伴 2024-09-15 02:10:07

听起来你已经差不多完成了。您可以在文本编辑器中打开 .sln 文件,然后手动更改 .(vs|cs)proj 文件的路径。这应该允许您使用您想要的结构。

It sounds like you're most of the way there. You can open up the .sln file in a text editor, and manually change the paths to the .(vs|cs)proj files. This should allow you to use the structure you want.

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