[英]OutputDataReceived does not work with windows git.exe
我确实有一个奇怪的问题:我尝试通过小c#console-application->调用git.exe克隆存储库
Process p = new Process();
p.StartInfo.FileName = "path/to/git/git.exe";
p.StartInfo.Arguments = "clone SomeGitRepoWhichRequiresPassword";
p.StartInfo.UseShellExecute = false;
p.EnableRaisingEvents = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardError = true;
p.OutputDataReceived += OutputDataReceived;
p.ErrorDataReceived += ErrorDataReceived;
p.Exited += Exited;
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.WaitForExit();
当我尝试克隆需要用户输入(例如,输入ssh密码)的存储库时,不会触发任何事件,因此我无法以编程方式对此输入做出反应。 有没有一种方法可以真正获得ALL命令的输出?
谢谢!
为什么要以编程方式输入密码? 您可以尝试在Git存储库URL中写密码,如下所示:
git clone https://username:password@github.com/username/repository.git
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.