开发者

Determine if workspace exists on build server

Is it possible to determine whether a workspace exist on the server given the local path using tf.exe?

This can be done using the TFS API but that would require me to build the task source code before using it which is not possible because I don't have a workspace yet. Checking binaries into source control 开发者_高级运维is not an option.

Any ideas?


If you run the tf.exe workfold command passing in the local directory, it will either return an error if the folder is not mapped, or it will return the workspace information. You can (in a hacky fashion) determine if an error occurred by redirecting the stderr to a text file, then checking to see if the file is empty. For example:

tf.exe workfold c:\some\mapping\folder\path 2> error.txt

You may also be able to check the exit code from the command. Based on research, it looks like the exit code is set to 100 if there's an error. Not sure what you can do in the task, but in a CMD file you can check ERRORLEVEL.

To see this in action, try:

tf.exe workfold "C:\program files" 2> error.txt
echo %ERRORLEVEL%
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜