diff options
Diffstat (limited to 'src/WixToolset.BuildTasks/Torch.cs')
| -rw-r--r-- | src/WixToolset.BuildTasks/Torch.cs | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/src/WixToolset.BuildTasks/Torch.cs b/src/WixToolset.BuildTasks/Torch.cs new file mode 100644 index 00000000..e18ed315 --- /dev/null +++ b/src/WixToolset.BuildTasks/Torch.cs | |||
| @@ -0,0 +1,159 @@ | |||
| 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 System; | ||
| 6 | using System.Diagnostics; | ||
| 7 | using System.Globalization; | ||
| 8 | using System.IO; | ||
| 9 | using System.Text; | ||
| 10 | |||
| 11 | using Microsoft.Build.Framework; | ||
| 12 | using Microsoft.Build.Utilities; | ||
| 13 | |||
| 14 | /// <summary> | ||
| 15 | /// An MSBuild task to run the WiX transform generator. | ||
| 16 | /// </summary> | ||
| 17 | public sealed class Torch : WixToolTask | ||
| 18 | { | ||
| 19 | private const string TorchToolName = "Torch.exe"; | ||
| 20 | |||
| 21 | private bool adminImage; | ||
| 22 | private ITaskItem baselineFile; | ||
| 23 | private string binaryExtractionPath; | ||
| 24 | private bool inputIsXml; | ||
| 25 | private bool leaveTemporaryFiles; | ||
| 26 | private bool outputAsXml; | ||
| 27 | private ITaskItem outputFile; | ||
| 28 | private bool preserveUnmodifiedContent; | ||
| 29 | private string suppressTransformErrorFlags; | ||
| 30 | private string transformValidationFlags; | ||
| 31 | private string transformValidationType; | ||
| 32 | private ITaskItem updateFile; | ||
| 33 | |||
| 34 | public bool AdminImage | ||
| 35 | { | ||
| 36 | get { return this.adminImage; } | ||
| 37 | set { this.adminImage = value; } | ||
| 38 | } | ||
| 39 | |||
| 40 | |||
| 41 | [Required] | ||
| 42 | public ITaskItem BaselineFile | ||
| 43 | { | ||
| 44 | get { return this.baselineFile; } | ||
| 45 | set { this.baselineFile = value; } | ||
| 46 | } | ||
| 47 | |||
| 48 | public string BinaryExtractionPath | ||
| 49 | { | ||
| 50 | get { return this.binaryExtractionPath; } | ||
| 51 | set { this.binaryExtractionPath = value; } | ||
| 52 | } | ||
| 53 | |||
| 54 | public bool LeaveTemporaryFiles | ||
| 55 | { | ||
| 56 | get { return this.leaveTemporaryFiles; } | ||
| 57 | set { this.leaveTemporaryFiles = value; } | ||
| 58 | } | ||
| 59 | |||
| 60 | public bool InputIsXml | ||
| 61 | { | ||
| 62 | get { return this.inputIsXml; } | ||
| 63 | set { this.inputIsXml = value; } | ||
| 64 | } | ||
| 65 | |||
| 66 | public bool OutputAsXml | ||
| 67 | { | ||
| 68 | get { return this.outputAsXml; } | ||
| 69 | set { this.outputAsXml = value; } | ||
| 70 | } | ||
| 71 | |||
| 72 | public bool PreserveUnmodifiedContent | ||
| 73 | { | ||
| 74 | get { return this.preserveUnmodifiedContent; } | ||
| 75 | set { this.preserveUnmodifiedContent = value; } | ||
| 76 | } | ||
| 77 | |||
| 78 | [Required] | ||
| 79 | [Output] | ||
| 80 | public ITaskItem OutputFile | ||
| 81 | { | ||
| 82 | get { return this.outputFile; } | ||
| 83 | set { this.outputFile = value; } | ||
| 84 | } | ||
| 85 | |||
| 86 | public string SuppressTransformErrorFlags | ||
| 87 | { | ||
| 88 | get { return this.suppressTransformErrorFlags; } | ||
| 89 | set { this.suppressTransformErrorFlags = value; } | ||
| 90 | } | ||
| 91 | |||
| 92 | public string TransformValidationType | ||
| 93 | { | ||
| 94 | get { return this.transformValidationType; } | ||
| 95 | set { this.transformValidationType = value; } | ||
| 96 | } | ||
| 97 | |||
| 98 | public string TransformValidationFlags | ||
| 99 | { | ||
| 100 | get { return this.transformValidationFlags; } | ||
| 101 | set { this.transformValidationFlags = value; } | ||
| 102 | } | ||
| 103 | |||
| 104 | [Required] | ||
| 105 | public ITaskItem UpdateFile | ||
| 106 | { | ||
| 107 | get { return this.updateFile; } | ||
| 108 | set { this.updateFile = value; } | ||
| 109 | } | ||
| 110 | |||
| 111 | /// <summary> | ||
| 112 | /// Get the name of the executable. | ||
| 113 | /// </summary> | ||
| 114 | /// <remarks>The ToolName is used with the ToolPath to get the location of torch.exe.</remarks> | ||
| 115 | /// <value>The name of the executable.</value> | ||
| 116 | protected override string ToolName | ||
| 117 | { | ||
| 118 | get { return TorchToolName; } | ||
| 119 | } | ||
| 120 | |||
| 121 | /// <summary> | ||
| 122 | /// Get the path to the executable. | ||
| 123 | /// </summary> | ||
| 124 | /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks> | ||
| 125 | /// <returns>The full path to the executable or simply torch.exe if it's expected to be in the system path.</returns> | ||
| 126 | protected override string GenerateFullPathToTool() | ||
| 127 | { | ||
| 128 | // If there's not a ToolPath specified, it has to be in the system path. | ||
| 129 | if (String.IsNullOrEmpty(this.ToolPath)) | ||
| 130 | { | ||
| 131 | return TorchToolName; | ||
| 132 | } | ||
| 133 | |||
| 134 | return Path.Combine(Path.GetFullPath(this.ToolPath), TorchToolName); | ||
| 135 | } | ||
| 136 | |||
| 137 | /// <summary> | ||
| 138 | /// Builds a command line from options in this task. | ||
| 139 | /// </summary> | ||
| 140 | protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder) | ||
| 141 | { | ||
| 142 | base.BuildCommandLine(commandLineBuilder); | ||
| 143 | |||
| 144 | commandLineBuilder.AppendIfTrue("-notidy", this.LeaveTemporaryFiles); | ||
| 145 | commandLineBuilder.AppendIfTrue("-xo", this.OutputAsXml); | ||
| 146 | commandLineBuilder.AppendIfTrue("-xi", this.InputIsXml); | ||
| 147 | commandLineBuilder.AppendIfTrue("-p", this.PreserveUnmodifiedContent); | ||
| 148 | commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions); | ||
| 149 | commandLineBuilder.AppendFileNameIfNotNull(this.BaselineFile); | ||
| 150 | commandLineBuilder.AppendFileNameIfNotNull(this.UpdateFile); | ||
| 151 | commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile); | ||
| 152 | commandLineBuilder.AppendIfTrue("-a", this.adminImage); | ||
| 153 | commandLineBuilder.AppendSwitchIfNotNull("-x ", this.BinaryExtractionPath); | ||
| 154 | commandLineBuilder.AppendSwitchIfNotNull("-serr ", this.SuppressTransformErrorFlags); | ||
| 155 | commandLineBuilder.AppendSwitchIfNotNull("-t ", this.TransformValidationType); | ||
| 156 | commandLineBuilder.AppendSwitchIfNotNull("-val ", this.TransformValidationFlags); | ||
| 157 | } | ||
| 158 | } | ||
| 159 | } | ||
