我正在尝试从SVN预先签名挂钩中的控制台应用程序调用MSTest,但是出现错误吗?
-
03-10-2019 - |
题
我正在尝试从一个简单的控制台应用程序调用mstest.exe,该应用程序是从SVN预先固定挂钩内部执行的。
如果我使用TortoisesVN进行提交,它将自动运行下面的控制台应用程序代码。
(在代码之后跳过,看看会发生什么...)
// 代码
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;
}
// 输出
这就是我在Tortoisesvn窗口中看到的:
错误:提交失败(详细信息如下):
错误:通过预先承诺钩(退出代码1)阻止提交,输出:
错误:Microsoft(R)测试执行命令行工具版本10.0.30319.1
错误:版权(C)Microsoft Corporation。版权所有。
错误:
错误:文件
错误:“ c: users myname documents svn test bin debug debug testproject1.dll”
错误:找不到。
因此,您可以看到我正确地打电话给mstest,但声称这条路是错误的。
但是,如果我手动打开VS命令提示符并键入完全相同的路径,则代码在没有错误的情况下运行。
我究竟做错了什么?
解决方案
可能,这实际上可能是一个许可问题,而不是FNF问题。
在执行代码时运行Filemon,并查看在操作系统级别上实际请求的内容。
不隶属于 StackOverflow