I am trying to call MSTest.exe from a simple console app that is executed from inside an SVN pre-commit hook.
If I use TortoiseSVN to Commit, it auto-runs the console app code below.
(skip after the code to see what happens...)
// CODE
static void Main(string[] args)
{
string testPath = @"C:\Users\myname\Documents\SVN\Test\bin\Debug\TestProject1.dll";
string mstest = GetMSTestOutput(testPath);
if (mstest != null)
{
Console.Error.WriteLine(mstest);
Environment.Exit(1); // I WANT it to stop here, so I can see output while testing
}
}
private static string GetMSTestOutput(string testPath)
{
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
FileName = @"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe",
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
Arguments = String.Format("/testcontainer:{0}", testPath)
};
Process process = Process.Start(processStartInfo);
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return output;
}
// OUTPUT
This is what I see in the TortoiseSVN window:
Error: Commit failed (details follow):
Error: Commit blocked by pre-commit hook (exit code 1) with output:
Error: Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1
Error: Copyright (c) Microsoft Corporation. All rights reserved.
Error:
Error: File
Error: "C:\Users\myname\Documents\SVN\Test\bin\Debug\TestProject1.dll"
Error: not found .
So you can see I am calling MSTest correctly, but it's claiming the path is wrong.
BUT, if I open a VS Command Prompt manually and type the EXACT same path, the code runs without error.
What am I doing wrong?