public ProcessExecutionCommand CreateExecutionCommand (WorkspaceObject entry, ConfigurationSelector configuration)
{
if (string.IsNullOrEmpty (command))
throw new UserException (GettextCatalog.GetString ("Invalid custom command for '{0}' step: the path to the command to execute has not been provided.", TypeLabel));
string exe, args;
StringTagModel tagSource = GetTagModel (entry, configuration);
ParseCommand (tagSource, out exe, out args);
//if the executable name matches an executable in the project directory, use that, for back-compat
//else fall back and let the execution handler handle it via PATH, working directory, etc.
if (!Path.IsPathRooted (exe)) {
string localPath = ((FilePath) exe).ToAbsolute (entry.BaseDirectory).FullPath;
if (File.Exists (localPath))
exe = localPath;
}
ProcessExecutionCommand cmd = Runtime.ProcessService.CreateCommand (exe);
cmd.Arguments = args;
FilePath workingDir = this.workingdir;
if (!workingDir.IsNullOrEmpty)
workingDir = StringParserService.Parse (workingDir, tagSource);
cmd.WorkingDirectory = workingDir.IsNullOrEmpty
? entry.BaseDirectory
: workingDir.ToAbsolute (entry.BaseDirectory);
if (environmentVariables != null) {
var vars = new Dictionary<string, string> ();
foreach (var v in environmentVariables)
vars [v.Key] = StringParserService.Parse (v.Value, tagSource);
cmd.EnvironmentVariables = vars;
}
return cmd;
}