main
cs 70 lines 2.45 KB
Raw
1 // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3 namespace WixToolset.BuildTasks
4 {
5 using Microsoft.Build.Framework;
6 using WixToolset.BaseBuildTasks;
7
8 /// <summary>
9 /// An MSBuild task to run WiX to reattach a (signed) bundle engine to its bundle.
10 /// </summary>
11 public sealed partial class ReattachSignedBundleEngine : WixExeBaseTask
12 {
13 /// <summary>
14 /// The bundle to which to attach the bundle engine.
15 /// </summary>
16 [Required]
17 public ITaskItem BundleFile { get; set; }
18
19 /// <summary>
20 /// The bundle engine file to reattach to the bundle.
21 /// </summary>
22 [Required]
23 public ITaskItem BundleEngineFile { get; set; }
24
25 /// <summary>
26 /// Gets or sets the intermedidate folder to use.
27 /// </summary>
28 public ITaskItem IntermediateDirectory { get; set; }
29
30 /// <summary>
31 /// Gets or sets the path to the output detached bundle.
32 /// </summary>
33 [Required]
34 public ITaskItem OutputFile { get; set; }
35
36 /// <summary>
37 /// Gets or sets the output. Only set if the task does work.
38 /// </summary>
39 [Output]
40 public ITaskItem Output { get; set; }
41
42 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
43 {
44 commandLineBuilder.AppendTextUnquoted("burn reattach");
45
46 commandLineBuilder.AppendFileNameIfNotNull(this.BundleFile);
47 commandLineBuilder.AppendSwitchIfNotNull("-engine ", this.BundleEngineFile);
48 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
49 commandLineBuilder.AppendSwitchIfNotNull("-intermediatefolder ", this.IntermediateDirectory);
50
51 base.BuildCommandLine(commandLineBuilder);
52 }
53
54 protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands)
55 {
56 var exitCode = base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
57
58 if (exitCode == 0) // successfully did work.
59 {
60 this.Output = this.OutputFile;
61 }
62 else if (exitCode == -1000) // no work done.
63 {
64 exitCode = 0;
65 }
66
67 return exitCode;
68 }
69 }
70 }