Search code examples
c#tfstfs-sdk

How do I get information about a warning from the TFS-API


I'm trying to write a simple program in the TFS API that, given a change set number, will get latest on all the files in that change set. With the hope that this will make updating build servers easier.

Using some black magic the code figures out a list of files that need to be updated. Once it has a list of mapped files it performs a Workspace.Get on them. This returns a GetStatus object.

The problem I'm running into is that on some of our virtual build servers the cloning process produced files that were not marked readonly. This produces a warning message when TFS tries to update those files. In this scenario the GetStatus.NoActionNeeded boolean is false and the GetStatus.NumWarnings is set to the number of files it couldn't get. The problem is there is no way to pinpoint which files specifically are having this problem. GetStatus.GetFailures() returns an array of size 0 so I'm at a loss as to how to get this information.

Is it possible to retrieve that list? I'd like to present it to the user so they can decide whether to overwrite the files in question or take some other action.


Solution

  • If a get fails and there are no failures you can retrieve a list of conflicts by taking the same list of items passed into the get call and pass them to Workspace.QueryConflicts. This will return an array of conflicts with file names and information about what the problem was.