我有一个简单的批处理文件:的Git拉问题与C#函数执行批处理文件
cd <path to my git repository>
git pull
我尝试用下面的C#函数来执行它:
private NuGetBO.ShellCommandReturn ExecuteCommand(string path)
{
ProcessStartInfo processInfo;
Process process;
processInfo = new ProcessStartInfo(path);
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
// *** Redirect the output ***
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
process = Process.Start(processInfo);
process.WaitForExit(5000);
// *** Read the streams ***
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
int exitCode = process.ExitCode;
process.Close();
return new NuGetBO.ShellCommandReturn { Error = error, ExitCode = exitCode, Output = output };
}
但我得到以下错误:
"Access is denied.\r\nfatal: Not a git repository (or any of the parent directories): .git\n"
换句话说,我试图执行从C#我的批处理文件,没有成功了几个小时,但我的批处理文件WOR ks没有任何问题,如果我在命令行中执行它。
如何让我的C#函数工作,我应该在批处理文件或C#函数中更改哪些内容?由于
编辑:
我已经改变了批处理文件的内容如下:
cd <path to my git repository> && git pull
但我收到以下错误:
Access is denied.
EDIT2:
我已添加访问该文件夹,现在我得到一个新的错误:
fatal: Not a git repository: "../.git/modules/myProject\n"
EDIT3:
我已经给了访问权限,在EDIT2提到的文件夹,但现在我收到以下错误:
"error: unable to create directory for C:/myFolder/.git/modules/myProject/ORIG_HEAD\nfatal: Cannot lock the ref 'ORIG_HEAD'.\n"
这是一个愚蠢的(也许不是?)问题要问你:你确定的路径是相同的100%? –
是的,我相信,但是从根本上来说,这个bug可能就在那里,这绝不是愚蠢的做法。 –