Question

I'm trying to write an application that provides my own UI for tf.exe (in TFS 2010). (yes, I know VS already does this but this app is custom). For some commands, like properties, I want to capture output from stdout. Also, when a command fails, I want to capture its error output from stderr. I'm using .NET's Process class to launch tf.exe, like so:

try
{
   sccProcess.StartInfo.FileName = "tf.exe"; 
   sccProcess.StartInfo.Arguments = arguments;
   sccProcess.StartInfo.CreateNoWindow = true;
   sccProcess.StartInfo.UseShellExecute = false;
   sccProcess.StartInfo.RedirectStandardOutput = true;
   sccProcess.StartInfo.RedirectStandardError = true;
   sccProcess.Start();

   output = sccProcess.StandardOutput.ReadToEnd();

   // Redirecting synchronously from output and error streams may cause a deadlock.
   // To prevent that, we always read the error stream asynchronously.
   sccProcess.ErrorDataReceived += (sender, args) => errorStringBuilder.Append(args.Data);
   sccProcess.BeginErrorReadLine();

   sccProcess.WaitForExit();
   exitCode = sccProcess.ExitCode;

   error = errorStringBuilder.ToString();
}
catch (Win32Exception)
{
    // The file name for the process couldn't be found.
    exitCode = -1;
}
finally
{
    sccProcess.Close();
}

However, when I run a command, say "tf checkin", I notice that when standard error is redirected, I no longer see the checkin dialog box that normally opens. Instead, the checkin just happens. Thus, it seems like redirecting stderr for tf.exe behaves as if I set the noprompt flag. Does anyone know how I can capture stderr data without stopping tf.exe dialog prompts?

Thanks,

-Craig

Was it helpful?

Solution

You might be better off calling the TFS API directly rather than calling tf.exe from code. That way you'll have much more control over the behaviour of the application and all the benefits of exceptions rather than stderr. The API also exposes a lot more functionality than is available from tf.exe tfpt.exe and visual studio.

OTHER TIPS

Finally, after months of being frustrated about this I found the solution.

Apparently there's a hidden parameter to tf.exe called /prompt, which forces the UI to be shown even though you've redirected stdout.

Source: http://www.wintellect.com/cs/blogs/jrobbins/archive/2006/12/26/working-offline-with-tfs.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top