aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2018-12-27 11:07:45 -0800
committerRob Mensching <rob@robmensching.com>2018-12-27 11:14:08 -0800
commit05c1b41651afced8b3f3629668ef1b32bcc04e6d (patch)
treef17b79ae6457511f2ed13a6dbdd4ffe4acdffc05
parentc6da3f6d1c9b571d8f58745560332c3e0531a5c5 (diff)
downloadwix-05c1b41651afced8b3f3629668ef1b32bcc04e6d.tar.gz
wix-05c1b41651afced8b3f3629668ef1b32bcc04e6d.tar.bz2
wix-05c1b41651afced8b3f3629668ef1b32bcc04e6d.zip
Minor code clean up in build task
-rw-r--r--src/WixToolset.BuildTasks/DoIt.cs110
1 files changed, 20 insertions, 90 deletions
diff --git a/src/WixToolset.BuildTasks/DoIt.cs b/src/WixToolset.BuildTasks/DoIt.cs
index 07bf05e5..ac0f895c 100644
--- a/src/WixToolset.BuildTasks/DoIt.cs
+++ b/src/WixToolset.BuildTasks/DoIt.cs
@@ -136,6 +136,25 @@ namespace WixToolset.BuildTasks
136 136
137 private void ExecuteCore(IServiceProvider serviceProvider, IMessageListener listener) 137 private void ExecuteCore(IServiceProvider serviceProvider, IMessageListener listener)
138 { 138 {
139 var commandLineString = this.BuildCommandLine();
140
141 this.Log.LogMessage(MessageImportance.Normal, "wix.exe " + commandLineString);
142
143 var messaging = serviceProvider.GetService<IMessaging>();
144 messaging.SetListener(listener);
145
146 var arguments = serviceProvider.GetService<ICommandLineArguments>();
147 arguments.Populate(commandLineString);
148
149 var commandLine = serviceProvider.GetService<ICommandLine>();
150 commandLine.ExtensionManager = this.CreateExtensionManagerWithStandardBackends(serviceProvider, messaging, arguments.Extensions);
151 commandLine.Arguments = arguments;
152 var command = commandLine.ParseStandardCommandLine();
153 command?.Execute();
154 }
155
156 private string BuildCommandLine()
157 {
139 var commandLineBuilder = new WixCommandLineBuilder(); 158 var commandLineBuilder = new WixCommandLineBuilder();
140 159
141 commandLineBuilder.AppendTextUnquoted("build"); 160 commandLineBuilder.AppendTextUnquoted("build");
@@ -164,21 +183,7 @@ namespace WixToolset.BuildTasks
164 commandLineBuilder.AppendTextIfNotWhitespace(this.AdditionalOptions); 183 commandLineBuilder.AppendTextIfNotWhitespace(this.AdditionalOptions);
165 commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " "); 184 commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " ");
166 185
167 var commandLineString = commandLineBuilder.ToString(); 186 return commandLineBuilder.ToString();
168
169 this.Log.LogMessage(MessageImportance.Normal, "wix.exe " + commandLineString);
170
171 var messaging = serviceProvider.GetService<IMessaging>();
172 messaging.SetListener(listener);
173
174 var arguments = serviceProvider.GetService<ICommandLineArguments>();
175 arguments.Populate(commandLineString);
176
177 var commandLine = serviceProvider.GetService<ICommandLine>();
178 commandLine.ExtensionManager = this.CreateExtensionManagerWithStandardBackends(serviceProvider, messaging, arguments.Extensions);
179 commandLine.Arguments = arguments;
180 var command = commandLine.ParseStandardCommandLine();
181 command?.Execute();
182 } 187 }
183 188
184 private IExtensionManager CreateExtensionManagerWithStandardBackends(IServiceProvider serviceProvider, IMessaging messaging, string[] extensions) 189 private IExtensionManager CreateExtensionManagerWithStandardBackends(IServiceProvider serviceProvider, IMessaging messaging, string[] extensions)
@@ -205,11 +210,6 @@ namespace WixToolset.BuildTasks
205 return extensionManager; 210 return extensionManager;
206 } 211 }
207 212
208 private void DisplayMessage(object sender, DisplayEventArgs e)
209 {
210 this.Log.LogMessageFromText(e.Message, MessageImportance.Normal);
211 }
212
213 private IEnumerable<string> CalculateBindPathStrings() 213 private IEnumerable<string> CalculateBindPathStrings()
214 { 214 {
215 if (null != this.BindInputPaths) 215 if (null != this.BindInputPaths)
@@ -231,76 +231,6 @@ namespace WixToolset.BuildTasks
231 } 231 }
232 } 232 }
233 233
234 ///// <summary>
235 ///// Builds a command line from options in this task.
236 ///// </summary>
237 //protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
238 //{
239 // base.BuildCommandLine(commandLineBuilder);
240
241 // commandLineBuilder.AppendIfTrue("-p", this.PreprocessToStdOut);
242 // commandLineBuilder.AppendSwitchIfNotNull("-p", this.PreprocessToFile);
243 // commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
244 // commandLineBuilder.AppendArrayIfNotNull("-d", this.DefineConstants);
245 // commandLineBuilder.AppendArrayIfNotNull("-I", this.IncludeSearchPaths);
246 // commandLineBuilder.AppendIfTrue("-pedantic", this.Pedantic);
247 // commandLineBuilder.AppendSwitchIfNotNull("-arch ", this.InstallerPlatform);
248 // commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.referencePaths);
249 // commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
250
251 // // Support per-source-file output by looking at the SourceFiles items to
252 // // see if there is any "CandleOutput" metadata. If there is, we do our own
253 // // appending, otherwise we fall back to the built-in "append file names" code.
254 // // Note also that the wix.targets "Compile" target does *not* automagically
255 // // fix the "@(CompileObjOutput)" list to include these new output names.
256 // // If you really want to use this, you're going to have to clone the target
257 // // in your own .targets file and create the output list yourself.
258 // bool usePerSourceOutput = false;
259 // if (this.SourceFiles != null)
260 // {
261 // foreach (ITaskItem item in this.SourceFiles)
262 // {
263 // if (!String.IsNullOrEmpty(item.GetMetadata("CandleOutput")))
264 // {
265 // usePerSourceOutput = true;
266 // break;
267 // }
268 // }
269 // }
270
271 // if (usePerSourceOutput)
272 // {
273 // string[] newSourceNames = new string[this.SourceFiles.Length];
274 // for (int iSource = 0; iSource < this.SourceFiles.Length; ++iSource)
275 // {
276 // ITaskItem item = this.SourceFiles[iSource];
277 // if (null == item)
278 // {
279 // newSourceNames[iSource] = null;
280 // }
281 // else
282 // {
283 // string output = item.GetMetadata("CandleOutput");
284
285 // if (!String.IsNullOrEmpty(output))
286 // {
287 // newSourceNames[iSource] = String.Concat(item.ItemSpec, ";", output);
288 // }
289 // else
290 // {
291 // newSourceNames[iSource] = item.ItemSpec;
292 // }
293 // }
294 // }
295
296 // commandLineBuilder.AppendFileNamesIfNotNull(newSourceNames, " ");
297 // }
298 // else
299 // {
300 // commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " ");
301 // }
302 //}
303
304 private class MsbuildMessageListener : IMessageListener 234 private class MsbuildMessageListener : IMessageListener
305 { 235 {
306 public MsbuildMessageListener(TaskLoggingHelper logger, string shortName, string longName) 236 public MsbuildMessageListener(TaskLoggingHelper logger, string shortName, string longName)