I have a simple batch file:
cd <path to my git repository>
git pull
I try to execute it with the following C# function:
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 };
}
But I get the following error:
"Access is denied.\r\nfatal: Not a git repository (or any of the parent directories): .git\n"
In other words I have tried to execute my batch file from C# without success for hours, however, my batch file works without any problem if I execute it in command line.
How can I get my C# function to work, what should I change in my batch file or C# function? Thanks
EDIT:
I have changed the batch file's content to the following:
cd <path to my git repository> && git pull
But I receive the following error:
Access is denied.
EDIT2:
I've added access to the folder and now I get a new error:
fatal: Not a git repository: "../.git/modules/myProject\n"
EDIT3:
I have given access rights to the folder mentioned in EDIT2, but now I receive the following error:
"error: unable to create directory for C:/myFolder/.git/modules/myProject/ORIG_HEAD\nfatal: Cannot lock the ref 'ORIG_HEAD'.\n"