aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2018-08-01 03:14:38 -0700
committerRob Mensching <rob@firegiant.com>2018-08-01 03:14:38 -0700
commitc7d69b36789b6403f5b02a975afad80f6b23b48b (patch)
tree6ef69db059c0c7f0ffc4c9b41f59759581360bfe
parent63ebed98f610c9f6ae722d6a12678593c262ba3e (diff)
downloadwix-c7d69b36789b6403f5b02a975afad80f6b23b48b.tar.gz
wix-c7d69b36789b6403f5b02a975afad80f6b23b48b.tar.bz2
wix-c7d69b36789b6403f5b02a975afad80f6b23b48b.zip
Refactor and remove code from WixToolset.BuildTask
-rw-r--r--src/WixToolset.BuildTasks/Candle.cs199
-rw-r--r--src/WixToolset.BuildTasks/CreateItemAvoidingInference.cs32
-rw-r--r--src/WixToolset.BuildTasks/DoIt-Compile.cs192
-rw-r--r--src/WixToolset.BuildTasks/FileSearchHelperMethods.cs4
-rw-r--r--src/WixToolset.BuildTasks/HeatDirectory.cs2
-rw-r--r--src/WixToolset.BuildTasks/HeatFile.cs2
-rw-r--r--src/WixToolset.BuildTasks/HeatProject.cs2
-rw-r--r--src/WixToolset.BuildTasks/HeatTask.cs2
-rw-r--r--src/WixToolset.BuildTasks/Insignia.cs2
-rw-r--r--src/WixToolset.BuildTasks/Light.cs488
-rw-r--r--src/WixToolset.BuildTasks/Lit.cs178
-rw-r--r--src/WixToolset.BuildTasks/Pyro.cs140
-rw-r--r--src/WixToolset.BuildTasks/ReplaceString.cs54
-rw-r--r--src/WixToolset.BuildTasks/TaskBase.cs65
-rw-r--r--src/WixToolset.BuildTasks/Torch.cs159
-rw-r--r--src/WixToolset.BuildTasks/WixToolTask.cs403
-rw-r--r--src/WixToolset.BuildTasks/wix.targets61
17 files changed, 19 insertions, 1966 deletions
diff --git a/src/WixToolset.BuildTasks/Candle.cs b/src/WixToolset.BuildTasks/Candle.cs
deleted file mode 100644
index 82b15838..00000000
--- a/src/WixToolset.BuildTasks/Candle.cs
+++ /dev/null
@@ -1,199 +0,0 @@
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
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics;
8 using System.Globalization;
9 using System.IO;
10 using System.Text;
11
12 using Microsoft.Build.Framework;
13 using Microsoft.Build.Utilities;
14
15 /// <summary>
16 /// An MSBuild task to run the WiX compiler.
17 /// </summary>
18 public sealed class CandleOld : WixToolTask
19 {
20 private const string CandleToolName = "candle.exe";
21
22 private string[] defineConstants;
23 private ITaskItem[] extensions;
24 private string[] includeSearchPaths;
25 private ITaskItem outputFile;
26 private bool pedantic;
27 private string installerPlatform;
28 private string preprocessToFile;
29 private bool preprocessToStdOut;
30 private ITaskItem[] sourceFiles;
31 private string extensionDirectory;
32 private string[] referencePaths;
33
34 public string[] DefineConstants
35 {
36 get { return this.defineConstants; }
37 set { this.defineConstants = value; }
38 }
39
40 public ITaskItem[] Extensions
41 {
42 get { return this.extensions; }
43 set { this.extensions = value; }
44 }
45
46 public string[] IncludeSearchPaths
47 {
48 get { return this.includeSearchPaths; }
49 set { this.includeSearchPaths = value; }
50 }
51
52 public string InstallerPlatform
53 {
54 get { return this.installerPlatform; }
55 set { this.installerPlatform = value; }
56 }
57
58 [Output]
59 [Required]
60 public ITaskItem OutputFile
61 {
62 get { return this.outputFile; }
63 set { this.outputFile = value; }
64 }
65
66 public bool Pedantic
67 {
68 get { return this.pedantic; }
69 set { this.pedantic = value; }
70 }
71
72 public string PreprocessToFile
73 {
74 get { return this.preprocessToFile; }
75 set { this.preprocessToFile = value; }
76 }
77
78 public bool PreprocessToStdOut
79 {
80 get { return this.preprocessToStdOut; }
81 set { this.preprocessToStdOut = value; }
82 }
83
84 [Required]
85 public ITaskItem[] SourceFiles
86 {
87 get { return this.sourceFiles; }
88 set { this.sourceFiles = value; }
89 }
90
91 public string ExtensionDirectory
92 {
93 get { return this.extensionDirectory; }
94 set { this.extensionDirectory = value; }
95 }
96
97 public string[] ReferencePaths
98 {
99 get { return this.referencePaths; }
100 set { this.referencePaths = value; }
101 }
102
103 /// <summary>
104 /// Get the name of the executable.
105 /// </summary>
106 /// <remarks>The ToolName is used with the ToolPath to get the location of candle.exe.</remarks>
107 /// <value>The name of the executable.</value>
108 protected override string ToolName
109 {
110 get { return CandleToolName; }
111 }
112
113 /// <summary>
114 /// Get the path to the executable.
115 /// </summary>
116 /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
117 /// <returns>The full path to the executable or simply candle.exe if it's expected to be in the system path.</returns>
118 protected override string GenerateFullPathToTool()
119 {
120 // If there's not a ToolPath specified, it has to be in the system path.
121 if (String.IsNullOrEmpty(this.ToolPath))
122 {
123 return CandleToolName;
124 }
125
126 return Path.Combine(Path.GetFullPath(this.ToolPath), CandleToolName);
127 }
128
129 /// <summary>
130 /// Builds a command line from options in this task.
131 /// </summary>
132 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
133 {
134 base.BuildCommandLine(commandLineBuilder);
135
136 commandLineBuilder.AppendIfTrue("-p", this.PreprocessToStdOut);
137 commandLineBuilder.AppendSwitchIfNotNull("-p", this.PreprocessToFile);
138 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
139 commandLineBuilder.AppendArrayIfNotNull("-d", this.DefineConstants);
140 commandLineBuilder.AppendArrayIfNotNull("-I", this.IncludeSearchPaths);
141 commandLineBuilder.AppendIfTrue("-pedantic", this.Pedantic);
142 commandLineBuilder.AppendSwitchIfNotNull("-arch ", this.InstallerPlatform);
143 commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.referencePaths);
144 commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
145
146 // Support per-source-file output by looking at the SourceFiles items to
147 // see if there is any "CandleOutput" metadata. If there is, we do our own
148 // appending, otherwise we fall back to the built-in "append file names" code.
149 // Note also that the wix.targets "Compile" target does *not* automagically
150 // fix the "@(CompileObjOutput)" list to include these new output names.
151 // If you really want to use this, you're going to have to clone the target
152 // in your own .targets file and create the output list yourself.
153 bool usePerSourceOutput = false;
154 if (this.SourceFiles != null)
155 {
156 foreach (ITaskItem item in this.SourceFiles)
157 {
158 if (!String.IsNullOrEmpty(item.GetMetadata("CandleOutput")))
159 {
160 usePerSourceOutput = true;
161 break;
162 }
163 }
164 }
165
166 if (usePerSourceOutput)
167 {
168 string[] newSourceNames = new string[this.SourceFiles.Length];
169 for (int iSource = 0; iSource < this.SourceFiles.Length; ++iSource)
170 {
171 ITaskItem item = this.SourceFiles[iSource];
172 if (null == item)
173 {
174 newSourceNames[iSource] = null;
175 }
176 else
177 {
178 string output = item.GetMetadata("CandleOutput");
179
180 if (!String.IsNullOrEmpty(output))
181 {
182 newSourceNames[iSource] = String.Concat(item.ItemSpec, ";", output);
183 }
184 else
185 {
186 newSourceNames[iSource] = item.ItemSpec;
187 }
188 }
189 }
190
191 commandLineBuilder.AppendFileNamesIfNotNull(newSourceNames, " ");
192 }
193 else
194 {
195 commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " ");
196 }
197 }
198 }
199}
diff --git a/src/WixToolset.BuildTasks/CreateItemAvoidingInference.cs b/src/WixToolset.BuildTasks/CreateItemAvoidingInference.cs
index 84816cac..3441bd85 100644
--- a/src/WixToolset.BuildTasks/CreateItemAvoidingInference.cs
+++ b/src/WixToolset.BuildTasks/CreateItemAvoidingInference.cs
@@ -3,11 +3,7 @@
3namespace WixToolset.BuildTasks 3namespace WixToolset.BuildTasks
4{ 4{
5 using System; 5 using System;
6 using System.Collections;
7 using System.Collections.Generic; 6 using System.Collections.Generic;
8 using System.Globalization;
9 using System.IO;
10 using System.Xml;
11 using Microsoft.Build.Framework; 7 using Microsoft.Build.Framework;
12 using Microsoft.Build.Utilities; 8 using Microsoft.Build.Utilities;
13 9
@@ -17,27 +13,17 @@ namespace WixToolset.BuildTasks
17 /// </summary> 13 /// </summary>
18 public class CreateItemAvoidingInference : Task 14 public class CreateItemAvoidingInference : Task
19 { 15 {
20 private string inputProperties;
21 private ITaskItem[] outputItems;
22
23 /// <summary> 16 /// <summary>
24 /// The output items. 17 /// The properties to converty to items.
25 /// </summary> 18 /// </summary>
26 [Output] 19 [Required]
27 public ITaskItem[] OuputItems 20 public string InputProperties { get; set; }
28 {
29 get { return this.outputItems; }
30 }
31 21
32 /// <summary> 22 /// <summary>
33 /// The properties to converty to items. 23 /// The output items.
34 /// </summary> 24 /// </summary>
35 [Required] 25 [Output]
36 public string InputProperties 26 public ITaskItem[] OuputItems { get; private set; }
37 {
38 get { return this.inputProperties; }
39 set { this.inputProperties = value; }
40 }
41 27
42 /// <summary> 28 /// <summary>
43 /// Gets a complete list of external cabs referenced by the given installer database file. 29 /// Gets a complete list of external cabs referenced by the given installer database file.
@@ -45,14 +31,14 @@ namespace WixToolset.BuildTasks
45 /// <returns>True upon completion of the task execution.</returns> 31 /// <returns>True upon completion of the task execution.</returns>
46 public override bool Execute() 32 public override bool Execute()
47 { 33 {
48 List<ITaskItem> newItems = new List<ITaskItem>(); 34 var newItems = new List<ITaskItem>();
49 35
50 foreach (string property in this.inputProperties.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) 36 foreach (var property in this.InputProperties.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
51 { 37 {
52 newItems.Add(new TaskItem(property)); 38 newItems.Add(new TaskItem(property));
53 } 39 }
54 40
55 this.outputItems = newItems.ToArray(); 41 this.OuputItems = newItems.ToArray();
56 42
57 return true; 43 return true;
58 } 44 }
diff --git a/src/WixToolset.BuildTasks/DoIt-Compile.cs b/src/WixToolset.BuildTasks/DoIt-Compile.cs
deleted file mode 100644
index f89078fe..00000000
--- a/src/WixToolset.BuildTasks/DoIt-Compile.cs
+++ /dev/null
@@ -1,192 +0,0 @@
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#if false
4namespace WixToolset.BuildTasks
5{
6 using System;
7 using System.Collections.Generic;
8 using System.IO;
9 using Microsoft.Build.Framework;
10 using WixToolset.Data;
11
12 /// <summary>
13 /// An MSBuild task to run the WiX compiler.
14 /// </summary>
15 public sealed class Candle : TaskBase
16 {
17 public string[] DefineConstants { get; set; }
18
19 public ITaskItem[] Extensions { get; set; }
20
21 public string[] IncludeSearchPaths { get; set; }
22
23 public string InstallerPlatform { get; set; }
24
25 [Output]
26 [Required]
27 public ITaskItem OutputFile { get; set; }
28
29 public bool Pedantic { get; set; }
30
31 public string PreprocessToFile { get; set; }
32
33 public bool PreprocessToStdOut { get; set; }
34
35 [Required]
36 public ITaskItem IntermediateDirectory { get; set; }
37
38 [Required]
39 public ITaskItem[] SourceFiles { get; set; }
40
41 public string ExtensionDirectory { get; set; }
42
43 public string[] ReferencePaths { get; set; }
44
45 protected override void ExecuteCore()
46 {
47 Messaging.Instance.InitializeAppName("WIX", "wix.exe");
48
49 Messaging.Instance.Display += this.DisplayMessage;
50
51 var preprocessor = new Preprocessor();
52
53 var compiler = new Compiler();
54
55 var sourceFiles = this.GatherSourceFiles();
56
57 var preprocessorVariables = this.GatherPreprocessorVariables();
58
59 foreach (var sourceFile in sourceFiles)
60 {
61 var document = preprocessor.Process(sourceFile.SourcePath, preprocessorVariables);
62
63 var intermediate = compiler.Compile(document);
64
65 intermediate.Save(sourceFile.OutputPath);
66 }
67 }
68
69 private void DisplayMessage(object sender, DisplayEventArgs e)
70 {
71 this.Log.LogMessageFromText(e.Message, MessageImportance.Normal);
72 }
73
74 private IEnumerable<SourceFile> GatherSourceFiles()
75 {
76 var files = new List<SourceFile>();
77
78 foreach (var item in this.SourceFiles)
79 {
80 var sourcePath = item.ItemSpec;
81 var outputPath = item.GetMetadata("CandleOutput") ?? this.OutputFile?.ItemSpec;
82
83 if (String.IsNullOrEmpty(outputPath))
84 {
85 outputPath = Path.Combine(this.IntermediateDirectory.ItemSpec, Path.GetFileNameWithoutExtension(sourcePath) + ".wir");
86 }
87
88 files.Add(new SourceFile(sourcePath, outputPath));
89 }
90
91 return files;
92 }
93
94 private IDictionary<string, string> GatherPreprocessorVariables()
95 {
96 var variables = new Dictionary<string, string>();
97
98 foreach (var pair in this.DefineConstants)
99 {
100 string[] value = pair.Split(new[] { '=' }, 2);
101
102 if (variables.ContainsKey(value[0]))
103 {
104 //Messaging.Instance.OnMessage(WixErrors.DuplicateVariableDefinition(value[0], (1 == value.Length) ? String.Empty : value[1], this.PreprocessorVariables[value[0]]));
105 break;
106 }
107
108 if (1 == value.Length)
109 {
110 variables.Add(value[0], String.Empty);
111 }
112 else
113 {
114 variables.Add(value[0], value[1]);
115 }
116 }
117
118 return variables;
119 }
120
121 ///// <summary>
122 ///// Builds a command line from options in this task.
123 ///// </summary>
124 //protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
125 //{
126 // base.BuildCommandLine(commandLineBuilder);
127
128 // commandLineBuilder.AppendIfTrue("-p", this.PreprocessToStdOut);
129 // commandLineBuilder.AppendSwitchIfNotNull("-p", this.PreprocessToFile);
130 // commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
131 // commandLineBuilder.AppendArrayIfNotNull("-d", this.DefineConstants);
132 // commandLineBuilder.AppendArrayIfNotNull("-I", this.IncludeSearchPaths);
133 // commandLineBuilder.AppendIfTrue("-pedantic", this.Pedantic);
134 // commandLineBuilder.AppendSwitchIfNotNull("-arch ", this.InstallerPlatform);
135 // commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.referencePaths);
136 // commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
137
138 // // Support per-source-file output by looking at the SourceFiles items to
139 // // see if there is any "CandleOutput" metadata. If there is, we do our own
140 // // appending, otherwise we fall back to the built-in "append file names" code.
141 // // Note also that the wix.targets "Compile" target does *not* automagically
142 // // fix the "@(CompileObjOutput)" list to include these new output names.
143 // // If you really want to use this, you're going to have to clone the target
144 // // in your own .targets file and create the output list yourself.
145 // bool usePerSourceOutput = false;
146 // if (this.SourceFiles != null)
147 // {
148 // foreach (ITaskItem item in this.SourceFiles)
149 // {
150 // if (!String.IsNullOrEmpty(item.GetMetadata("CandleOutput")))
151 // {
152 // usePerSourceOutput = true;
153 // break;
154 // }
155 // }
156 // }
157
158 // if (usePerSourceOutput)
159 // {
160 // string[] newSourceNames = new string[this.SourceFiles.Length];
161 // for (int iSource = 0; iSource < this.SourceFiles.Length; ++iSource)
162 // {
163 // ITaskItem item = this.SourceFiles[iSource];
164 // if (null == item)
165 // {
166 // newSourceNames[iSource] = null;
167 // }
168 // else
169 // {
170 // string output = item.GetMetadata("CandleOutput");
171
172 // if (!String.IsNullOrEmpty(output))
173 // {
174 // newSourceNames[iSource] = String.Concat(item.ItemSpec, ";", output);
175 // }
176 // else
177 // {
178 // newSourceNames[iSource] = item.ItemSpec;
179 // }
180 // }
181 // }
182
183 // commandLineBuilder.AppendFileNamesIfNotNull(newSourceNames, " ");
184 // }
185 // else
186 // {
187 // commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " ");
188 // }
189 //}
190 }
191}
192#endif
diff --git a/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs b/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs
index 6cc804eb..397c9d7c 100644
--- a/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs
+++ b/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs
@@ -3,11 +3,7 @@
3namespace WixToolset.BuildTasks 3namespace WixToolset.BuildTasks
4{ 4{
5 using System; 5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics.CodeAnalysis;
8 using System.IO; 6 using System.IO;
9 using System.Text;
10 using Microsoft.Build.Framework;
11 7
12 /// <summary> 8 /// <summary>
13 /// Contains helper methods on searching for files 9 /// Contains helper methods on searching for files
diff --git a/src/WixToolset.BuildTasks/HeatDirectory.cs b/src/WixToolset.BuildTasks/HeatDirectory.cs
index 1d5f104a..112418e7 100644
--- a/src/WixToolset.BuildTasks/HeatDirectory.cs
+++ b/src/WixToolset.BuildTasks/HeatDirectory.cs
@@ -4,6 +4,7 @@ namespace WixToolset.BuildTasks
4{ 4{
5 using Microsoft.Build.Framework; 5 using Microsoft.Build.Framework;
6 6
7#if false
7 public sealed class HeatDirectory : HeatTask 8 public sealed class HeatDirectory : HeatTask
8 { 9 {
9 private string directory; 10 private string directory;
@@ -100,4 +101,5 @@ namespace WixToolset.BuildTasks
100 return commandLineBuilder.ToString(); 101 return commandLineBuilder.ToString();
101 } 102 }
102 } 103 }
104#endif
103} 105}
diff --git a/src/WixToolset.BuildTasks/HeatFile.cs b/src/WixToolset.BuildTasks/HeatFile.cs
index 69e11b88..e21d61f5 100644
--- a/src/WixToolset.BuildTasks/HeatFile.cs
+++ b/src/WixToolset.BuildTasks/HeatFile.cs
@@ -4,6 +4,7 @@ namespace WixToolset.BuildTasks
4{ 4{
5 using Microsoft.Build.Framework; 5 using Microsoft.Build.Framework;
6 6
7#if false
7 public sealed class HeatFile : HeatTask 8 public sealed class HeatFile : HeatTask
8 { 9 {
9 private string file; 10 private string file;
@@ -92,4 +93,5 @@ namespace WixToolset.BuildTasks
92 return commandLineBuilder.ToString(); 93 return commandLineBuilder.ToString();
93 } 94 }
94 } 95 }
96#endif
95} 97}
diff --git a/src/WixToolset.BuildTasks/HeatProject.cs b/src/WixToolset.BuildTasks/HeatProject.cs
index 8620ffa3..c8f56688 100644
--- a/src/WixToolset.BuildTasks/HeatProject.cs
+++ b/src/WixToolset.BuildTasks/HeatProject.cs
@@ -4,6 +4,7 @@ namespace WixToolset.BuildTasks
4{ 4{
5 using Microsoft.Build.Framework; 5 using Microsoft.Build.Framework;
6 6
7#if false
7 public sealed class HeatProject : HeatTask 8 public sealed class HeatProject : HeatTask
8 { 9 {
9 private string configuration; 10 private string configuration;
@@ -105,4 +106,5 @@ namespace WixToolset.BuildTasks
105 return commandLineBuilder.ToString(); 106 return commandLineBuilder.ToString();
106 } 107 }
107 } 108 }
109#endif
108} 110}
diff --git a/src/WixToolset.BuildTasks/HeatTask.cs b/src/WixToolset.BuildTasks/HeatTask.cs
index bf0a2ad3..8b12c48c 100644
--- a/src/WixToolset.BuildTasks/HeatTask.cs
+++ b/src/WixToolset.BuildTasks/HeatTask.cs
@@ -11,6 +11,7 @@ namespace WixToolset.BuildTasks
11 using Microsoft.Build.Framework; 11 using Microsoft.Build.Framework;
12 using Microsoft.Build.Utilities; 12 using Microsoft.Build.Utilities;
13 13
14#if false
14 /// <summary> 15 /// <summary>
15 /// A base MSBuild task to run the WiX harvester. 16 /// A base MSBuild task to run the WiX harvester.
16 /// Specific harvester tasks should extend this class. 17 /// Specific harvester tasks should extend this class.
@@ -118,4 +119,5 @@ namespace WixToolset.BuildTasks
118 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile); 119 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
119 } 120 }
120 } 121 }
122#endif
121} 123}
diff --git a/src/WixToolset.BuildTasks/Insignia.cs b/src/WixToolset.BuildTasks/Insignia.cs
index ba30963a..d89770db 100644
--- a/src/WixToolset.BuildTasks/Insignia.cs
+++ b/src/WixToolset.BuildTasks/Insignia.cs
@@ -11,6 +11,7 @@ namespace WixToolset.BuildTasks
11 using Microsoft.Build.Framework; 11 using Microsoft.Build.Framework;
12 using Microsoft.Build.Utilities; 12 using Microsoft.Build.Utilities;
13 13
14#if false
14 /// <summary> 15 /// <summary>
15 /// An MSBuild task to run the WiX transform generator. 16 /// An MSBuild task to run the WiX transform generator.
16 /// </summary> 17 /// </summary>
@@ -115,4 +116,5 @@ namespace WixToolset.BuildTasks
115 return returnCode; 116 return returnCode;
116 } 117 }
117 } 118 }
119#endif
118} 120}
diff --git a/src/WixToolset.BuildTasks/Light.cs b/src/WixToolset.BuildTasks/Light.cs
deleted file mode 100644
index b7d0b4f7..00000000
--- a/src/WixToolset.BuildTasks/Light.cs
+++ /dev/null
@@ -1,488 +0,0 @@
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
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics;
8 using System.Diagnostics.CodeAnalysis;
9 using System.Globalization;
10 using System.IO;
11 using System.Text;
12
13 using Microsoft.Build.Framework;
14 using Microsoft.Build.Utilities;
15
16 /// <summary>
17 /// An MSBuild task to run the WiX linker.
18 /// </summary>
19 public sealed class Light : WixToolTask
20 {
21 private const string LightToolName = "Light.exe";
22
23 private string additionalCub;
24 private bool allowIdenticalRows;
25 private bool allowUnresolvedReferences;
26 private string[] baseInputPaths;
27 private ITaskItem[] bindInputPaths;
28 private bool backwardsCompatibleGuidGeneration;
29 private bool bindFiles;
30 private ITaskItem builtOutputsFile;
31 private string cabinetCachePath;
32 private int cabinetCreationThreadCount = WixCommandLineBuilder.Unspecified;
33 private ITaskItem contentsFile;
34 private string cultures;
35 private string customBinder;
36 private string defaultCompressionLevel;
37 private ITaskItem[] extensions;
38 private string[] ices;
39 private bool leaveTemporaryFiles;
40 private ITaskItem[] localizationFiles;
41 private ITaskItem[] objectFiles;
42 private bool outputAsXml;
43 private ITaskItem outputsFile;
44 private ITaskItem outputFile;
45 private ITaskItem pdbOutputFile;
46 private ITaskItem wixProjectFile;
47 private bool pedantic;
48 private bool reuseCabinetCache;
49 private bool suppressAclReset;
50 private bool suppressAssemblies;
51 private bool suppressDefaultAdminSequenceActions;
52 private bool suppressDefaultAdvSequenceActions;
53 private bool suppressDefaultUISequenceActions;
54 private bool dropUnrealTables;
55 private bool exactAssemblyVersions;
56 private bool suppressFileHashAndInfo;
57 private bool suppressFiles;
58 private bool suppressIntermediateFileVersionMatching;
59 private string[] suppressIces;
60 private bool suppressLayout;
61 private bool suppressLocalization;
62 private bool suppressMsiAssemblyTableProcessing;
63 private bool suppressPdbOutput;
64 private bool suppressSchemaValidation;
65 private bool suppressValidation;
66 private bool suppressTagSectionIdAttributeOnTuples;
67 private ITaskItem unreferencedSymbolsFile;
68 private string[] wixVariables;
69 private string extensionDirectory;
70 private string[] referencePaths;
71
72 /// <summary>
73 /// Creates a new light task.
74 /// </summary>
75 /// <remarks>
76 /// Defaults to running the task as a separate process, instead of in-proc
77 /// which is the default for WixToolTasks. This allows the Win32 manifest file
78 /// embedded in light.exe to enable reg-free COM interop with mergemod.dll.
79 /// </remarks>
80 public Light()
81 {
82 }
83
84 public string AdditionalCub
85 {
86 get { return this.additionalCub; }
87 set { this.additionalCub = value; }
88 }
89
90 public bool AllowIdenticalRows
91 {
92 get { return this.allowIdenticalRows; }
93 set { this.allowIdenticalRows = value; }
94 }
95
96 public bool AllowUnresolvedReferences
97 {
98 get { return this.allowUnresolvedReferences; }
99 set { this.allowUnresolvedReferences = value; }
100 }
101
102 // TODO: remove this property entirely in v4.0
103 [Obsolete("Use BindInputPaths instead of BaseInputPaths.")]
104 public string[] BaseInputPaths
105 {
106 get { return this.baseInputPaths; }
107 set { this.baseInputPaths = value; }
108 }
109
110 public ITaskItem[] BindInputPaths
111 {
112 get { return this.bindInputPaths; }
113 set { this.bindInputPaths = value; }
114 }
115
116 public bool BackwardsCompatibleGuidGeneration
117 {
118 get { return this.backwardsCompatibleGuidGeneration; }
119 set { this.backwardsCompatibleGuidGeneration = value; }
120 }
121
122 public bool BindFiles
123 {
124 get { return this.bindFiles; }
125 set { this.bindFiles = value; }
126 }
127
128 public string CabinetCachePath
129 {
130 get { return this.cabinetCachePath; }
131 set { this.cabinetCachePath = value; }
132 }
133
134 public int CabinetCreationThreadCount
135 {
136 get { return this.cabinetCreationThreadCount; }
137 set { this.cabinetCreationThreadCount = value; }
138 }
139
140 public ITaskItem BindBuiltOutputsFile
141 {
142 get { return this.builtOutputsFile; }
143 set { this.builtOutputsFile = value; }
144 }
145
146 public ITaskItem BindContentsFile
147 {
148 get { return this.contentsFile; }
149 set { this.contentsFile = value; }
150 }
151
152 public ITaskItem BindOutputsFile
153 {
154 get { return this.outputsFile; }
155 set { this.outputsFile = value; }
156 }
157
158 public string Cultures
159 {
160 get { return this.cultures; }
161 set { this.cultures = value; }
162 }
163
164 public string CustomBinder
165 {
166 get { return this.customBinder; }
167 set { this.customBinder = value; }
168 }
169
170 public string DefaultCompressionLevel
171 {
172 get { return this.defaultCompressionLevel; }
173 set { this.defaultCompressionLevel = value; }
174 }
175
176 public bool DropUnrealTables
177 {
178 get { return this.dropUnrealTables; }
179 set { this.dropUnrealTables = value; }
180 }
181
182 public bool ExactAssemblyVersions
183 {
184 get { return this.exactAssemblyVersions; }
185 set { this.exactAssemblyVersions = value; }
186 }
187
188 public ITaskItem[] Extensions
189 {
190 get { return this.extensions; }
191 set { this.extensions = value; }
192 }
193
194 public string[] Ices
195 {
196 get { return this.ices; }
197 set { this.ices = value; }
198 }
199
200 public bool LeaveTemporaryFiles
201 {
202 get { return this.leaveTemporaryFiles; }
203 set { this.leaveTemporaryFiles = value; }
204 }
205
206 public ITaskItem[] LocalizationFiles
207 {
208 get { return this.localizationFiles; }
209 set { this.localizationFiles = value; }
210 }
211
212 [Required]
213 public ITaskItem[] ObjectFiles
214 {
215 get { return this.objectFiles; }
216 set { this.objectFiles = value; }
217 }
218
219 public bool OutputAsXml
220 {
221 get { return this.outputAsXml; }
222 set { this.outputAsXml = value; }
223 }
224
225 [Required]
226 [Output]
227 public ITaskItem OutputFile
228 {
229 get { return this.outputFile; }
230 set { this.outputFile = value; }
231 }
232
233 [Output]
234 public ITaskItem PdbOutputFile
235 {
236 get { return this.pdbOutputFile; }
237 set { this.pdbOutputFile = value; }
238 }
239
240 public bool Pedantic
241 {
242 get { return this.pedantic; }
243 set { this.pedantic = value; }
244 }
245
246 public bool ReuseCabinetCache
247 {
248 get { return this.reuseCabinetCache; }
249 set { this.reuseCabinetCache = value; }
250 }
251
252 public bool SuppressAclReset
253 {
254 get { return this.suppressAclReset; }
255 set { this.suppressAclReset = value; }
256 }
257
258 public bool SuppressAssemblies
259 {
260 get { return this.suppressAssemblies; }
261 set { this.suppressAssemblies = value; }
262 }
263
264 public bool SuppressDefaultAdminSequenceActions
265 {
266 get { return this.suppressDefaultAdminSequenceActions; }
267 set { this.suppressDefaultAdminSequenceActions = value; }
268 }
269
270 public bool SuppressDefaultAdvSequenceActions
271 {
272 get { return this.suppressDefaultAdvSequenceActions; }
273 set { this.suppressDefaultAdvSequenceActions = value; }
274 }
275
276 public bool SuppressDefaultUISequenceActions
277 {
278 get { return this.suppressDefaultUISequenceActions; }
279 set { this.suppressDefaultUISequenceActions = value; }
280 }
281
282 public bool SuppressFileHashAndInfo
283 {
284 get { return this.suppressFileHashAndInfo; }
285 set { this.suppressFileHashAndInfo = value; }
286 }
287
288 public bool SuppressFiles
289 {
290 get { return this.suppressFiles; }
291 set { this.suppressFiles = value; }
292 }
293
294 public bool SuppressIntermediateFileVersionMatching
295 {
296 get { return this.suppressIntermediateFileVersionMatching; }
297 set { this.suppressIntermediateFileVersionMatching = value; }
298 }
299
300 public string[] SuppressIces
301 {
302 get { return this.suppressIces; }
303 set { this.suppressIces = value; }
304 }
305
306 public bool SuppressLayout
307 {
308 get { return this.suppressLayout; }
309 set { this.suppressLayout = value; }
310 }
311
312 public bool SuppressLocalization
313 {
314 get { return this.suppressLocalization; }
315 set { this.suppressLocalization = value; }
316 }
317
318 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
319 public bool SuppressMsiAssemblyTableProcessing
320 {
321 get { return this.suppressMsiAssemblyTableProcessing; }
322 set { this.suppressMsiAssemblyTableProcessing = value; }
323 }
324
325 public bool SuppressPdbOutput
326 {
327 get { return this.suppressPdbOutput; }
328 set { this.suppressPdbOutput = value; }
329 }
330
331 public bool SuppressSchemaValidation
332 {
333 get { return this.suppressSchemaValidation; }
334 set { this.suppressSchemaValidation = value; }
335 }
336
337 public bool SuppressValidation
338 {
339 get { return this.suppressValidation; }
340 set { this.suppressValidation = value; }
341 }
342
343 public bool SuppressTagSectionIdAttributeOnTuples
344 {
345 get { return this.suppressTagSectionIdAttributeOnTuples; }
346 set { this.suppressTagSectionIdAttributeOnTuples = value; }
347 }
348
349 [Output]
350 public ITaskItem UnreferencedSymbolsFile
351 {
352 get { return this.unreferencedSymbolsFile; }
353 set { this.unreferencedSymbolsFile = value; }
354 }
355
356 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
357 public ITaskItem WixProjectFile
358 {
359 get { return this.wixProjectFile; }
360 set { this.wixProjectFile = value; }
361 }
362
363 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
364 public string[] WixVariables
365 {
366 get { return this.wixVariables; }
367 set { this.wixVariables = value; }
368 }
369
370 public string ExtensionDirectory
371 {
372 get { return this.extensionDirectory; }
373 set { this.extensionDirectory = value; }
374 }
375
376 public string[] ReferencePaths
377 {
378 get { return this.referencePaths; }
379 set { this.referencePaths = value; }
380 }
381
382 /// <summary>
383 /// Get the name of the executable.
384 /// </summary>
385 /// <remarks>The ToolName is used with the ToolPath to get the location of light.exe.</remarks>
386 /// <value>The name of the executable.</value>
387 protected override string ToolName
388 {
389 get { return LightToolName; }
390 }
391
392 /// <summary>
393 /// Get the path to the executable.
394 /// </summary>
395 /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
396 /// <returns>The full path to the executable or simply light.exe if it's expected to be in the system path.</returns>
397 protected override string GenerateFullPathToTool()
398 {
399 // If there's not a ToolPath specified, it has to be in the system path.
400 if (String.IsNullOrEmpty(this.ToolPath))
401 {
402 return LightToolName;
403 }
404
405 return Path.Combine(Path.GetFullPath(this.ToolPath), LightToolName);
406 }
407
408 /// <summary>
409 /// Builds a command line from options in this task.
410 /// </summary>
411 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
412 {
413 // Always put the output first so it is easy to find in the log.
414 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
415 commandLineBuilder.AppendSwitchIfNotNull("-pdbout ", this.PdbOutputFile);
416
417 base.BuildCommandLine(commandLineBuilder);
418
419 commandLineBuilder.AppendIfTrue("-ai", this.AllowIdenticalRows);
420 commandLineBuilder.AppendIfTrue("-au", this.AllowUnresolvedReferences);
421 commandLineBuilder.AppendArrayIfNotNull("-b ", this.baseInputPaths);
422
423 if (null != this.BindInputPaths)
424 {
425 Queue<String> formattedBindInputPaths = new Queue<String>();
426 foreach (ITaskItem item in this.BindInputPaths)
427 {
428 String formattedPath = string.Empty;
429 String bindName = item.GetMetadata("BindName");
430 if (!String.IsNullOrEmpty(bindName))
431 {
432 formattedPath = String.Concat(bindName, "=", item.GetMetadata("FullPath"));
433 }
434 else
435 {
436 formattedPath = item.GetMetadata("FullPath");
437 }
438 formattedBindInputPaths.Enqueue(formattedPath);
439 }
440 commandLineBuilder.AppendArrayIfNotNull("-b ", formattedBindInputPaths.ToArray());
441 }
442
443 commandLineBuilder.AppendIfTrue("-bcgg", this.BackwardsCompatibleGuidGeneration);
444 commandLineBuilder.AppendIfTrue("-bf", this.BindFiles);
445 commandLineBuilder.AppendSwitchIfNotNull("-cc ", this.CabinetCachePath);
446 commandLineBuilder.AppendIfSpecified("-ct ", this.CabinetCreationThreadCount);
447 commandLineBuilder.AppendSwitchIfNotNull("-cub ", this.AdditionalCub);
448 commandLineBuilder.AppendSwitchIfNotNull("-cultures:", this.Cultures);
449 commandLineBuilder.AppendSwitchIfNotNull("-binder ", this.CustomBinder);
450 commandLineBuilder.AppendArrayIfNotNull("-d", this.WixVariables);
451 commandLineBuilder.AppendSwitchIfNotNull("-dcl:", this.DefaultCompressionLevel);
452 commandLineBuilder.AppendIfTrue("-dut", this.DropUnrealTables);
453 commandLineBuilder.AppendIfTrue("-eav", this.ExactAssemblyVersions);
454 commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.referencePaths);
455 commandLineBuilder.AppendArrayIfNotNull("-ice:", this.Ices);
456 commandLineBuilder.AppendArrayIfNotNull("-loc ", this.LocalizationFiles);
457 commandLineBuilder.AppendIfTrue("-notidy", this.LeaveTemporaryFiles);
458 commandLineBuilder.AppendIfTrue("-pedantic", this.Pedantic);
459 commandLineBuilder.AppendIfTrue("-reusecab", this.ReuseCabinetCache);
460 commandLineBuilder.AppendIfTrue("-sa", this.SuppressAssemblies);
461 commandLineBuilder.AppendIfTrue("-sacl", this.SuppressAclReset);
462 commandLineBuilder.AppendIfTrue("-sadmin", this.SuppressDefaultAdminSequenceActions);
463 commandLineBuilder.AppendIfTrue("-sadv", this.SuppressDefaultAdvSequenceActions);
464 commandLineBuilder.AppendArrayIfNotNull("-sice:", this.SuppressIces);
465 commandLineBuilder.AppendIfTrue("-sma", this.SuppressMsiAssemblyTableProcessing);
466 commandLineBuilder.AppendIfTrue("-sf", this.SuppressFiles);
467 commandLineBuilder.AppendIfTrue("-sh", this.SuppressFileHashAndInfo);
468 commandLineBuilder.AppendIfTrue("-sl", this.SuppressLayout);
469 commandLineBuilder.AppendIfTrue("-sloc", this.SuppressLocalization);
470 commandLineBuilder.AppendIfTrue("-spdb", this.SuppressPdbOutput);
471 commandLineBuilder.AppendIfTrue("-ss", this.SuppressSchemaValidation);
472 commandLineBuilder.AppendIfTrue("-sts", this.SuppressTagSectionIdAttributeOnTuples);
473 commandLineBuilder.AppendIfTrue("-sui", this.SuppressDefaultUISequenceActions);
474 commandLineBuilder.AppendIfTrue("-sv", this.SuppressIntermediateFileVersionMatching);
475 commandLineBuilder.AppendIfTrue("-sval", this.SuppressValidation);
476 commandLineBuilder.AppendSwitchIfNotNull("-usf ", this.UnreferencedSymbolsFile);
477 commandLineBuilder.AppendIfTrue("-xo", this.OutputAsXml);
478 commandLineBuilder.AppendSwitchIfNotNull("-contentsfile ", this.BindContentsFile);
479 commandLineBuilder.AppendSwitchIfNotNull("-outputsfile ", this.BindOutputsFile);
480 commandLineBuilder.AppendSwitchIfNotNull("-builtoutputsfile ", this.BindBuiltOutputsFile);
481 commandLineBuilder.AppendSwitchIfNotNull("-wixprojectfile ", this.WixProjectFile);
482 commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
483
484 List<string> objectFilePaths = AdjustFilePaths(this.objectFiles, this.ReferencePaths);
485 commandLineBuilder.AppendFileNamesIfNotNull(objectFilePaths.ToArray(), " ");
486 }
487 }
488}
diff --git a/src/WixToolset.BuildTasks/Lit.cs b/src/WixToolset.BuildTasks/Lit.cs
deleted file mode 100644
index 1df964ae..00000000
--- a/src/WixToolset.BuildTasks/Lit.cs
+++ /dev/null
@@ -1,178 +0,0 @@
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
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics;
8 using System.Globalization;
9 using System.IO;
10 using System.Text;
11
12 using Microsoft.Build.Framework;
13 using Microsoft.Build.Utilities;
14
15 /// <summary>
16 /// An MSBuild task to run the WiX lib tool.
17 /// </summary>
18 public sealed class Lit : WixToolTask
19 {
20 private const string LitToolName = "lit.exe";
21
22 private string[] baseInputPaths;
23 private ITaskItem[] bindInputPaths;
24 private bool bindFiles;
25 private ITaskItem[] extensions;
26 private ITaskItem[] localizationFiles;
27 private ITaskItem[] objectFiles;
28 private ITaskItem outputFile;
29 private bool pedantic;
30 private bool suppressIntermediateFileVersionMatching;
31 private bool suppressSchemaValidation;
32 private string extensionDirectory;
33 private string[] referencePaths;
34
35 // TODO: remove this property entirely in v4.0
36 [Obsolete("Use BindInputPaths instead of BaseInputPaths.")]
37 public string[] BaseInputPaths
38 {
39 get { return this.baseInputPaths; }
40 set { this.baseInputPaths = value; }
41 }
42
43 public ITaskItem[] BindInputPaths
44 {
45 get { return this.bindInputPaths; }
46 set { this.bindInputPaths = value; }
47 }
48
49 public bool BindFiles
50 {
51 get { return this.bindFiles; }
52 set { this.bindFiles = value; }
53 }
54
55 public ITaskItem[] Extensions
56 {
57 get { return this.extensions; }
58 set { this.extensions = value; }
59 }
60
61 public ITaskItem[] LocalizationFiles
62 {
63 get { return this.localizationFiles; }
64 set { this.localizationFiles = value; }
65 }
66
67 [Required]
68 public ITaskItem[] ObjectFiles
69 {
70 get { return this.objectFiles; }
71 set { this.objectFiles = value; }
72 }
73
74 [Required]
75 [Output]
76 public ITaskItem OutputFile
77 {
78 get { return this.outputFile; }
79 set { this.outputFile = value; }
80 }
81
82 public bool Pedantic
83 {
84 get { return this.pedantic; }
85 set { this.pedantic = value; }
86 }
87
88 public bool SuppressIntermediateFileVersionMatching
89 {
90 get { return this.suppressIntermediateFileVersionMatching; }
91 set { this.suppressIntermediateFileVersionMatching = value; }
92 }
93
94 public bool SuppressSchemaValidation
95 {
96 get { return this.suppressSchemaValidation; }
97 set { this.suppressSchemaValidation = value; }
98 }
99
100 public string ExtensionDirectory
101 {
102 get { return this.extensionDirectory; }
103 set { this.extensionDirectory = value; }
104 }
105
106 public string[] ReferencePaths
107 {
108 get { return this.referencePaths; }
109 set { this.referencePaths = value; }
110 }
111
112 /// <summary>
113 /// Get the name of the executable.
114 /// </summary>
115 /// <remarks>The ToolName is used with the ToolPath to get the location of lit.exe</remarks>
116 /// <value>The name of the executable.</value>
117 protected override string ToolName
118 {
119 get { return LitToolName; }
120 }
121
122 /// <summary>
123 /// Get the path to the executable.
124 /// </summary>
125 /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
126 /// <returns>The full path to the executable or simply lit.exe if it's expected to be in the system path.</returns>
127 protected override string GenerateFullPathToTool()
128 {
129 // If there's not a ToolPath specified, it has to be in the system path.
130 if (String.IsNullOrEmpty(this.ToolPath))
131 {
132 return LitToolName;
133 }
134
135 return Path.Combine(Path.GetFullPath(this.ToolPath), LitToolName);
136 }
137
138 /// <summary>
139 /// Builds a command line from options in this task.
140 /// </summary>
141 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
142 {
143 base.BuildCommandLine(commandLineBuilder);
144
145 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
146 commandLineBuilder.AppendArrayIfNotNull("-b ", this.baseInputPaths);
147 if (null != this.BindInputPaths)
148 {
149 Queue<String> formattedBindInputPaths = new Queue<String>();
150 foreach (ITaskItem item in this.BindInputPaths)
151 {
152 String formattedPath = string.Empty;
153 String bindName = item.GetMetadata("BindName");
154 if (!String.IsNullOrEmpty(item.GetMetadata("BindName")))
155 {
156 formattedPath = String.Concat(bindName, "=", item.GetMetadata("FullPath"));
157 }
158 else
159 {
160 formattedPath = item.GetMetadata("FullPath");
161 }
162 formattedBindInputPaths.Enqueue(formattedPath);
163 }
164 commandLineBuilder.AppendArrayIfNotNull("-b ", formattedBindInputPaths.ToArray());
165 }
166 commandLineBuilder.AppendIfTrue("-bf", this.BindFiles);
167 commandLineBuilder.AppendExtensions(this.extensions, this.ExtensionDirectory, this.referencePaths);
168 commandLineBuilder.AppendArrayIfNotNull("-loc ", this.LocalizationFiles);
169 commandLineBuilder.AppendIfTrue("-pedantic", this.Pedantic);
170 commandLineBuilder.AppendIfTrue("-ss", this.SuppressSchemaValidation);
171 commandLineBuilder.AppendIfTrue("-sv", this.SuppressIntermediateFileVersionMatching);
172 commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
173
174 List<string> objectFilePaths = AdjustFilePaths(this.objectFiles, this.ReferencePaths);
175 commandLineBuilder.AppendFileNamesIfNotNull(objectFilePaths.ToArray(), " ");
176 }
177 }
178}
diff --git a/src/WixToolset.BuildTasks/Pyro.cs b/src/WixToolset.BuildTasks/Pyro.cs
deleted file mode 100644
index f6b069da..00000000
--- a/src/WixToolset.BuildTasks/Pyro.cs
+++ /dev/null
@@ -1,140 +0,0 @@
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
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.IO;
8 using Microsoft.Build.Framework;
9
10 /// <summary>
11 /// An MSBuild task to run the WiX patch builder.
12 /// </summary>
13 public sealed class Pyro : WixToolTask
14 {
15 private const string PyroToolName = "pyro.exe";
16
17 public bool BinaryDeltaPatch { get; set; }
18 public string CabinetCachePath { get; set; }
19 public string ExtensionDirectory { get; set; }
20 public ITaskItem[] Extensions { get; set; }
21 public bool LeaveTemporaryFiles { get; set; }
22 public string[] ReferencePaths { get; set; }
23 public bool ReuseCabinetCache { get; set; }
24 public bool SuppressAssemblies { get; set; }
25 public bool SuppressFiles { get; set; }
26 public bool SuppressFileHashAndInfo { get; set; }
27 public bool SuppressPdbOutput { get; set; }
28
29 [Required]
30 public string DefaultBaselineId { get; set; }
31
32 public ITaskItem[] BindInputPathsForTarget { get; set; }
33 public ITaskItem[] BindInputPathsForUpdated { get; set; }
34
35 [Required]
36 public ITaskItem InputFile { get; set; }
37
38 [Required]
39 [Output]
40 public ITaskItem OutputFile { get; set; }
41
42 [Output]
43 public ITaskItem PdbOutputFile { get; set; }
44
45 [Required]
46 public ITaskItem[] Transforms { get; set; }
47
48 /// <summary>
49 /// Get the name of the executable.
50 /// </summary>
51 /// <remarks>The ToolName is used with the ToolPath to get the location of pyro.exe.</remarks>
52 /// <value>The name of the executable.</value>
53 protected override string ToolName
54 {
55 get { return PyroToolName; }
56 }
57
58 /// <summary>
59 /// Get the path to the executable.
60 /// </summary>
61 /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
62 /// <returns>The full path to the executable or simply torch.exe if it's expected to be in the system path.</returns>
63 protected override string GenerateFullPathToTool()
64 {
65 // If there's not a ToolPath specified, it has to be in the system path.
66 if (String.IsNullOrEmpty(this.ToolPath))
67 {
68 return PyroToolName;
69 }
70
71 return Path.Combine(Path.GetFullPath(this.ToolPath), PyroToolName);
72 }
73
74 /// <summary>
75 /// Builds a command line for bind-input paths (-bt and -bu switches).
76 /// </summary>
77 private void AppendBindInputPaths(WixCommandLineBuilder commandLineBuilder, IEnumerable<ITaskItem> bindInputPaths, string switchName)
78 {
79 if (null != bindInputPaths)
80 {
81 Queue<String> formattedBindInputPaths = new Queue<String>();
82 foreach (ITaskItem item in bindInputPaths)
83 {
84 String formattedPath = string.Empty;
85 String bindName = item.GetMetadata("BindName");
86 if (!String.IsNullOrEmpty(bindName))
87 {
88 formattedPath = String.Concat(bindName, "=", item.GetMetadata("FullPath"));
89 }
90 else
91 {
92 formattedPath = item.GetMetadata("FullPath");
93 }
94 formattedBindInputPaths.Enqueue(formattedPath);
95 }
96
97 commandLineBuilder.AppendArrayIfNotNull(switchName, formattedBindInputPaths.ToArray());
98 }
99 }
100
101 /// <summary>
102 /// Builds a command line from options in this task.
103 /// </summary>
104 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
105 {
106 // Always put the output first so it is easy to find in the log.
107 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
108 commandLineBuilder.AppendSwitchIfNotNull("-pdbout ", this.PdbOutputFile);
109
110 base.BuildCommandLine(commandLineBuilder);
111
112 this.AppendBindInputPaths(commandLineBuilder, this.BindInputPathsForTarget, "-bt ");
113 this.AppendBindInputPaths(commandLineBuilder, this.BindInputPathsForUpdated, "-bu ");
114
115 commandLineBuilder.AppendFileNameIfNotNull(this.InputFile);
116 commandLineBuilder.AppendSwitchIfNotNull("-cc ", this.CabinetCachePath);
117 commandLineBuilder.AppendIfTrue("-delta", this.BinaryDeltaPatch);
118 commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.ReferencePaths);
119 commandLineBuilder.AppendIfTrue("-notidy", this.LeaveTemporaryFiles);
120 commandLineBuilder.AppendIfTrue("-reusecab", this.ReuseCabinetCache);
121 commandLineBuilder.AppendIfTrue("-sa", this.SuppressAssemblies);
122 commandLineBuilder.AppendIfTrue("-sf", this.SuppressFiles);
123 commandLineBuilder.AppendIfTrue("-sh", this.SuppressFileHashAndInfo);
124 commandLineBuilder.AppendIfTrue("-spdb", this.SuppressPdbOutput);
125 foreach (ITaskItem transform in this.Transforms)
126 {
127 string transformPath = transform.ItemSpec;
128 string baselineId = transform.GetMetadata("OverrideBaselineId");
129 if (String.IsNullOrEmpty(baselineId))
130 {
131 baselineId = this.DefaultBaselineId;
132 }
133
134 commandLineBuilder.AppendTextIfNotNull(String.Format("-t {0} {1}", baselineId, transformPath));
135 }
136
137 commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
138 }
139 }
140}
diff --git a/src/WixToolset.BuildTasks/ReplaceString.cs b/src/WixToolset.BuildTasks/ReplaceString.cs
deleted file mode 100644
index e5041923..00000000
--- a/src/WixToolset.BuildTasks/ReplaceString.cs
+++ /dev/null
@@ -1,54 +0,0 @@
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
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using Microsoft.Build.Framework;
7 using Microsoft.Build.Utilities;
8
9 /// <summary>
10 /// Replaces occurances of OldValues with NewValues in String.
11 /// </summary>
12 public class ReplaceString : Task
13 {
14 /// <summary>
15 /// Text to operate on.
16 /// </summary>
17 [Output]
18 [Required]
19 public string Text { get; set; }
20
21 /// <summary>
22 /// List of old values to replace.
23 /// </summary>
24 [Required]
25 public string OldValue { get; set; }
26
27 /// <summary>
28 /// List of new values to replace old values with. If not specified, occurances of OldValue will be removed.
29 /// </summary>
30 public string NewValue { get; set; }
31
32 /// <summary>
33 /// Does the string replacement.
34 /// </summary>
35 /// <returns></returns>
36 public override bool Execute()
37 {
38 if (String.IsNullOrEmpty(this.Text))
39 {
40 return true;
41 }
42
43 if (String.IsNullOrEmpty(this.OldValue))
44 {
45 Log.LogError("OldValue must be specified");
46 return false;
47 }
48
49 this.Text = this.Text.Replace(this.OldValue, this.NewValue);
50
51 return true;
52 }
53 }
54}
diff --git a/src/WixToolset.BuildTasks/TaskBase.cs b/src/WixToolset.BuildTasks/TaskBase.cs
deleted file mode 100644
index 3d58fc06..00000000
--- a/src/WixToolset.BuildTasks/TaskBase.cs
+++ /dev/null
@@ -1,65 +0,0 @@
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
3namespace WixToolset.BuildTasks
4{
5 using Microsoft.Build.Utilities;
6
7 public abstract class TaskBase : Task
8 {
9 public string ToolPath { get; set; }
10
11 public string AdditionalOptions { get; set; }
12
13 public bool RunAsSeparateProcess { get; set; }
14
15 /// <summary>
16 /// Gets or sets whether all warnings should be suppressed.
17 /// </summary>
18 public bool SuppressAllWarnings { get; set; }
19
20 /// <summary>
21 /// Gets or sets a list of specific warnings to be suppressed.
22 /// </summary>
23 public string[] SuppressSpecificWarnings { get; set; }
24
25 /// <summary>
26 /// Gets or sets whether all warnings should be treated as errors.
27 /// </summary>
28 public bool TreatWarningsAsErrors { get; set; }
29
30 /// <summary>
31 /// Gets or sets a list of specific warnings to treat as errors.
32 /// </summary>
33 public string[] TreatSpecificWarningsAsErrors { get; set; }
34
35 /// <summary>
36 /// Gets or sets whether to display verbose output.
37 /// </summary>
38 public bool VerboseOutput { get; set; }
39
40 /// <summary>
41 /// Gets or sets whether to display the logo.
42 /// </summary>
43 public bool NoLogo { get; set; }
44
45 public override bool Execute()
46 {
47 try
48 {
49 this.ExecuteCore();
50 }
51 catch (BuildException e)
52 {
53 this.Log.LogErrorFromException(e);
54 }
55 catch (Data.WixException e)
56 {
57 this.Log.LogErrorFromException(e);
58 }
59
60 return !this.Log.HasLoggedErrors;
61 }
62
63 protected abstract void ExecuteCore();
64 }
65}
diff --git a/src/WixToolset.BuildTasks/Torch.cs b/src/WixToolset.BuildTasks/Torch.cs
deleted file mode 100644
index e18ed315..00000000
--- a/src/WixToolset.BuildTasks/Torch.cs
+++ /dev/null
@@ -1,159 +0,0 @@
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
3namespace 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}
diff --git a/src/WixToolset.BuildTasks/WixToolTask.cs b/src/WixToolset.BuildTasks/WixToolTask.cs
deleted file mode 100644
index 60305e00..00000000
--- a/src/WixToolset.BuildTasks/WixToolTask.cs
+++ /dev/null
@@ -1,403 +0,0 @@
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
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics.CodeAnalysis;
8 using System.Globalization;
9 using System.IO;
10 using System.Reflection;
11 using System.Text;
12 using System.Threading;
13
14 using Microsoft.Build.Framework;
15 using Microsoft.Build.Utilities;
16 using WixToolset.Core.CommandLine;
17
18 /// <summary>
19 /// Base class for WiX tool tasks; executes tools in-process
20 /// so that repeated invocations are much faster.
21 /// </summary>
22 public abstract class WixToolTask : ToolTask, IDisposable
23 {
24 private string additionalOptions;
25 private bool disposed;
26 private bool noLogo;
27 private bool runAsSeparateProcess;
28 private bool suppressAllWarnings;
29 private string[] suppressSpecificWarnings;
30 private string[] treatSpecificWarningsAsErrors;
31 private bool treatWarningsAsErrors;
32 private bool verboseOutput;
33 private Queue<string> messageQueue;
34 private ManualResetEvent messagesAvailable;
35 private ManualResetEvent toolExited;
36 private int exitCode;
37
38 /// <summary>
39 /// Gets or sets additional options that are appended the the tool command-line.
40 /// </summary>
41 /// <remarks>
42 /// This allows the task to support extended options in the tool which are not
43 /// explicitly implemented as properties on the task.
44 /// </remarks>
45 public string AdditionalOptions
46 {
47 get { return this.additionalOptions; }
48 set { this.additionalOptions = value; }
49 }
50
51 /// <summary>
52 /// Gets or sets a flag indicating whether the task should be run as separate
53 /// process instead of in-proc with MSBuild which is the default.
54 /// </summary>
55 public bool RunAsSeparateProcess
56 {
57 get { return this.runAsSeparateProcess; }
58 set { this.runAsSeparateProcess = value; }
59 }
60
61#region Common Options
62 /// <summary>
63 /// Gets or sets whether all warnings should be suppressed.
64 /// </summary>
65 public bool SuppressAllWarnings
66 {
67 get { return this.suppressAllWarnings; }
68 set { this.suppressAllWarnings = value; }
69 }
70
71 /// <summary>
72 /// Gets or sets a list of specific warnings to be suppressed.
73 /// </summary>
74 public string[] SuppressSpecificWarnings
75 {
76 get { return this.suppressSpecificWarnings; }
77 set { this.suppressSpecificWarnings = value; }
78 }
79
80 /// <summary>
81 /// Gets or sets whether all warnings should be treated as errors.
82 /// </summary>
83 public bool TreatWarningsAsErrors
84 {
85 get { return this.treatWarningsAsErrors; }
86 set { this.treatWarningsAsErrors = value; }
87 }
88
89 /// <summary>
90 /// Gets or sets a list of specific warnings to treat as errors.
91 /// </summary>
92 public string[] TreatSpecificWarningsAsErrors
93 {
94 get { return this.treatSpecificWarningsAsErrors; }
95 set { this.treatSpecificWarningsAsErrors = value; }
96 }
97
98 /// <summary>
99 /// Gets or sets whether to display verbose output.
100 /// </summary>
101 public bool VerboseOutput
102 {
103 get { return this.verboseOutput; }
104 set { this.verboseOutput = value; }
105 }
106
107 /// <summary>
108 /// Gets or sets whether to display the logo.
109 /// </summary>
110 public bool NoLogo
111 {
112 get { return this.noLogo; }
113 set { this.noLogo = value; }
114 }
115#endregion
116
117 /// <summary>
118 /// Cleans up the ManualResetEvent members
119 /// </summary>
120 public void Dispose()
121 {
122 if (!this.disposed)
123 {
124 this.Dispose(true);
125 GC.SuppressFinalize(this);
126 disposed = true;
127 }
128 }
129
130 /// <summary>
131 /// Cleans up the ManualResetEvent members
132 /// </summary>
133 protected virtual void Dispose(bool disposing)
134 {
135 if (disposing)
136 {
137 messagesAvailable.Close();
138 toolExited.Close();
139 }
140 }
141
142 /// <summary>
143 /// Generate the command line arguments to write to the response file from the properties.
144 /// </summary>
145 /// <returns>Command line string.</returns>
146 protected override string GenerateResponseFileCommands()
147 {
148 WixCommandLineBuilder commandLineBuilder = new WixCommandLineBuilder();
149 this.BuildCommandLine(commandLineBuilder);
150 return commandLineBuilder.ToString();
151 }
152
153 /// <summary>
154 /// Builds a command line from options in this and derivative tasks.
155 /// </summary>
156 /// <remarks>
157 /// Derivative classes should call BuildCommandLine() on the base class to ensure that common command line options are added to the command.
158 /// </remarks>
159 protected virtual void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
160 {
161 commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo);
162 commandLineBuilder.AppendArrayIfNotNull("-sw", this.SuppressSpecificWarnings);
163 commandLineBuilder.AppendIfTrue("-sw", this.SuppressAllWarnings);
164 commandLineBuilder.AppendIfTrue("-v", this.VerboseOutput);
165 commandLineBuilder.AppendArrayIfNotNull("-wx", this.TreatSpecificWarningsAsErrors);
166 commandLineBuilder.AppendIfTrue("-wx", this.TreatWarningsAsErrors);
167 }
168
169 /// <summary>
170 /// Executes a tool in-process by loading the tool assembly and invoking its entrypoint.
171 /// </summary>
172 /// <param name="pathToTool">Path to the tool to be executed; must be a managed executable.</param>
173 /// <param name="responseFileCommands">Commands to be written to a response file.</param>
174 /// <param name="commandLineCommands">Commands to be passed directly on the command-line.</param>
175 /// <returns>The tool exit code.</returns>
176 protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands)
177 {
178 if (this.RunAsSeparateProcess)
179 {
180 return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
181 }
182
183 this.messageQueue = new Queue<string>();
184 this.messagesAvailable = new ManualResetEvent(false);
185 this.toolExited = new ManualResetEvent(false);
186
187 WixToolTaskLogger logger = new WixToolTaskLogger(this.messageQueue, this.messagesAvailable);
188 TextWriter saveConsoleOut = Console.Out;
189 TextWriter saveConsoleError = Console.Error;
190 Console.SetOut(logger);
191 Console.SetError(logger);
192
193 string responseFile = null;
194 try
195 {
196 responseFile = this.GetTemporaryResponseFile(responseFileCommands, out var responseFileSwitch);
197 if (!String.IsNullOrEmpty(responseFileSwitch))
198 {
199 commandLineCommands = commandLineCommands + " " + responseFileSwitch;
200 }
201
202 string[] arguments = CommandLineResponseFile.ParseArgumentsToArray(commandLineCommands);
203
204 Thread toolThread = new Thread(new ParameterizedThreadStart(this.ExecuteToolThread));
205 toolThread.Start(new object[] { pathToTool, arguments });
206
207 this.HandleToolMessages();
208
209 if (this.exitCode == 0 && this.Log.HasLoggedErrors)
210 {
211 this.exitCode = -1;
212 }
213
214 return this.exitCode;
215 }
216 finally
217 {
218 if (responseFile != null)
219 {
220 File.Delete(responseFile);
221 }
222
223 Console.SetOut(saveConsoleOut);
224 Console.SetError(saveConsoleError);
225 }
226 }
227
228 /// <summary>
229 /// Called by a new thread to execute the tool in that thread.
230 /// </summary>
231 /// <param name="parameters">Tool path and arguments array.</param>
232 private void ExecuteToolThread(object parameters)
233 {
234 try
235 {
236 object[] pathAndArguments = (object[])parameters;
237 Assembly toolAssembly = Assembly.LoadFrom((string)pathAndArguments[0]);
238 this.exitCode = (int)toolAssembly.EntryPoint.Invoke(null, new object[] { pathAndArguments[1] });
239 }
240 catch (FileNotFoundException fnfe)
241 {
242 Log.LogError("Unable to load tool from path {0}. Consider setting the ToolPath parameter to $(WixToolPath).", fnfe.FileName);
243 this.exitCode = -1;
244 }
245 catch (Exception ex)
246 {
247 this.exitCode = -1;
248 this.LogEventsFromTextOutput(ex.Message, MessageImportance.High);
249 foreach (string stackTraceLine in ex.StackTrace.Split('\n'))
250 {
251 this.LogEventsFromTextOutput(stackTraceLine.TrimEnd(), MessageImportance.High);
252 }
253
254 throw;
255 }
256 finally
257 {
258 this.toolExited.Set();
259 }
260 }
261
262 /// <summary>
263 /// Waits for messages from the tool thread and sends them to the MSBuild logger on the original thread.
264 /// Returns when the tool thread exits.
265 /// </summary>
266 private void HandleToolMessages()
267 {
268 WaitHandle[] waitHandles = new WaitHandle[] { this.messagesAvailable, this.toolExited };
269 while (WaitHandle.WaitAny(waitHandles) == 0)
270 {
271 lock (this.messageQueue)
272 {
273 while (this.messageQueue.Count > 0)
274 {
275 this.LogEventsFromTextOutput(messageQueue.Dequeue(), MessageImportance.Normal);
276 }
277
278 this.messagesAvailable.Reset();
279 }
280 }
281 }
282
283 /// <summary>
284 /// Creates a temporary response file for tool execution.
285 /// </summary>
286 /// <returns>Path to the response file.</returns>
287 /// <remarks>
288 /// The temporary file should be deleted after the tool execution is finished.
289 /// </remarks>
290 private string GetTemporaryResponseFile(string responseFileCommands, out string responseFileSwitch)
291 {
292 string responseFile = null;
293 responseFileSwitch = null;
294
295 if (!String.IsNullOrEmpty(responseFileCommands))
296 {
297 responseFile = Path.GetTempFileName();
298 using (StreamWriter writer = new StreamWriter(responseFile, false, this.ResponseFileEncoding))
299 {
300 writer.Write(responseFileCommands);
301 }
302 responseFileSwitch = this.GetResponseFileSwitch(responseFile);
303 }
304 return responseFile;
305 }
306
307 /// <summary>
308 /// Cycles thru each task to find correct path of the file in question.
309 /// Looks at item spec, hintpath and then in user defined Reference Paths
310 /// </summary>
311 /// <param name="tasks">Input task array</param>
312 /// <param name="referencePaths">SemiColon delimited directories to search</param>
313 /// <returns>List of task item file paths</returns>
314 [SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
315 protected static List<string> AdjustFilePaths(ITaskItem[] tasks, string[] referencePaths)
316 {
317 List<string> sourceFilePaths = new List<string>();
318
319 if (tasks == null)
320 {
321 return sourceFilePaths;
322 }
323
324 foreach (ITaskItem task in tasks)
325 {
326 string filePath = task.ItemSpec;
327 if (!File.Exists(filePath))
328 {
329 filePath = task.GetMetadata("HintPath");
330 if (!File.Exists(filePath))
331 {
332 string searchPath = FileSearchHelperMethods.SearchFilePaths(referencePaths, filePath);
333 if (!String.IsNullOrEmpty(searchPath))
334 {
335 filePath = searchPath;
336 }
337 }
338 }
339 sourceFilePaths.Add(filePath);
340 }
341
342 return sourceFilePaths;
343 }
344
345 /// <summary>
346 /// Used as a replacement for Console.Out to capture output from a tool
347 /// and redirect it to the MSBuild logging system.
348 /// </summary>
349 private class WixToolTaskLogger : TextWriter
350 {
351 private StringBuilder buffer;
352 private Queue<string> messageQueue;
353 private ManualResetEvent messagesAvailable;
354
355 /// <summary>
356 /// Creates a new logger that sends tool output to the tool task's log handler.
357 /// </summary>
358 public WixToolTaskLogger(Queue<string> messageQueue, ManualResetEvent messagesAvailable) : base(CultureInfo.CurrentCulture)
359 {
360 this.messageQueue = messageQueue;
361 this.messagesAvailable = messagesAvailable;
362 this.buffer = new StringBuilder();
363 }
364
365 /// <summary>
366 /// Gets the encoding of the logger.
367 /// </summary>
368 public override Encoding Encoding
369 {
370 get { return Encoding.Unicode; }
371 }
372
373 /// <summary>
374 /// Redirects output to a buffer; watches for newlines and sends each line to the
375 /// MSBuild logging system.
376 /// </summary>
377 /// <param name="value">Character being written.</param>
378 /// <remarks>All other Write() variants eventually call into this one.</remarks>
379 public override void Write(char value)
380 {
381 lock (this.messageQueue)
382 {
383 if (value == '\n')
384 {
385 if (this.buffer.Length > 0 && this.buffer[this.buffer.Length - 1] == '\r')
386 {
387 this.buffer.Length = this.buffer.Length - 1;
388 }
389
390 this.messageQueue.Enqueue(this.buffer.ToString());
391 this.messagesAvailable.Set();
392
393 this.buffer.Length = 0;
394 }
395 else
396 {
397 this.buffer.Append(value);
398 }
399 }
400 }
401 }
402 }
403}
diff --git a/src/WixToolset.BuildTasks/wix.targets b/src/WixToolset.BuildTasks/wix.targets
index 2edd44c4..ebd3fa90 100644
--- a/src/WixToolset.BuildTasks/wix.targets
+++ b/src/WixToolset.BuildTasks/wix.targets
@@ -103,11 +103,7 @@
103 --> 103 -->
104 104
105 <!-- These tasks can be used as general-purpose build tasks. --> 105 <!-- These tasks can be used as general-purpose build tasks. -->
106 <UsingTask TaskName="Candle" AssemblyFile="$(WixTasksPath)" />
107 <UsingTask TaskName="DoIt" AssemblyFile="$(WixTasksPath)" /> 106 <UsingTask TaskName="DoIt" AssemblyFile="$(WixTasksPath)" />
108 <UsingTask TaskName="Lit" AssemblyFile="$(WixTasksPath)" />
109 <UsingTask TaskName="Light" AssemblyFile="$(WixTasksPath)" />
110 <UsingTask TaskName="Torch" AssemblyFile="$(WixTasksPath)" />
111 107
112 <!-- These tasks are specific to the build process defined in this file, and are not considered general-purpose build tasks. --> 108 <!-- These tasks are specific to the build process defined in this file, and are not considered general-purpose build tasks. -->
113 <UsingTask TaskName="CreateItemAvoidingInference" AssemblyFile="$(WixTasksPath)" /> 109 <UsingTask TaskName="CreateItemAvoidingInference" AssemblyFile="$(WixTasksPath)" />
@@ -784,63 +780,6 @@
784 780
785 <!-- 781 <!--
786 ================================================================================================ 782 ================================================================================================
787 Lib
788
789 Links the .wixobj, .wxl, .wixlib, wix extensions into a .wixlib file using lit.exe.
790
791 [IN]
792 @(CompileObjOutput) - The compiled .wixobj file.
793 @(EmbeddedResource) - The list of wxl files to use for localization.
794 @(WixObject) - The list of .wixobj files.
795 @(WixLibrary) - The list of .wixlib files.
796 @(WixExtension) - The list of wix dll extension files.
797
798 [OUT]
799 $(TargetPath) - The compiled .wixlib file.
800 ================================================================================================
801 -->
802 <PropertyGroup>
803 <LibDependsOn>
804 PrepareForBuild;
805 ResolveReferences
806 </LibDependsOn>
807 </PropertyGroup>
808 <Target
809 Name="Lib"
810 Inputs="@(CompileObjOutput);
811 @(EmbeddedResource);
812 @(WixObject);
813 @(WixLibrary);
814 @(_ResolvedWixExtensionPaths);
815 $(MSBuildAllProjects)"
816 Outputs="$(TargetPath)"
817 DependsOnTargets="$(LibDependsOn)"
818 Condition=" '$(OutputType)' == 'Library' ">
819
820 <Lit
821 ObjectFiles="@(CompileObjOutput);@(WixObject);@(WixLibProjects);@(WixLibrary)"
822 AdditionalOptions="$(LibAdditionalOptions)"
823 BindInputPaths="@(LinkerBindInputPaths)"
824 BindFiles="$(LibBindFiles)"
825 ExtensionDirectory="$(WixExtDir)"
826 Extensions="@(_ResolvedWixExtensionPaths)"
827 LocalizationFiles="@(EmbeddedResource)"
828 NoLogo="$(LibNoLogo)"
829 OutputFile="$(TargetPath)"
830 Pedantic="$(LibPedantic)"
831 ReferencePaths="$(ReferencePaths)"
832 RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
833 SuppressAllWarnings="$(LibSuppressAllWarnings)"
834 SuppressIntermediateFileVersionMatching="$(LibSuppressIntermediateFileVersionMatching)"
835 SuppressSchemaValidation="$(LibSuppressSchemaValidation)"
836 SuppressSpecificWarnings="$(LibSuppressSpecificWarnings)"
837 ToolPath="$(WixToolDir)"
838 TreatWarningsAsErrors="$(LibTreatWarningsAsErrors)"
839 VerboseOutput="$(LibVerboseOutput)" />
840 </Target>
841
842 <!--
843 ================================================================================================
844 AssignCultures 783 AssignCultures
845 784
846 Determines the final list of culture groups to build based on either the Cultures property or 785 Determines the final list of culture groups to build based on either the Cultures property or