/// <summary> /// Applies an <see cref="ExecutableInVar"/> binding by creating a run-environment executable. /// </summary> /// <param name="binding">The binding to apply.</param> /// <param name="implementation">The implementation to be made available.</param> /// <param name="startInfo">The process launch environment to use to make the run-environment executable available.</param> /// <exception cref="KeyNotFoundException"><see cref="Selections"/> points to missing <see cref="Dependency"/>s.</exception> /// <exception cref="ImplementationNotFoundException">One of the <see cref="Store.Model.Implementation"/>s is not cached yet.</exception> /// <exception cref="ExecutorException"><see cref="ExecutableInVar.Name"/> is invalid.</exception> /// <exception cref="IOException">A problem occurred while writing the file.</exception> /// <exception cref="UnauthorizedAccessException">Write access to the file is not permitted.</exception> private void ApplyExecutableInVar(ExecutableInVar binding, ImplementationSelection implementation, ProcessStartInfo startInfo) { Log.Debug("Applying " + binding + " for " + implementation); if (string.IsNullOrEmpty(binding.Name)) { throw new ExecutorException(string.Format(Resources.MissingBindingName, @"<executable-in-var>")); } if (Path.GetInvalidFileNameChars().Any(invalidChar => binding.Name.Contains(invalidChar.ToString(CultureInfo.InvariantCulture)))) { throw new ExecutorException(string.Format(Resources.IllegalCharInBindingName, @"<executable-in-var>")); } string exePath = DeployRunEnvExecutable(binding.Name); // Point variable directly to executable if (startInfo.EnvironmentVariables.ContainsKey(binding.Name)) { Log.Warn("Overwriting existing environment variable with <executable-in-var>: " + binding.Name); } startInfo.EnvironmentVariables[binding.Name] = exePath; // Tell the executable what command-line to run _runEnvPendings.Add(new RunEnvPending(binding.Name, GetCommandLine(implementation, binding.Command ?? Command.NameRun, startInfo))); }
/// <summary> /// Applies an <see cref="ExecutableInVar"/> binding by creating a run-environment executable. /// </summary> /// <param name="binding">The binding to apply.</param> /// <param name="implementation">The implementation to be made available.</param> /// <param name="startInfo">The process launch environment to use to make the run-environment executable available.</param> /// <exception cref="KeyNotFoundException"><see cref="Selections"/> points to missing <see cref="Dependency"/>s.</exception> /// <exception cref="ImplementationNotFoundException">One of the <see cref="Store.Model.Implementation"/>s is not cached yet.</exception> /// <exception cref="ExecutorException"><see cref="ExecutableInVar.Name"/> is invalid.</exception> /// <exception cref="IOException">A problem occurred while writing the file.</exception> /// <exception cref="UnauthorizedAccessException">Write access to the file is not permitted.</exception> private void ApplyExecutableInVar(ExecutableInVar binding, ImplementationSelection implementation, ProcessStartInfo startInfo) { Log.Debug("Applying " + binding + " for " + implementation); if (string.IsNullOrEmpty(binding.Name)) throw new ExecutorException(string.Format(Resources.MissingBindingName, @"<executable-in-var>")); if (Path.GetInvalidFileNameChars().Any(invalidChar => binding.Name.Contains(invalidChar.ToString(CultureInfo.InvariantCulture)))) throw new ExecutorException(string.Format(Resources.IllegalCharInBindingName, @"<executable-in-var>")); string exePath = DeployRunEnvExecutable(binding.Name); // Point variable directly to executable if (startInfo.EnvironmentVariables.ContainsKey(binding.Name)) Log.Warn("Overwriting existing environment variable with <executable-in-var>: " + binding.Name); startInfo.EnvironmentVariables[binding.Name] = exePath; // Tell the executable what command-line to run _runEnvPendings.Add(new RunEnvPending(binding.Name, GetCommandLine(implementation, binding.Command ?? Command.NameRun, startInfo))); }