public override Process CreateProcess(string path, string args, bool useShellExecute, string workingDirectory) { // If we're asked to start a WSL executable we must launch via the wsl.exe command tool if (!useShellExecute && WslUtils.IsWslPath(path)) { string wslPath = WslUtils.ConvertToDistroPath(path, out string distro); return(WslUtils.CreateWslProcess(distro, $"{wslPath} {args}", workingDirectory)); } return(base.CreateProcess(path, args, useShellExecute, workingDirectory)); }
public void WslUtils_CreateWslProcess() { const string distribution = "ubuntu"; const string command = "/usr/lib/git-core/git version"; string expectedFileName = WslUtils.GetWslPath(); string expectedArgs = $"--distribution {distribution} --exec {command}"; Process process = WslUtils.CreateWslProcess(distribution, command); Assert.NotNull(process); Assert.Equal(expectedArgs, process.StartInfo.Arguments); Assert.Equal(expectedFileName, process.StartInfo.FileName); Assert.True(process.StartInfo.RedirectStandardInput); Assert.True(process.StartInfo.RedirectStandardOutput); Assert.True(process.StartInfo.RedirectStandardError); Assert.False(process.StartInfo.UseShellExecute); }