diff options
Diffstat (limited to 'src/WixToolset.BuildTasks/DoIt-Compile.cs')
-rw-r--r-- | src/WixToolset.BuildTasks/DoIt-Compile.cs | 192 |
1 files changed, 0 insertions, 192 deletions
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 | ||
4 | namespace 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 | ||