This project is read-only.

UndoCheckout - HELP!!!

Jan 21, 2013 at 9:53 PM
Edited Jan 21, 2013 at 10:01 PM

I can’t seem to find any good information on the use of the UndoCheckout task
action for MSBuild.ExtensionPack.VisualStudio.TfsSource. My (perhaps naïve)
impression is that this is similar to a tf undo, where I can undo the checkout
of a file in TFS.

Here’s my target:  

<Target Name="UndoCheckOut">
<MSBuild.ExtensionPack.VisualStudio.TfsSource TaskAction="UndoCheckout" ItemPath="$(MyBinaryPath)" Version="2010" WorkingDirectory="$(MySolutionRoot)"/>

It runs, but throws an error.  Here’s the error I get back:

0 error(s), 2 warning(s) $/GrandCentral/AppDev/Dev/Shared/TeamBuildScripts/TFSCheckin.proj - 0 error(s), 2 warning(s), View Log File

D:\TfsBuild\Builds\210\Sources\TeamBuildScripts\UndoCheckOut.proj (12): Exit Code 1. Partial success: No pending changes were found for $/GrandCentral/AppDev/Dev/Shared/_MTDependencies/GCBaseClasses.

D:\TfsBuild\Builds\210\Sources\TeamBuildScripts\TFSCheckin.proj (42): Exit Code 1. Partial success: The item $/GrandCentral/AppDev/Dev/Shared/_MTDependencies/GCBaseClasses/EpsiBase.dll is locked for check-out by jroth in workspace TX-LT13142.

Obviously, no file checkouts are undone. That file (EpsiBase.dll) is one I’ve checked out on my 
workstation for testing purposes.  Do I need to “GetPendingChanges,” and somehow use some sort
of return value to iterate over pending changes and undo them, or am I just barking up the
wrong tree?

Jan 22, 2013 at 3:55 PM

Allow me to elaborate a bit more.

My question is how to get enough information to the TF command (or UndoCheckout extension) to have it undo a checkout from another user.  I know it’s possible using TF Undo, but you have to specify the exact file name (including the TFS path), workspace, and the project collection.  Is there a way for me to get the list of files and workspaces back from GetPendingChanges so that I can pass to an undo command?  It appears that GetPendingChanges will return a string that has what the pending changes are – is there a way to parse the workspace and filename from PendingChangesExistItem?

Example of a successful TF undo command:  tf undo /workspace:TX-LT13142 $/MyPath/BaseClasses/BaseClass1.dll /collection:http://blah.blah.blah/

Works a treat.  I just need to be able to do that based on what GetPendingChanges returns, if possible.

Marked as answer by mikeFourie on 10/15/2013 at 8:32 AM