Resolved Repo cloning [git@github.com:nodejs/node.git] is not successful from visual studio 2019

Joined
Nov 5, 2020
Messages
9
Programming Experience
10+
Version: Visual Studio 2019

Platform: 64-bit (Windows 10)
Windows version : Microsoft Windows [Version 10.0.19042.572]


When ever cloning is initiated from visual studio C# code, it cloned all the files except vcbuild.bat
Even tried to clone using git clone git@github.com:nodejs/node.git , git clone git://github.com/nodejs/node.git and nodejs/node
still vcbuild.bat is not clone from the repo.

C# Code :
C#:
Process proc = new Process();
proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
ProcessToUse.StartInfo.FileName ="cmd";
proc.StartInfo.Arguments = "/c \"git clone git://github.com/nodejs/node.git\"";
proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.UseShellExecute = false;
proc.Start();
string output = proc.StandardOutput.ReadToEnd().Trim();
proc.WaitForExit();

Manual execution in command prompt.
Cloning is successful through command prompt.
i.e. git clone git://github.com/nodejs/node.git

Expected behavior
Should clone entire repo.

Actual Behavior
It's cloning all the files except vcbuild.bat when cloned using Visual studio C# code.
 
Last edited by a moderator:
Solution
It's mostly a logic problem. The read stream to end on line 10 is blocking execution from reaching line 11. The correct set of operations is to wait for the app to end, and then read the output.

But it's also partly a git running from .NET Framework problem, too. For a large repository, using the "--quiet" flag seems to get things moving. If I try a small repository, I don't need the "--quiet" flag.

Anyway the following works for me:
C#:
Process proc = new Process();
proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
proc.StartInfo.FileName = "git.exe";
// proc.StartInfo.Arguments = "clone git@github.com:azureskydiver/Passphrase.git";
proc.StartInfo.Arguments = "clone --quiet git://github.com/nodejs/node.git"...
I don't think this is specifically a C# problem, but rather a .NET Framework invoking git problem.

Your code above doesn't compile. Line 3 has a major typo.

Anyway, you also failed to tell us that it isn't just the vcbuild.bat that is missing, but a whole slew of other folders are also missing. What you failed to tell us that the program doesn't actually seem to end. I can see in Task Manager that the git clone operation is still running even after giving it 5 minutes to run.
 
It's mostly a logic problem. The read stream to end on line 10 is blocking execution from reaching line 11. The correct set of operations is to wait for the app to end, and then read the output.

But it's also partly a git running from .NET Framework problem, too. For a large repository, using the "--quiet" flag seems to get things moving. If I try a small repository, I don't need the "--quiet" flag.

Anyway the following works for me:
C#:
Process proc = new Process();
proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
proc.StartInfo.FileName = "git.exe";
// proc.StartInfo.Arguments = "clone git@github.com:azureskydiver/Passphrase.git";
proc.StartInfo.Arguments = "clone --quiet git://github.com/nodejs/node.git";
proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.UseShellExecute = false;
proc.Start();
proc.WaitForExit();
string output = proc.StandardOutput.ReadToEnd().Trim();
string errors = proc.StandardError.ReadToEnd().Trim();

Console.WriteLine("Output:");
Console.WriteLine(output);

Console.WriteLine("Errors:");
Console.WriteLine(errors);
 
Last edited:
Solution
Back
Top Bottom