/// <exception cref="NGit.Errors.TransportException"></exception> public virtual SystemProcess Exec(string command, int timeout) { string ssh = SystemReader.GetInstance().Getenv("GIT_SSH"); bool putty = ssh.ToLower().Contains("plink"); IList<string> args = new AList<string>(); args.AddItem(ssh); if (putty && !ssh.ToLower().Contains("tortoiseplink")) { args.AddItem("-batch"); } if (0 < this._enclosing.GetURI().GetPort()) { args.AddItem(putty ? "-P" : "-p"); args.AddItem(this._enclosing.GetURI().GetPort().ToString()); } if (this._enclosing.GetURI().GetUser() != null) { args.AddItem(this._enclosing.GetURI().GetUser() + "@" + this._enclosing.GetURI(). GetHost()); } else { args.AddItem(this._enclosing.GetURI().GetHost()); } args.AddItem(command); ProcessStartInfo pb = new ProcessStartInfo(); pb.SetCommand(args); if (this._enclosing.local.Directory != null) { pb.EnvironmentVariables.Put(Constants.GIT_DIR_KEY, this._enclosing.local.Directory .GetPath()); } try { return pb.Start(); } catch (IOException err) { throw new TransportException(err.Message, err); } }
/// <summary> /// Runs ngen in the background to pre-compile new/updated .NET assemblies. /// </summary> private void Ngen() { if (IsPortable || !WindowsUtils.IsAdministrator) return; // Use .NET 4.0 if possible, otherwise 2.0 string netFxDir = WindowsUtils.GetNetFxDirectory( WindowsUtils.HasNetFxVersion(WindowsUtils.NetFx40) ? WindowsUtils.NetFx40 : WindowsUtils.NetFx20); string ngenPath = Path.Combine(netFxDir, "ngen.exe"); if (!File.Exists(ngenPath)) return; foreach (string assembly in _ngenAssemblies) { string arguments = new[] {"install", Path.Combine(Target, assembly)}.JoinEscapeArguments(); var startInfo = new ProcessStartInfo(ngenPath, arguments) {WindowStyle = ProcessWindowStyle.Hidden}; using (var process = startInfo.Start()) if (process != null) process.WaitForExit(); } }
/// <exception cref="NGit.Errors.TransportException"></exception> internal override void Exec(string commandName) { string ssh = SystemReader.GetInstance().Getenv("GIT_SSH"); bool putty = ssh.ToLower().Contains("plink"); IList<string> args = new AList<string>(); args.AddItem(ssh); if (putty) { args.AddItem("--batch"); } if (0 < this._enclosing.GetURI().GetPort()) { args.AddItem(putty ? "-P" : "-p"); args.AddItem(this._enclosing.GetURI().GetPort().ToString()); } if (this._enclosing.GetURI().GetUser() != null) { args.AddItem(this._enclosing.GetURI().GetUser() + "@" + this._enclosing.GetURI(). GetHost()); } else { args.AddItem(this._enclosing.GetURI().GetHost()); } args.AddItem(this._enclosing.CommandFor(commandName)); ProcessStartInfo pb = new ProcessStartInfo(); pb.SetCommand(args); if (this._enclosing.local.Directory != null) { pb.EnvironmentVariables.Put(Constants.GIT_DIR_KEY, this._enclosing.local.Directory .GetPath()); } try { this.proc = pb.Start(); } catch (IOException err) { throw new TransportException(this._enclosing.uri, err.Message, err); } }
private void buttonCommandLine_Click(object sender, EventArgs e) { ProcessUtils.SanitizeEnvironmentVariables(); var cmd = new ProcessStartInfo("cmd.exe", "/k echo " + Resources.CommandLineHint) { UseShellExecute = false, WorkingDirectory = Locations.IsPortable ? Locations.PortableBase : Locations.HomeDir }; cmd.EnvironmentVariables["Path"] = Locations.InstallBase + Path.PathSeparator + Environment.GetEnvironmentVariable("Path"); cmd.Start(); }