public override void InitStreams(LaunchOptions options, out StreamReader reader, out StreamWriter writer) { PipeLaunchOptions pipeOptions = (PipeLaunchOptions)options; if (!LocalLaunchOptions.CheckDirectoryPath(pipeOptions.PipeCwd)) { throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, MICoreResources.Error_InvalidLocalDirectoryPath, pipeOptions.PipeCwd)); } if (!LocalLaunchOptions.CheckFilePath(pipeOptions.PipePath)) { throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, MICoreResources.Error_InvalidLocalExePath, pipeOptions.PipePath)); } _cmdArgs = pipeOptions.PipeCommandArguments; Process proc = new Process(); _pipePath = pipeOptions.PipePath; proc.StartInfo.FileName = pipeOptions.PipePath; proc.StartInfo.Arguments = pipeOptions.PipeArguments; proc.StartInfo.WorkingDirectory = pipeOptions.PipeCwd; foreach (EnvironmentEntry entry in pipeOptions.PipeEnvironment) { proc.StartInfo.SetEnvironmentVariable(entry.Name, entry.Value); } InitProcess(proc, out reader, out writer); }
public override void InitStreams(LaunchOptions options, out StreamReader reader, out StreamWriter writer) { PipeLaunchOptions pipeOptions = (PipeLaunchOptions)options; string workingDirectory = pipeOptions.PipeCwd; if (!string.IsNullOrWhiteSpace(workingDirectory)) { if (!LocalLaunchOptions.CheckDirectoryPath(workingDirectory)) { throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, MICoreResources.Error_InvalidLocalDirectoryPath, workingDirectory)); } } else { workingDirectory = Path.GetDirectoryName(pipeOptions.PipePath); if (!LocalLaunchOptions.CheckDirectoryPath(workingDirectory)) { // If provided PipeCwd is not an absolute path, the working directory will be set to null. workingDirectory = null; } } if (string.IsNullOrWhiteSpace(pipeOptions.PipePath)) { throw new ArgumentException(MICoreResources.Error_EmptyPipePath); } _cmdArgs = pipeOptions.PipeCommandArguments; Process proc = new Process(); _pipePath = pipeOptions.PipePath; proc.StartInfo.FileName = pipeOptions.PipePath; proc.StartInfo.Arguments = pipeOptions.PipeArguments; proc.StartInfo.WorkingDirectory = workingDirectory; foreach (EnvironmentEntry entry in pipeOptions.PipeEnvironment) { proc.StartInfo.SetEnvironmentVariable(entry.Name, entry.Value); } InitProcess(proc, out reader, out writer); }