| 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 detach bundle engine to be signed. |
| 10 | /// </summary> |
| 11 | public sealed partial class DetachBundleEngineForSigning : WixExeBaseTask |
| 12 | { |
| 13 | /// <summary> |
| 14 | /// The bundle from which to detach the bundle engine. |
| 15 | /// </summary> |
| 16 | [Required] |
| 17 | public ITaskItem BundleFile { get; set; } |
| 18 | |
| 19 | /// <summary> |
| 20 | /// Gets or sets the intermedidate folder to use. |
| 21 | /// </summary> |
| 22 | public ITaskItem IntermediateDirectory { get; set; } |
| 23 | |
| 24 | /// <summary> |
| 25 | /// Gets or sets the path to the output detached bundle. |
| 26 | /// </summary> |
| 27 | [Required] |
| 28 | public ITaskItem OutputFile { get; set; } |
| 29 | |
| 30 | /// <summary> |
| 31 | /// Gets or sets the output. Only set if the task does work. |
| 32 | /// </summary> |
| 33 | [Output] |
| 34 | public ITaskItem Output { get; set; } |
| 35 | |
| 36 | protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder) |
| 37 | { |
| 38 | commandLineBuilder.AppendTextUnquoted("burn detach"); |
| 39 | |
| 40 | commandLineBuilder.AppendFileNameIfNotNull(this.BundleFile); |
| 41 | commandLineBuilder.AppendSwitchIfNotNull("-engine ", this.OutputFile); |
| 42 | commandLineBuilder.AppendSwitchIfNotNull("-intermediatefolder ", this.IntermediateDirectory); |
| 43 | |
| 44 | base.BuildCommandLine(commandLineBuilder); |
| 45 | } |
| 46 | |
| 47 | protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands) |
| 48 | { |
| 49 | var exitCode = base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands); |
| 50 | |
| 51 | if (exitCode == 0) // successfully did work. |
| 52 | { |
| 53 | this.Output = this.OutputFile; |
| 54 | } |
| 55 | else if (exitCode == -1000) // no work done. |
| 56 | { |
| 57 | exitCode = 0; |
| 58 | } |
| 59 | |
| 60 | return exitCode; |
| 61 | } |
| 62 | } |
| 63 | } |