开发者

I'm trying to call MSTest from a console app inside an SVN pre-commit hook, but getting an error?

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 out开发者_开发知识库put;
}

// 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?


It's possible, this may actually be a permissions issue, not a FnF issue.

Run filemon while you are executing the code, and see what is actually being requested at the OS level.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜