85
85
set { pauseExternalConsole = value; }
88
public string GetCommandFile (IWorkspaceObject entry, ConfigurationSelector configuration)
91
StringTagModel tagSource = GetTagModel (entry, configuration);
92
ParseCommand (tagSource, out exe, out args);
96
public string GetCommandArgs (IWorkspaceObject entry, ConfigurationSelector configuration)
99
StringTagModel tagSource = GetTagModel (entry, configuration);
100
ParseCommand (tagSource, out exe, out args);
104
public FilePath GetCommandWorkingDir (IWorkspaceObject entry, ConfigurationSelector configuration)
106
StringTagModel tagSource = GetTagModel (entry, configuration);
107
return (string.IsNullOrEmpty (workingdir) ? entry.BaseDirectory : (FilePath) StringParserService.Parse (workingdir, tagSource));
88
110
public CustomCommand Clone ()
90
112
CustomCommand cmd = new CustomCommand ();
122
StringTagModel GetTagModel (IWorkspaceObject entry, ConfigurationSelector configuration)
124
if (entry is SolutionItem)
125
return ((SolutionItem)entry).GetStringTagModel (configuration);
126
else if (entry is WorkspaceItem)
127
return ((WorkspaceItem)entry).GetStringTagModel ();
129
return new StringTagModel ();
132
void ParseCommand (StringTagModel tagSource, out string cmd, out string args)
134
if (command.Length > 0 && command [0] == '"') {
135
int n = command.IndexOf ('"', 1);
137
cmd = command.Substring (1, n - 1);
138
args = command.Substring (n + 1).Trim ();
146
int i = command.IndexOf (' ');
148
cmd = command.Substring (0, i);
149
args = command.Substring (i + 1).Trim ();
155
cmd = StringParserService.Parse (cmd, tagSource);
156
args = StringParserService.Parse (args, tagSource);
100
159
public void Execute (IProgressMonitor monitor, IWorkspaceObject entry, ConfigurationSelector configuration)
102
161
Execute (monitor, entry, null, configuration);
105
public bool CanExecute (ExecutionContext context, ConfigurationSelector configuration)
164
public bool CanExecute (IWorkspaceObject entry, ExecutionContext context, ConfigurationSelector configuration)
107
string exe = command;
108
int i = exe.IndexOf (' ');
110
exe = command.Substring (0, i);
167
StringTagModel tagSource = GetTagModel (entry, configuration);
168
ParseCommand (tagSource, out exe, out args);
112
169
ExecutionCommand cmd = Runtime.ProcessService.CreateCommand (exe);
113
170
return context == null || context.ExecutionHandler.CanExecute (cmd);
116
173
public void Execute (IProgressMonitor monitor, IWorkspaceObject entry, ExecutionContext context, ConfigurationSelector configuration)
118
StringTagModel tagSource;
120
if (entry is SolutionItem)
121
tagSource = ((SolutionItem)entry).GetStringTagModel (configuration);
122
else if (entry is WorkspaceItem)
123
tagSource = ((WorkspaceItem)entry).GetStringTagModel ();
125
tagSource = new StringTagModel ();
127
175
if (string.IsNullOrEmpty (command))
130
int i = command.IndexOf (' ');
132
string args = string.Empty;
137
exe = command.Substring (0, i);
138
args = StringParserService.Parse (command.Substring (i + 1), tagSource);
178
StringTagModel tagSource = GetTagModel (entry, configuration);
181
ParseCommand (tagSource, out exe, out args);
141
183
monitor.Log.WriteLine (GettextCatalog.GetString ("Executing: {0} {1}", exe, args));
143
FilePath dir = (string.IsNullOrEmpty (workingdir) ? entry.BaseDirectory : (FilePath) StringParserService.Parse (workingdir, tagSource));
185
FilePath dir = GetCommandWorkingDir (entry, configuration);
145
187
FilePath localPath = entry.BaseDirectory.Combine (exe);
146
188
if (File.Exists (localPath))
149
191
IProcessAsyncOperation oper;
151
if (context != null) {
154
console = context.ExternalConsoleFactory.CreateConsole (!pauseExternalConsole);
156
console = context.ConsoleFactory.CreateConsole (!pauseExternalConsole);
158
ExecutionCommand cmd = Runtime.ProcessService.CreateCommand (exe);
159
ProcessExecutionCommand pcmd = cmd as ProcessExecutionCommand;
161
pcmd.Arguments = args;
162
pcmd.WorkingDirectory = dir;
164
oper = context.ExecutionHandler.Execute (cmd, console);
167
if (externalConsole) {
168
IConsole console = ExternalConsoleFactory.Instance.CreateConsole (!pauseExternalConsole);
169
oper = Runtime.ProcessService.StartConsoleProcess (exe, args, dir, console, null);
171
oper = Runtime.ProcessService.StartProcess (exe, args, dir, monitor.Log, monitor.Log, null, false);
194
if (context != null) {
197
console = context.ExternalConsoleFactory.CreateConsole (!pauseExternalConsole);
199
console = context.ConsoleFactory.CreateConsole (!pauseExternalConsole);
201
ExecutionCommand cmd = Runtime.ProcessService.CreateCommand (exe);
202
ProcessExecutionCommand pcmd = cmd as ProcessExecutionCommand;
204
pcmd.Arguments = args;
205
pcmd.WorkingDirectory = dir;
207
oper = context.ExecutionHandler.Execute (cmd, console);
210
if (externalConsole) {
211
IConsole console = ExternalConsoleFactory.Instance.CreateConsole (!pauseExternalConsole);
212
oper = Runtime.ProcessService.StartConsoleProcess (exe, args, dir, console, null);
214
oper = Runtime.ProcessService.StartProcess (exe, args, dir, monitor.Log, monitor.Log, null, false);
217
} catch (Exception ex) {
218
throw new UserException (GettextCatalog.GetString ("Command execution failed: {0}",ex.Message));
175
221
monitor.CancelRequested += delegate {