Programmatically update files in the tfs workspace

I am working on an extension for visual studio to update the project.
The situation is as follows:

  • We create a new project from the template.
  • Put the solution in tfs
  • We are changing the project that was used to create the template. The project on the tfs server still needs to be updated.
  • We publish the project in a folder. Now I want to update the files in the TFS repository with the current files in the publish folder

I thought of the following approach:
In the application, we have the whole project, which is stored on the TFS server. When I want to update a specific project, I select a project from the database. Then I download this project from the TFS server and create a new check for this project. So far, so good. The problem occurs when I copy files from a published folder to a new version. Files that are already registered in the workspace become marked as modified, but no new files are added.

The only solution I can think of is to add all the files through the TFS SDK. But it seems to me very difficult.

So, I got a couple of questions:

  • Is this the right approach to updating a project?
  • Is there any other way to add files to the workspace instead of adding all files through the TFS SDK?

Thanks!

+4
source share
1 answer

Do not make blind copies of files. Instead, try reprogramming your program one at a time.

  • Upgrade your workspace first with the latest version of TFS.
  • Then for each file in the source directory:
    • If the file exists in the destination directory, โ€œedit the fileโ€ and then copy it.
    • If the file does not exist, copy the file, then โ€œset asideโ€ the file.
  • When you're done, check out any pending changes in the workspace.
+2
source

Source: https://habr.com/ru/post/1348111/


All Articles