1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
// 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.
namespace WixToolset.BuildTasks
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
/// <summary>
/// An MSBuild task to run the WiX lib tool.
/// </summary>
public sealed class Lit : WixToolTask
{
private const string LitToolName = "lit.exe";
private string[] baseInputPaths;
private ITaskItem[] bindInputPaths;
private bool bindFiles;
private ITaskItem[] extensions;
private ITaskItem[] localizationFiles;
private ITaskItem[] objectFiles;
private ITaskItem outputFile;
private bool pedantic;
private bool suppressIntermediateFileVersionMatching;
private bool suppressSchemaValidation;
private string extensionDirectory;
private string[] referencePaths;
// TODO: remove this property entirely in v4.0
[Obsolete("Use BindInputPaths instead of BaseInputPaths.")]
public string[] BaseInputPaths
{
get { return this.baseInputPaths; }
set { this.baseInputPaths = value; }
}
public ITaskItem[] BindInputPaths
{
get { return this.bindInputPaths; }
set { this.bindInputPaths = value; }
}
public bool BindFiles
{
get { return this.bindFiles; }
set { this.bindFiles = value; }
}
public ITaskItem[] Extensions
{
get { return this.extensions; }
set { this.extensions = value; }
}
public ITaskItem[] LocalizationFiles
{
get { return this.localizationFiles; }
set { this.localizationFiles = value; }
}
[Required]
public ITaskItem[] ObjectFiles
{
get { return this.objectFiles; }
set { this.objectFiles = value; }
}
[Required]
[Output]
public ITaskItem OutputFile
{
get { return this.outputFile; }
set { this.outputFile = value; }
}
public bool Pedantic
{
get { return this.pedantic; }
set { this.pedantic = value; }
}
public bool SuppressIntermediateFileVersionMatching
{
get { return this.suppressIntermediateFileVersionMatching; }
set { this.suppressIntermediateFileVersionMatching = value; }
}
public bool SuppressSchemaValidation
{
get { return this.suppressSchemaValidation; }
set { this.suppressSchemaValidation = value; }
}
public string ExtensionDirectory
{
get { return this.extensionDirectory; }
set { this.extensionDirectory = value; }
}
public string[] ReferencePaths
{
get { return this.referencePaths; }
set { this.referencePaths = value; }
}
/// <summary>
/// Get the name of the executable.
/// </summary>
/// <remarks>The ToolName is used with the ToolPath to get the location of lit.exe</remarks>
/// <value>The name of the executable.</value>
protected override string ToolName
{
get { return LitToolName; }
}
/// <summary>
/// Get the path to the executable.
/// </summary>
/// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
/// <returns>The full path to the executable or simply lit.exe if it's expected to be in the system path.</returns>
protected override string GenerateFullPathToTool()
{
// If there's not a ToolPath specified, it has to be in the system path.
if (String.IsNullOrEmpty(this.ToolPath))
{
return LitToolName;
}
return Path.Combine(Path.GetFullPath(this.ToolPath), LitToolName);
}
/// <summary>
/// Builds a command line from options in this task.
/// </summary>
protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
{
base.BuildCommandLine(commandLineBuilder);
commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
commandLineBuilder.AppendArrayIfNotNull("-b ", this.baseInputPaths);
if (null != this.BindInputPaths)
{
Queue<String> formattedBindInputPaths = new Queue<String>();
foreach (ITaskItem item in this.BindInputPaths)
{
String formattedPath = string.Empty;
String bindName = item.GetMetadata("BindName");
if (!String.IsNullOrEmpty(item.GetMetadata("BindName")))
{
formattedPath = String.Concat(bindName, "=", item.GetMetadata("FullPath"));
}
else
{
formattedPath = item.GetMetadata("FullPath");
}
formattedBindInputPaths.Enqueue(formattedPath);
}
commandLineBuilder.AppendArrayIfNotNull("-b ", formattedBindInputPaths.ToArray());
}
commandLineBuilder.AppendIfTrue("-bf", this.BindFiles);
commandLineBuilder.AppendExtensions(this.extensions, this.ExtensionDirectory, this.referencePaths);
commandLineBuilder.AppendArrayIfNotNull("-loc ", this.LocalizationFiles);
commandLineBuilder.AppendIfTrue("-pedantic", this.Pedantic);
commandLineBuilder.AppendIfTrue("-ss", this.SuppressSchemaValidation);
commandLineBuilder.AppendIfTrue("-sv", this.SuppressIntermediateFileVersionMatching);
commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
List<string> objectFilePaths = AdjustFilePaths(this.objectFiles, this.ReferencePaths);
commandLineBuilder.AppendFileNamesIfNotNull(objectFilePaths.ToArray(), " ");
}
}
}
|