Search code examples
batch-filecommand-linetfstfsbuildbuild-definition

Error when execute within a TFS build definition


When I tried to call command-line to get latest update for my TFS mapped folder

TF get /recursive

The call complete successfully from the run window of Windows 7.

However, when I put the call into a .bat file and run it via InvokeProcess within a build definition (guide to do that), it failed.

The message is as below.

Unable to determine the workspace. You may be able to correct this by running 'tf workspaces /collection:TeamProjectCollectionUrl'

What happens? How can I get around with that?


Solution

  • The cause for my issue is that the build agent execute my .bat file under a different Windows account which is something like NTSERVICE; when I run it directly, my TFS login account was used (which was previously remembered in Windows 7 Credential Manager)

    So the solution is to put in the login name and password as TF get /login:SomeTFSUsername,SomePassword (see more here)