开发者

Programmatically update files in a tfs workspace

开发者 https://www.devze.com 2023-02-24 11:04 出处:网络
I am working on an extension for visual studio to update a project. The situation is a follows: We create a new project from a template.

I am working on an extension for visual studio to update a project.

The situation is a follows:

  1. We create a new project from a template.
  2. We put the solution in tfs
  3. We change the project which was used to create the template. The project on the tfs server still needs te be updated.
  4. We publ开发者_开发问答ish the project to a folder. I now want to update the files in the TFS repo with the current files in the publish folder

I thought of the following approach:

In the application we have all the project stored that are on the TFS server. When I want to update a specific project I select the project from the database. Next I load this project from the TFS server and create a new checkout for this project. So far so good. The problem arise when I copy the files from the published folder to the new checkout. Files that are already registered in the workspace get marked as changed but the files that are new are not added.

The only solution I can think of is to add all the files through the TFS SDK. But this seems pretty heavy to me.

So I got a couple of questions:

  1. Is this the right approach to update the project?
  2. Is there any other way to add the files to the workspace instead of adding all files through the TFS SDK?

Thanks!


Don't do a blind copy of the files. Instead, have your program iterate through them one by one.

  • First, update your workspace with the latest from TFS.
  • Then, for each file in the source directory:
    • If the file exists in the target directory, "pend edit" the file, then copy it.
    • If the file does not exist, copy the file, then "pend add" the file.
  • When you've finished, check in all pending changes in the workspace.
0

精彩评论

暂无评论...
验证码 换一张
取 消