在TFS下重命名VS.net中包含的项目文件夹

发布于 2024-07-04 11:53:41 字数 136 浏览 4 评论 0原文

我有一个 vs.net 项目,经过一些重构,修改了项目的名称。 如何轻松重命名底层 Windows 文件夹名称以匹配 TFS 控制的项目和解决方案下的新项目名称?
请注意,我过去可以通过使用 SourceSafe 在后台摆弄东西来完成......

I have a vs.net project, and after some refactoring, have modified the name of the project. How can I easily rename the underlying windows folder name to match this new project name under a TFS controlled project and solution?
Note, I used to be able to do by fiddling with things in the background using SourceSafe ...

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

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

发布评论

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

评论(6

夏末的微笑 2024-07-11 11:53:41

对于 Visual Studio 2019ASP.NET Core 2.2 我必须稍微修改 Scott Munro 的答案。 以下是对我有用的方法:

开始之前:签入所有更改并备份您的解决方案。

  1. 使用解决方案资源管理器重命名项目(即右键单击项目并单击“重命名”)。
  2. 源代码管理资源管理器中重命名项目文件夹。
  3. 在文本编辑器中打开解决方案的 .sln 文件,然后修复文件路径。 (将对“OldProjectName”的所有引用替换为“NewProjectName”)。
  4. 在 Visual Studio 中重新加载您的解决方案。
  5. 查找所有旧名称空间并将其替换为新项目名称。
  6. 完毕。 检查更改。

我必须先执行步骤 1,以便在步骤 3 中修复文件路径后加载项目。

For Visual Studio 2019 and ASP.NET Core 2.2 I had to modify Scott Munro's answer slightly. Here's what worked for me:

Before you start: Check in all changes and make a backup of your solution.

  1. Rename the project using the Solution Explorer (i.e. right click the project and click rename).
  2. Rename the project folder in Source Control Explorer.
  3. Open your solution's .sln file in a text editor, and fix the file path. (Replace any references to "OldProjectName" with "NewProjectName").
  4. Reload your solution in Visual Studio.
  5. Find and replace all the old namespaces with the new project name.
  6. Done. Check in changes.

I had to do step 1 first in order to get the project to load after fixing the file path in step 3.

关于从前 2024-07-11 11:53:41

我的具体配置是VS2010连接到TFS2008。 我在这里尝试了一些其他解决方案,但遇到了问题。 我发现以下内容对我有用: -

  1. 删除要从解决方案中重命名的文件夹中的项目
  2. 保存解决方案
  3. 重命名 TFS 源代码管理中包含已删除项目的文件夹(这会在硬盘上本地重命名)
  4. 将项目添加回从新位置
  5. 保存解决方案
  6. 提交到源代码管理

现在,您将重命名文件夹并将解决方案重新映射在一个变更集下提交的所有内容。

My particular configuration is VS2010 connecting to TFS2008. I tried some of the other solutions here, but had problems. I found the following worked for me:-

  1. Remove project in folder to be renamed from solution
  2. Save solution
  3. Rename folder containing removed project in TFS source control (this renames locally on your hard disk)
  4. Add project back to the solution from the new location
  5. Save solution
  6. Commit to source control

Now, you'll have the folder rename and the solution re-map all committed under one changeset.

女中豪杰 2024-07-11 11:53:41

您可以在 TFS 中重命名项目(.Xproj 文件和项目文件夹),删除本地文件夹结构及其所有内容,然后获取项目的最新版本。 所有这一切都取决于您的源存储库的概念是否完全是最新的且可编译的。

You could just rename the project (.Xproj file and project folder) in TFS, delete the local folder structure and all of its contents, then do a get latest for the project. All of this depends the notion of your source repository is completely up to date and compilable.

两人的回忆 2024-07-11 11:53:41

以下是在使用 TFS 的 Visual Studio 2008 中对我有用的步骤:

  1. 关闭解决方案。
  2. 在源代码管理资源管理器中重命名项目文件夹(右键单击 -> 重命名)。 这会将代码复制到新命名的文件夹中。
  3. 打开解决方案,然后在解决方案资源管理器中删除旧文件夹/项目并添加新的、正确命名的重复项(在旧项目上,右键单击 -> 删除,然后在解决方案上,右键单击 -> 添加-> 现有项目...)

或者:在步骤 2 之后,您可以在文本编辑器中打开解决方案的 .sln 文件,然后手动更新项目文件夹名称。 如果您这样做,您可能需要手动签出 .sln 文件以确保您的更改将被签入(<- 重要!)。

Here are steps that worked for me in Visual Studio 2008 with TFS:

  1. Close solution.
  2. Rename project folders in Source Control Explorer (right-click -> rename). This duplicates code into newly named folders.
  3. Open the solution, and in Solution Explorer, remove the old folders/projects and add the new, properly named, duplicates, (on old projects, right-click -> remove, then on the solution, right-click->Add->Existing Project...)

OR: After step 2, you can open the solution's .sln file in a text editor, and manually update the project folder names. If you do this, you might need to manually check-out the .sln file to be sure your changes will be checked in (<- important!).

听你说爱我 2024-07-11 11:53:41

只需右键单击 TFS 中的文件夹,然后选择重命名。 提交重命名后,TFS 将为您在磁盘上进行更改。 正如 Kevin 指出的那样,您需要确保所有内容都已签入,因为 TFS 将删除旧文件夹及其中的所有内容,并下拉重命名的文件夹以及其中文件的当前版本。

最后一点:您无法重命名未映射的文件夹或未从中执行“获取”操作的文件夹。 我不知道为什么,但在这些情况下 TFS 将禁用“重命名”选项。

如果我没记错的话,至少这就是发生在我身上的事情。

Just right click on the folder in TFS, and select Rename. Once you commit the rename, TFS will make the changes on disk for you. As Kevin pointed out, you will want to make sure that everything is checked in, because TFS will remove the old folder and everything in it, and pull down the renamed folder with the current version of the files in it.

One final note: You can't rename a folder that you haven't mapped, or that you haven't done a "Get" from. I don't know why, but TFS will disable the Rename option in these cases.

At least that's what happened to me, if I remember correctly.

深巷少女 2024-07-11 11:53:41
  1. 签入文件夹内所有待处理的更改,并确保所有其他团队成员也执行相同操作。
  2. 确保您的工作目录中有该文件夹的副本(否则,您将无法在下一步中选择在源代码管理资源管理器中重命名该文件夹)。 如果您还没有文件夹,请获取最新版本以获取副本。
  3. 关闭解决方案
  4. 重命名源代码管理资源管理器中的文件夹。 这会将源代码管理中跟踪的所有文件从文件系统上的原始文件夹移动到新文件夹。 请注意,源代码管理未跟踪的文件将保留在原始文件夹中 - 一旦您确认其中没有您需要的文件,您可能需要删除该文件夹。
  5. 打开解决方案,并在提示从源代码管理获取新添加到解决方案中的项目时选择“”。 您将收到一条警告,指出无法加载解决方案中的项目之一。
  6. 在解决方案资源管理器中选择项目

    <块引用>

    请注意,它将显示为灰色并标记为“不可用”。

  7. 打开属性窗格。
  8. 直接或使用“...”按钮编辑“文件路径”属性。

    <块引用>

    另请注意,此属性只能在 Visual Studio 中编辑2010 年。 在较新版本的 Visual Studio 中,您需要手动编辑解决方案文件中的项目路径。

  9. 右键单击“解决方案浏览器”中的项目,然后从上下文菜单中选择“重新加载项目”。 如果收到错误消息,指出无法从原始文件夹加载项目,请尝试关闭解决方案,删除解决方案文件所在文件夹中的 suo 文件,然后重新打开解决方案。
  10. 签入更改作为单个更改集。
  11. 让其他团队成员“获取最新版本”解决方案(在解决方案资源管理器中右键单击解决方案,然后从上下文菜单中选择“获取最新版本”。

注意:涉及删除项目然后将项目重新添加到解决方案的其他建议解决方案将破坏项目引用。

如果执行这些步骤,那么您还可以考虑重命名以下内容以适应。

  1. 项目文件
  2. 默认/根命名空间程序

此外,请考虑修改以下程序集属性的值< /a>.

  1. AssemblyProductAttribute
  2. AssemblyDescriptionAttribute
  3. AssemblyTitleAttribute
  1. Check in all pending changes within the folder and ensure that all other team members to do the same.
  2. Ensure that you have a copy of the folder in your working directory (otherwise, you will not have the option to rename the folder in the Source Control Explorer in the next step). Get latest version on the folder to get a copy if you don't already have one.
  3. Close the solution.
  4. Rename the folder within the Source Control Explorer. This will move all of the files that are tracked in source control from the original folder on your file system to the new one. Note that files not tracked by source control will remain in the original folder - you will probably want to remove this folder once you have confirmed that there are no files there that you need.
  5. Open the solution and select 'No' when prompted to get projects that were newly added to the solution from source control. You will get a warning that one of the projects in the solution could not be loaded.
  6. Select the project within Solution Explorer.

    Note that it will be grayed out and marked as 'Unavailable'.

  7. Open the Properties pane.
  8. Edit the 'File Path' property either directly or using the '...' button.

    Note also that this property is only editable in Visual Studio 2010. In newer versions of Visual Studio, you will need to manually edit the project paths within the solution file.

  9. Right-click on the project in the Solution Explorer and select Reload Project from the context menu. If you get an error message saying that the project cannot be loaded from the original folder, try closing the solution, deleting the suo file in the same folder as the solution file then reopening the solution.
  10. Check in the changes as a single changeset.
  11. Have other team members 'Get latest version' for the solution (right click on the solution within Solution Explorer and select 'Get Latest Version' from the context menu.

Note: Other suggested solutions that involve removing and then re-adding the project to the solution will break project references.

If you perform these steps then you might also consider renaming the following to suit.

  1. Project File
  2. Default/Root Namespace
  3. Assembly

Also, consider modifying the values of the following assembly attributes.

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