diff options
Diffstat (limited to 'src/WixToolset.BuildTasks')
38 files changed, 6985 insertions, 0 deletions
diff --git a/src/WixToolset.BuildTasks/AssemblyInfo.cs b/src/WixToolset.BuildTasks/AssemblyInfo.cs new file mode 100644 index 00000000..ae52fce8 --- /dev/null +++ b/src/WixToolset.BuildTasks/AssemblyInfo.cs | |||
@@ -0,0 +1,7 @@ | |||
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 | using System.Reflection; | ||
4 | using System.Runtime.InteropServices; | ||
5 | |||
6 | [assembly: AssemblyCulture("")] | ||
7 | [assembly: ComVisible(false)] | ||
diff --git a/src/WixToolset.BuildTasks/BuildException.cs b/src/WixToolset.BuildTasks/BuildException.cs new file mode 100644 index 00000000..953134ba --- /dev/null +++ b/src/WixToolset.BuildTasks/BuildException.cs | |||
@@ -0,0 +1,26 @@ | |||
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.Globalization; | ||
7 | |||
8 | class BuildException : Exception | ||
9 | { | ||
10 | public BuildException() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | public BuildException(string message) : base(message) | ||
15 | { | ||
16 | } | ||
17 | |||
18 | public BuildException(string message, Exception innerException) : base(message, innerException) | ||
19 | { | ||
20 | } | ||
21 | |||
22 | public BuildException(string format, params string[] args) : this(String.Format(CultureInfo.CurrentCulture, format, args)) | ||
23 | { | ||
24 | } | ||
25 | } | ||
26 | } | ||
diff --git a/src/WixToolset.BuildTasks/Candle.cs b/src/WixToolset.BuildTasks/Candle.cs new file mode 100644 index 00000000..82b15838 --- /dev/null +++ b/src/WixToolset.BuildTasks/Candle.cs | |||
@@ -0,0 +1,199 @@ | |||
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.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/Common.cs b/src/WixToolset.BuildTasks/Common.cs new file mode 100644 index 00000000..803e9d14 --- /dev/null +++ b/src/WixToolset.BuildTasks/Common.cs | |||
@@ -0,0 +1,41 @@ | |||
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 | ||
4 | { | ||
5 | using System; | ||
6 | using System.Globalization; | ||
7 | using System.Text; | ||
8 | using System.Text.RegularExpressions; | ||
9 | |||
10 | /// <summary> | ||
11 | /// Common WixTasks utility methods and types. | ||
12 | /// </summary> | ||
13 | internal static class Common | ||
14 | { | ||
15 | /// <summary>Metadata key name to turn off harvesting of project references.</summary> | ||
16 | public const string DoNotHarvest = "DoNotHarvest"; | ||
17 | |||
18 | private static readonly Regex AddPrefix = new Regex(@"^[^a-zA-Z_]", RegexOptions.Compiled); | ||
19 | private static readonly Regex IllegalIdentifierCharacters = new Regex(@"[^A-Za-z0-9_\.]|\.{2,}", RegexOptions.Compiled); // non 'words' and assorted valid characters | ||
20 | |||
21 | /// <summary> | ||
22 | /// Return an identifier based on passed file/directory name | ||
23 | /// </summary> | ||
24 | /// <param name="name">File/directory name to generate identifer from</param> | ||
25 | /// <returns>A version of the name that is a legal identifier.</returns> | ||
26 | /// <remarks>This is duplicated from WiX's Common class.</remarks> | ||
27 | internal static string GetIdentifierFromName(string name) | ||
28 | { | ||
29 | string result = IllegalIdentifierCharacters.Replace(name, "_"); // replace illegal characters with "_". | ||
30 | |||
31 | // MSI identifiers must begin with an alphabetic character or an | ||
32 | // underscore. Prefix all other values with an underscore. | ||
33 | if (AddPrefix.IsMatch(name)) | ||
34 | { | ||
35 | result = String.Concat("_", result); | ||
36 | } | ||
37 | |||
38 | return result; | ||
39 | } | ||
40 | } | ||
41 | } | ||
diff --git a/src/WixToolset.BuildTasks/ConvertReferences.cs b/src/WixToolset.BuildTasks/ConvertReferences.cs new file mode 100644 index 00000000..fe137633 --- /dev/null +++ b/src/WixToolset.BuildTasks/ConvertReferences.cs | |||
@@ -0,0 +1,93 @@ | |||
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.Collections; | ||
7 | using System.Collections.Generic; | ||
8 | using System.Globalization; | ||
9 | using System.IO; | ||
10 | using System.Xml; | ||
11 | using Microsoft.Build.Framework; | ||
12 | using Microsoft.Build.Utilities; | ||
13 | |||
14 | /// <summary> | ||
15 | /// This task assigns Culture metadata to files based on the value of the Culture attribute on the | ||
16 | /// WixLocalization element inside the file. | ||
17 | /// </summary> | ||
18 | public class ConvertReferences : Task | ||
19 | { | ||
20 | private string projectOutputGroups; | ||
21 | private ITaskItem[] projectReferences; | ||
22 | private ITaskItem[] harvestItems; | ||
23 | |||
24 | /// <summary> | ||
25 | /// The total list of cabs in this database | ||
26 | /// </summary> | ||
27 | [Output] | ||
28 | public ITaskItem[] HarvestItems | ||
29 | { | ||
30 | get { return this.harvestItems; } | ||
31 | } | ||
32 | |||
33 | /// <summary> | ||
34 | /// The project output groups to harvest. | ||
35 | /// </summary> | ||
36 | [Required] | ||
37 | public string ProjectOutputGroups | ||
38 | { | ||
39 | get { return this.projectOutputGroups; } | ||
40 | set { this.projectOutputGroups = value; } | ||
41 | } | ||
42 | |||
43 | /// <summary> | ||
44 | /// All the project references in the project. | ||
45 | /// </summary> | ||
46 | [Required] | ||
47 | public ITaskItem[] ProjectReferences | ||
48 | { | ||
49 | get { return this.projectReferences; } | ||
50 | set { this.projectReferences = value; } | ||
51 | } | ||
52 | |||
53 | /// <summary> | ||
54 | /// Gets a complete list of external cabs referenced by the given installer database file. | ||
55 | /// </summary> | ||
56 | /// <returns>True upon completion of the task execution.</returns> | ||
57 | public override bool Execute() | ||
58 | { | ||
59 | List<ITaskItem> newItems = new List<ITaskItem>(); | ||
60 | |||
61 | foreach(ITaskItem item in this.ProjectReferences) | ||
62 | { | ||
63 | Dictionary<string, string> newItemMetadeta = new Dictionary<string, string>(); | ||
64 | |||
65 | if (!String.IsNullOrEmpty(item.GetMetadata(Common.DoNotHarvest))) | ||
66 | { | ||
67 | continue; | ||
68 | } | ||
69 | |||
70 | string refTargetDir = item.GetMetadata("RefTargetDir"); | ||
71 | if (!String.IsNullOrEmpty(refTargetDir)) | ||
72 | { | ||
73 | newItemMetadeta.Add("DirectoryIds", refTargetDir); | ||
74 | } | ||
75 | |||
76 | string refName = item.GetMetadata("Name"); | ||
77 | if (!String.IsNullOrEmpty(refName)) | ||
78 | { | ||
79 | newItemMetadeta.Add("ProjectName", refName); | ||
80 | } | ||
81 | |||
82 | newItemMetadeta.Add("ProjectOutputGroups", this.ProjectOutputGroups); | ||
83 | |||
84 | ITaskItem newItem = new TaskItem(item.ItemSpec, newItemMetadeta); | ||
85 | newItems.Add(newItem); | ||
86 | } | ||
87 | |||
88 | this.harvestItems = newItems.ToArray(); | ||
89 | |||
90 | return true; | ||
91 | } | ||
92 | } | ||
93 | } | ||
diff --git a/src/WixToolset.BuildTasks/CreateItemAvoidingInference.cs b/src/WixToolset.BuildTasks/CreateItemAvoidingInference.cs new file mode 100644 index 00000000..84816cac --- /dev/null +++ b/src/WixToolset.BuildTasks/CreateItemAvoidingInference.cs | |||
@@ -0,0 +1,60 @@ | |||
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.Collections; | ||
7 | using System.Collections.Generic; | ||
8 | using System.Globalization; | ||
9 | using System.IO; | ||
10 | using System.Xml; | ||
11 | using Microsoft.Build.Framework; | ||
12 | using Microsoft.Build.Utilities; | ||
13 | |||
14 | /// <summary> | ||
15 | /// This task assigns Culture metadata to files based on the value of the Culture attribute on the | ||
16 | /// WixLocalization element inside the file. | ||
17 | /// </summary> | ||
18 | public class CreateItemAvoidingInference : Task | ||
19 | { | ||
20 | private string inputProperties; | ||
21 | private ITaskItem[] outputItems; | ||
22 | |||
23 | /// <summary> | ||
24 | /// The output items. | ||
25 | /// </summary> | ||
26 | [Output] | ||
27 | public ITaskItem[] OuputItems | ||
28 | { | ||
29 | get { return this.outputItems; } | ||
30 | } | ||
31 | |||
32 | /// <summary> | ||
33 | /// The properties to converty to items. | ||
34 | /// </summary> | ||
35 | [Required] | ||
36 | public string InputProperties | ||
37 | { | ||
38 | get { return this.inputProperties; } | ||
39 | set { this.inputProperties = value; } | ||
40 | } | ||
41 | |||
42 | /// <summary> | ||
43 | /// Gets a complete list of external cabs referenced by the given installer database file. | ||
44 | /// </summary> | ||
45 | /// <returns>True upon completion of the task execution.</returns> | ||
46 | public override bool Execute() | ||
47 | { | ||
48 | List<ITaskItem> newItems = new List<ITaskItem>(); | ||
49 | |||
50 | foreach (string property in this.inputProperties.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) | ||
51 | { | ||
52 | newItems.Add(new TaskItem(property)); | ||
53 | } | ||
54 | |||
55 | this.outputItems = newItems.ToArray(); | ||
56 | |||
57 | return true; | ||
58 | } | ||
59 | } | ||
60 | } | ||
diff --git a/src/WixToolset.BuildTasks/CreateProjectReferenceDefineConstants.cs b/src/WixToolset.BuildTasks/CreateProjectReferenceDefineConstants.cs new file mode 100644 index 00000000..5eae0850 --- /dev/null +++ b/src/WixToolset.BuildTasks/CreateProjectReferenceDefineConstants.cs | |||
@@ -0,0 +1,270 @@ | |||
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.Collections.Generic; | ||
7 | using System.Globalization; | ||
8 | using System.IO; | ||
9 | using Microsoft.Build.Framework; | ||
10 | using Microsoft.Build.Utilities; | ||
11 | |||
12 | /// <summary> | ||
13 | /// An MSBuild task to create a list of preprocessor defines to be passed to candle from the | ||
14 | /// list of referenced projects. | ||
15 | /// </summary> | ||
16 | public sealed class CreateProjectReferenceDefineConstants : Task | ||
17 | { | ||
18 | private ITaskItem[] defineConstants; | ||
19 | private ITaskItem[] projectConfigurations; | ||
20 | private ITaskItem[] projectReferencePaths; | ||
21 | |||
22 | [Output] | ||
23 | public ITaskItem[] DefineConstants | ||
24 | { | ||
25 | get { return this.defineConstants; } | ||
26 | } | ||
27 | |||
28 | [Required] | ||
29 | public ITaskItem[] ProjectReferencePaths | ||
30 | { | ||
31 | get { return this.projectReferencePaths; } | ||
32 | set { this.projectReferencePaths = value; } | ||
33 | } | ||
34 | |||
35 | public ITaskItem[] ProjectConfigurations | ||
36 | { | ||
37 | get { return this.projectConfigurations; } | ||
38 | set { this.projectConfigurations = value; } | ||
39 | } | ||
40 | |||
41 | public override bool Execute() | ||
42 | { | ||
43 | List<ITaskItem> outputItems = new List<ITaskItem>(); | ||
44 | Dictionary<string, string> defineConstants = new Dictionary<string, string>(); | ||
45 | |||
46 | for (int i = 0; i < this.ProjectReferencePaths.Length; i++) | ||
47 | { | ||
48 | ITaskItem item = this.ProjectReferencePaths[i]; | ||
49 | |||
50 | string configuration = item.GetMetadata("Configuration"); | ||
51 | string fullConfiguration = item.GetMetadata("FullConfiguration"); | ||
52 | string platform = item.GetMetadata("Platform"); | ||
53 | |||
54 | string projectPath = CreateProjectReferenceDefineConstants.GetProjectPath(this.ProjectReferencePaths, i); | ||
55 | string projectDir = Path.GetDirectoryName(projectPath) + Path.DirectorySeparatorChar; | ||
56 | string projectExt = Path.GetExtension(projectPath); | ||
57 | string projectFileName = Path.GetFileName(projectPath); | ||
58 | string projectName = Path.GetFileNameWithoutExtension(projectPath); | ||
59 | |||
60 | string referenceName = CreateProjectReferenceDefineConstants.GetReferenceName(item, projectName); | ||
61 | |||
62 | string targetPath = item.GetMetadata("FullPath"); | ||
63 | string targetDir = Path.GetDirectoryName(targetPath) + Path.DirectorySeparatorChar; | ||
64 | string targetExt = Path.GetExtension(targetPath); | ||
65 | string targetFileName = Path.GetFileName(targetPath); | ||
66 | string targetName = Path.GetFileNameWithoutExtension(targetPath); | ||
67 | |||
68 | // If there is no configuration metadata on the project reference task item, | ||
69 | // check for any additional configuration data provided in the optional task property. | ||
70 | if (String.IsNullOrEmpty(fullConfiguration)) | ||
71 | { | ||
72 | fullConfiguration = this.FindProjectConfiguration(projectName); | ||
73 | if (!String.IsNullOrEmpty(fullConfiguration)) | ||
74 | { | ||
75 | string[] typeAndPlatform = fullConfiguration.Split('|'); | ||
76 | configuration = typeAndPlatform[0]; | ||
77 | platform = (typeAndPlatform.Length > 1 ? typeAndPlatform[1] : String.Empty); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | // write out the platform/configuration defines | ||
82 | defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.Configuration", referenceName)] = configuration; | ||
83 | defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.FullConfiguration", referenceName)] = fullConfiguration; | ||
84 | defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.Platform", referenceName)] = platform; | ||
85 | |||
86 | // write out the ProjectX defines | ||
87 | defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.ProjectDir", referenceName)] = projectDir; | ||
88 | defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.ProjectExt", referenceName)] = projectExt; | ||
89 | defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.ProjectFileName", referenceName)] = projectFileName; | ||
90 | defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.ProjectName", referenceName)] = projectName; | ||
91 | defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.ProjectPath", referenceName)] = projectPath; | ||
92 | |||
93 | // write out the TargetX defines | ||
94 | string targetDirDefine = String.Format(CultureInfo.InvariantCulture, "{0}.TargetDir", referenceName); | ||
95 | if (defineConstants.ContainsKey(targetDirDefine)) | ||
96 | { | ||
97 | //if target dir was already defined, redefine it as the common root shared by multiple references from the same project | ||
98 | string commonDir = FindCommonRoot(targetDir, defineConstants[targetDirDefine]); | ||
99 | if (!String.IsNullOrEmpty(commonDir)) | ||
100 | { | ||
101 | targetDir = commonDir; | ||
102 | } | ||
103 | } | ||
104 | defineConstants[targetDirDefine] = CreateProjectReferenceDefineConstants.EnsureEndsWithBackslash(targetDir); | ||
105 | |||
106 | defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.TargetExt", referenceName)] = targetExt; | ||
107 | defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.TargetFileName", referenceName)] = targetFileName; | ||
108 | defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.TargetName", referenceName)] = targetName; | ||
109 | |||
110 | //if target path was already defined, append to it creating a list of multiple references from the same project | ||
111 | string targetPathDefine = String.Format(CultureInfo.InvariantCulture, "{0}.TargetPath", referenceName); | ||
112 | if (defineConstants.ContainsKey(targetPathDefine)) | ||
113 | { | ||
114 | string oldTargetPath = defineConstants[targetPathDefine]; | ||
115 | if (!targetPath.Equals(oldTargetPath, StringComparison.OrdinalIgnoreCase)) | ||
116 | { | ||
117 | defineConstants[targetPathDefine] += ";" + targetPath; | ||
118 | } | ||
119 | |||
120 | //If there was only one targetpath we need to create its culture specific define | ||
121 | if (!oldTargetPath.Contains(";")) | ||
122 | { | ||
123 | string oldSubFolder = FindSubfolder(oldTargetPath, targetDir, targetFileName); | ||
124 | if (!String.IsNullOrEmpty(oldSubFolder)) | ||
125 | { | ||
126 | defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.{1}.TargetPath", referenceName, oldSubFolder.Replace('\\', '_'))] = oldTargetPath; | ||
127 | } | ||
128 | } | ||
129 | |||
130 | // Create a culture specific define | ||
131 | string subFolder = FindSubfolder(targetPath, targetDir, targetFileName); | ||
132 | if (!String.IsNullOrEmpty(subFolder)) | ||
133 | { | ||
134 | defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.{1}.TargetPath", referenceName, subFolder.Replace('\\', '_'))] = targetPath; | ||
135 | } | ||
136 | |||
137 | } | ||
138 | else | ||
139 | { | ||
140 | defineConstants[targetPathDefine] = targetPath; | ||
141 | } | ||
142 | } | ||
143 | |||
144 | foreach (KeyValuePair<string, string> define in defineConstants) | ||
145 | { | ||
146 | outputItems.Add(new TaskItem(String.Format(CultureInfo.InvariantCulture, "{0}={1}", define.Key, define.Value))); | ||
147 | } | ||
148 | this.defineConstants = outputItems.ToArray(); | ||
149 | |||
150 | return true; | ||
151 | } | ||
152 | |||
153 | public static string GetProjectPath(ITaskItem[] projectReferencePaths, int i) | ||
154 | { | ||
155 | return projectReferencePaths[i].GetMetadata("MSBuildSourceProjectFile"); | ||
156 | } | ||
157 | |||
158 | public static string GetReferenceName(ITaskItem item, string projectName) | ||
159 | { | ||
160 | string referenceName = item.GetMetadata("Name"); | ||
161 | if (String.IsNullOrEmpty(referenceName)) | ||
162 | { | ||
163 | referenceName = projectName; | ||
164 | } | ||
165 | |||
166 | // We cannot have an equals sign in the variable name because it | ||
167 | // messes with the preprocessor definitions on the command line. | ||
168 | referenceName = referenceName.Replace('=', '_'); | ||
169 | |||
170 | // We cannot have a double quote on the command line because it | ||
171 | // there is no way to escape it on the command line. | ||
172 | referenceName = referenceName.Replace('\"', '_'); | ||
173 | |||
174 | // We cannot have parens in the variable name because the WiX | ||
175 | // preprocessor will not be able to parse it. | ||
176 | referenceName = referenceName.Replace('(', '_'); | ||
177 | referenceName = referenceName.Replace(')', '_'); | ||
178 | |||
179 | return referenceName; | ||
180 | } | ||
181 | |||
182 | /// <summary> | ||
183 | /// Look through the configuration data in the ProjectConfigurations property | ||
184 | /// to find the configuration for a project, if available. | ||
185 | /// </summary> | ||
186 | /// <param name="projectName">Name of the project that is being searched for.</param> | ||
187 | /// <returns>Full configuration spec, for example "Release|Win32".</returns> | ||
188 | private string FindProjectConfiguration(string projectName) | ||
189 | { | ||
190 | string configuration = String.Empty; | ||
191 | |||
192 | if (this.ProjectConfigurations != null) | ||
193 | { | ||
194 | foreach (ITaskItem configItem in this.ProjectConfigurations) | ||
195 | { | ||
196 | string configProject = configItem.ItemSpec; | ||
197 | if (configProject.Length > projectName.Length && | ||
198 | configProject.StartsWith(projectName) && | ||
199 | configProject[projectName.Length] == '=') | ||
200 | { | ||
201 | configuration = configProject.Substring(projectName.Length + 1); | ||
202 | break; | ||
203 | } | ||
204 | } | ||
205 | } | ||
206 | |||
207 | return configuration; | ||
208 | } | ||
209 | |||
210 | /// <summary> | ||
211 | /// Finds the common root between two paths | ||
212 | /// </summary> | ||
213 | /// <param name="path1"></param> | ||
214 | /// <param name="path2"></param> | ||
215 | /// <returns>common root on success, empty string on failure</returns> | ||
216 | private static string FindCommonRoot(string path1, string path2) | ||
217 | { | ||
218 | path1 = path1.TrimEnd(Path.DirectorySeparatorChar); | ||
219 | path2 = path2.TrimEnd(Path.DirectorySeparatorChar); | ||
220 | |||
221 | while (!String.IsNullOrEmpty(path1)) | ||
222 | { | ||
223 | for (string searchPath = path2; !String.IsNullOrEmpty(searchPath); searchPath = Path.GetDirectoryName(searchPath)) | ||
224 | { | ||
225 | if (path1.Equals(searchPath, StringComparison.OrdinalIgnoreCase)) | ||
226 | { | ||
227 | return searchPath; | ||
228 | } | ||
229 | } | ||
230 | |||
231 | path1 = Path.GetDirectoryName(path1); | ||
232 | } | ||
233 | |||
234 | return path1; | ||
235 | } | ||
236 | |||
237 | /// <summary> | ||
238 | /// Finds the subfolder of a path, excluding a root and filename. | ||
239 | /// </summary> | ||
240 | /// <param name="path">Path to examine</param> | ||
241 | /// <param name="rootPath">Root that must be present </param> | ||
242 | /// <param name="fileName"></param> | ||
243 | /// <returns></returns> | ||
244 | private static string FindSubfolder(string path, string rootPath, string fileName) | ||
245 | { | ||
246 | if (Path.GetFileName(path).Equals(fileName, StringComparison.OrdinalIgnoreCase)) | ||
247 | { | ||
248 | path = Path.GetDirectoryName(path); | ||
249 | } | ||
250 | |||
251 | if (path.StartsWith(rootPath, StringComparison.OrdinalIgnoreCase)) | ||
252 | { | ||
253 | // cut out the root and return the subpath | ||
254 | return path.Substring(rootPath.Length).Trim(Path.DirectorySeparatorChar); | ||
255 | } | ||
256 | |||
257 | return String.Empty; | ||
258 | } | ||
259 | |||
260 | private static string EnsureEndsWithBackslash(string dir) | ||
261 | { | ||
262 | if (dir[dir.Length - 1] != Path.DirectorySeparatorChar) | ||
263 | { | ||
264 | dir += Path.DirectorySeparatorChar; | ||
265 | } | ||
266 | |||
267 | return dir; | ||
268 | } | ||
269 | } | ||
270 | } | ||
diff --git a/src/WixToolset.BuildTasks/DoIt-Compile.cs b/src/WixToolset.BuildTasks/DoIt-Compile.cs new file mode 100644 index 00000000..f89078fe --- /dev/null +++ b/src/WixToolset.BuildTasks/DoIt-Compile.cs | |||
@@ -0,0 +1,192 @@ | |||
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 | ||
diff --git a/src/WixToolset.BuildTasks/DoIt.cs b/src/WixToolset.BuildTasks/DoIt.cs new file mode 100644 index 00000000..7688342c --- /dev/null +++ b/src/WixToolset.BuildTasks/DoIt.cs | |||
@@ -0,0 +1,233 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolset.BuildTasks | ||
4 | { | ||
5 | using Microsoft.Build.Framework; | ||
6 | using Microsoft.Build.Utilities; | ||
7 | using WixToolset.Core; | ||
8 | using WixToolset.Data; | ||
9 | |||
10 | /// <summary> | ||
11 | /// An MSBuild task to run the WiX compiler. | ||
12 | /// </summary> | ||
13 | public sealed class DoIt : Task | ||
14 | { | ||
15 | public DoIt() | ||
16 | { | ||
17 | Messaging.Instance.InitializeAppName("WIX", "wix.exe"); | ||
18 | |||
19 | Messaging.Instance.Display += this.DisplayMessage; | ||
20 | } | ||
21 | |||
22 | public string AdditionalOptions { get; set; } | ||
23 | |||
24 | public string Cultures { get; set; } | ||
25 | |||
26 | public string[] DefineConstants { get; set; } | ||
27 | |||
28 | public ITaskItem[] Extensions { get; set; } | ||
29 | |||
30 | public string ExtensionDirectory { get; set; } | ||
31 | |||
32 | public string[] IncludeSearchPaths { get; set; } | ||
33 | |||
34 | public string InstallerPlatform { get; set; } | ||
35 | |||
36 | [Required] | ||
37 | public ITaskItem IntermediateDirectory { get; set; } | ||
38 | |||
39 | public ITaskItem[] LocalizationFiles { get; set; } | ||
40 | |||
41 | public bool NoLogo { get; set; } | ||
42 | |||
43 | public ITaskItem[] ObjectFiles { get; set; } | ||
44 | |||
45 | [Output] | ||
46 | [Required] | ||
47 | public ITaskItem OutputFile { get; set; } | ||
48 | |||
49 | public string PdbOutputFile { get; set; } | ||
50 | |||
51 | public bool Pedantic { get; set; } | ||
52 | |||
53 | [Required] | ||
54 | public ITaskItem[] SourceFiles { get; set; } | ||
55 | |||
56 | public string[] ReferencePaths { get; set; } | ||
57 | |||
58 | |||
59 | /// <summary> | ||
60 | /// Gets or sets whether all warnings should be suppressed. | ||
61 | /// </summary> | ||
62 | public bool SuppressAllWarnings { get; set; } | ||
63 | |||
64 | /// <summary> | ||
65 | /// Gets or sets a list of specific warnings to be suppressed. | ||
66 | /// </summary> | ||
67 | public string[] SuppressSpecificWarnings { get; set; } | ||
68 | |||
69 | /// <summary> | ||
70 | /// Gets or sets whether all warnings should be treated as errors. | ||
71 | /// </summary> | ||
72 | public bool TreatWarningsAsErrors { get; set; } | ||
73 | |||
74 | /// <summary> | ||
75 | /// Gets or sets a list of specific warnings to treat as errors. | ||
76 | /// </summary> | ||
77 | public string[] TreatSpecificWarningsAsErrors { get; set; } | ||
78 | |||
79 | /// <summary> | ||
80 | /// Gets or sets whether to display verbose output. | ||
81 | /// </summary> | ||
82 | public bool VerboseOutput { get; set; } | ||
83 | |||
84 | |||
85 | public ITaskItem[] BindInputPaths { get; set; } | ||
86 | public bool BindFiles { get; set; } | ||
87 | public ITaskItem BindContentsFile{ get; set; } | ||
88 | public ITaskItem BindOutputsFile { get; set; } | ||
89 | public ITaskItem BindBuiltOutputsFile { get; set; } | ||
90 | |||
91 | public string CabinetCachePath { get; set; } | ||
92 | public int CabinetCreationThreadCount { get; set; } | ||
93 | public string DefaultCompressionLevel { get; set; } | ||
94 | |||
95 | [Output] | ||
96 | public ITaskItem UnreferencedSymbolsFile { get; set; } | ||
97 | |||
98 | public ITaskItem WixProjectFile { get; set; } | ||
99 | public string[] WixVariables { get; set; } | ||
100 | |||
101 | public bool SuppressValidation { get; set; } | ||
102 | public string[] SuppressIces { get; set; } | ||
103 | public string AdditionalCub { get; set; } | ||
104 | |||
105 | |||
106 | |||
107 | public override bool Execute() | ||
108 | { | ||
109 | try | ||
110 | { | ||
111 | this.ExecuteCore(); | ||
112 | } | ||
113 | catch (BuildException e) | ||
114 | { | ||
115 | this.Log.LogErrorFromException(e); | ||
116 | } | ||
117 | catch (WixException e) | ||
118 | { | ||
119 | this.Log.LogErrorFromException(e); | ||
120 | } | ||
121 | |||
122 | return !this.Log.HasLoggedErrors; | ||
123 | } | ||
124 | |||
125 | private void ExecuteCore() | ||
126 | { | ||
127 | var commandLineBuilder = new WixCommandLineBuilder(); | ||
128 | |||
129 | commandLineBuilder.AppendTextUnquoted("build"); | ||
130 | |||
131 | commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile); | ||
132 | commandLineBuilder.AppendSwitchIfNotNull("-cultures ", this.Cultures); | ||
133 | commandLineBuilder.AppendArrayIfNotNull("-d ", this.DefineConstants); | ||
134 | commandLineBuilder.AppendArrayIfNotNull("-I ", this.IncludeSearchPaths); | ||
135 | commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.ReferencePaths); | ||
136 | commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo); | ||
137 | commandLineBuilder.AppendIfTrue("-sval", this.SuppressValidation); | ||
138 | commandLineBuilder.AppendArrayIfNotNull("-sice ", this.SuppressIces); | ||
139 | commandLineBuilder.AppendSwitchIfNotNull("-usf ", this.UnreferencedSymbolsFile); | ||
140 | commandLineBuilder.AppendSwitchIfNotNull("-cc ", this.CabinetCachePath); | ||
141 | commandLineBuilder.AppendSwitchIfNotNull("-contentsfile ", this.BindContentsFile); | ||
142 | commandLineBuilder.AppendSwitchIfNotNull("-outputsfile ", this.BindOutputsFile); | ||
143 | commandLineBuilder.AppendSwitchIfNotNull("-builtoutputsfile ", this.BindBuiltOutputsFile); | ||
144 | commandLineBuilder.AppendSwitchIfNotNull("-wixprojectfile ", this.WixProjectFile); | ||
145 | commandLineBuilder.AppendTextIfNotWhitespace(this.AdditionalOptions); | ||
146 | |||
147 | commandLineBuilder.AppendArrayIfNotNull("-loc ", this.LocalizationFiles); | ||
148 | commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " "); | ||
149 | |||
150 | var commandLineString = commandLineBuilder.ToString(); | ||
151 | |||
152 | this.Log.LogMessage(MessageImportance.Normal, commandLineString); | ||
153 | |||
154 | var command = CommandLine.ParseStandardCommandLine(commandLineString); | ||
155 | command?.Execute(); | ||
156 | } | ||
157 | |||
158 | private void DisplayMessage(object sender, DisplayEventArgs e) | ||
159 | { | ||
160 | this.Log.LogMessageFromText(e.Message, MessageImportance.Normal); | ||
161 | } | ||
162 | |||
163 | ///// <summary> | ||
164 | ///// Builds a command line from options in this task. | ||
165 | ///// </summary> | ||
166 | //protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder) | ||
167 | //{ | ||
168 | // base.BuildCommandLine(commandLineBuilder); | ||
169 | |||
170 | // commandLineBuilder.AppendIfTrue("-p", this.PreprocessToStdOut); | ||
171 | // commandLineBuilder.AppendSwitchIfNotNull("-p", this.PreprocessToFile); | ||
172 | // commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile); | ||
173 | // commandLineBuilder.AppendArrayIfNotNull("-d", this.DefineConstants); | ||
174 | // commandLineBuilder.AppendArrayIfNotNull("-I", this.IncludeSearchPaths); | ||
175 | // commandLineBuilder.AppendIfTrue("-pedantic", this.Pedantic); | ||
176 | // commandLineBuilder.AppendSwitchIfNotNull("-arch ", this.InstallerPlatform); | ||
177 | // commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.referencePaths); | ||
178 | // commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions); | ||
179 | |||
180 | // // Support per-source-file output by looking at the SourceFiles items to | ||
181 | // // see if there is any "CandleOutput" metadata. If there is, we do our own | ||
182 | // // appending, otherwise we fall back to the built-in "append file names" code. | ||
183 | // // Note also that the wix.targets "Compile" target does *not* automagically | ||
184 | // // fix the "@(CompileObjOutput)" list to include these new output names. | ||
185 | // // If you really want to use this, you're going to have to clone the target | ||
186 | // // in your own .targets file and create the output list yourself. | ||
187 | // bool usePerSourceOutput = false; | ||
188 | // if (this.SourceFiles != null) | ||
189 | // { | ||
190 | // foreach (ITaskItem item in this.SourceFiles) | ||
191 | // { | ||
192 | // if (!String.IsNullOrEmpty(item.GetMetadata("CandleOutput"))) | ||
193 | // { | ||
194 | // usePerSourceOutput = true; | ||
195 | // break; | ||
196 | // } | ||
197 | // } | ||
198 | // } | ||
199 | |||
200 | // if (usePerSourceOutput) | ||
201 | // { | ||
202 | // string[] newSourceNames = new string[this.SourceFiles.Length]; | ||
203 | // for (int iSource = 0; iSource < this.SourceFiles.Length; ++iSource) | ||
204 | // { | ||
205 | // ITaskItem item = this.SourceFiles[iSource]; | ||
206 | // if (null == item) | ||
207 | // { | ||
208 | // newSourceNames[iSource] = null; | ||
209 | // } | ||
210 | // else | ||
211 | // { | ||
212 | // string output = item.GetMetadata("CandleOutput"); | ||
213 | |||
214 | // if (!String.IsNullOrEmpty(output)) | ||
215 | // { | ||
216 | // newSourceNames[iSource] = String.Concat(item.ItemSpec, ";", output); | ||
217 | // } | ||
218 | // else | ||
219 | // { | ||
220 | // newSourceNames[iSource] = item.ItemSpec; | ||
221 | // } | ||
222 | // } | ||
223 | // } | ||
224 | |||
225 | // commandLineBuilder.AppendFileNamesIfNotNull(newSourceNames, " "); | ||
226 | // } | ||
227 | // else | ||
228 | // { | ||
229 | // commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " "); | ||
230 | // } | ||
231 | //} | ||
232 | } | ||
233 | } | ||
diff --git a/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs b/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs new file mode 100644 index 00000000..6cc804eb --- /dev/null +++ b/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs | |||
@@ -0,0 +1,60 @@ | |||
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.Collections.Generic; | ||
7 | using System.Diagnostics.CodeAnalysis; | ||
8 | using System.IO; | ||
9 | using System.Text; | ||
10 | using Microsoft.Build.Framework; | ||
11 | |||
12 | /// <summary> | ||
13 | /// Contains helper methods on searching for files | ||
14 | /// </summary> | ||
15 | public static class FileSearchHelperMethods | ||
16 | { | ||
17 | /// <summary> | ||
18 | /// Searches for the existence of a file in multiple directories. | ||
19 | /// Search is satisfied if default file path is valid and exists. If not, | ||
20 | /// file name is extracted from default path and combined with each of the directories | ||
21 | /// looking to see if it exists. If not found, input default path is returned. | ||
22 | /// </summary> | ||
23 | /// <param name="directories">Array of directories to look in, without filenames in them</param> | ||
24 | /// <param name="defaultFullPath">Default path - to use if not found</param> | ||
25 | /// <returns>File path if file found. Empty string if not found</returns> | ||
26 | public static string SearchFilePaths(string[] directories, string defaultFullPath) | ||
27 | { | ||
28 | if (String.IsNullOrEmpty(defaultFullPath)) | ||
29 | { | ||
30 | return String.Empty; | ||
31 | } | ||
32 | |||
33 | if (File.Exists(defaultFullPath)) | ||
34 | { | ||
35 | return defaultFullPath; | ||
36 | } | ||
37 | |||
38 | if (directories == null) | ||
39 | { | ||
40 | return string.Empty; | ||
41 | } | ||
42 | |||
43 | string fileName = Path.GetFileName(defaultFullPath); | ||
44 | foreach (string currentPath in directories) | ||
45 | { | ||
46 | if (String.IsNullOrEmpty(currentPath) || String.IsNullOrEmpty(currentPath.Trim())) | ||
47 | { | ||
48 | continue; | ||
49 | } | ||
50 | |||
51 | if (File.Exists(Path.Combine(currentPath, fileName))) | ||
52 | { | ||
53 | return Path.Combine(currentPath, fileName); | ||
54 | } | ||
55 | } | ||
56 | |||
57 | return String.Empty; | ||
58 | } | ||
59 | } | ||
60 | } | ||
diff --git a/src/WixToolset.BuildTasks/GenerateCompileWithObjectPath.cs b/src/WixToolset.BuildTasks/GenerateCompileWithObjectPath.cs new file mode 100644 index 00000000..06c8b98a --- /dev/null +++ b/src/WixToolset.BuildTasks/GenerateCompileWithObjectPath.cs | |||
@@ -0,0 +1,146 @@ | |||
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.Collections.Generic; | ||
7 | using System.Diagnostics.CodeAnalysis; | ||
8 | using System.Globalization; | ||
9 | using System.IO; | ||
10 | using System.Security.Cryptography; | ||
11 | using System.Text; | ||
12 | using Microsoft.Build.Framework; | ||
13 | using Microsoft.Build.Utilities; | ||
14 | |||
15 | /// <summary> | ||
16 | /// This task generates metadata on the for compile output objects. | ||
17 | /// </summary> | ||
18 | public class GenerateCompileWithObjectPath : Task | ||
19 | { | ||
20 | /// <summary> | ||
21 | /// The list of files to generate outputs for. | ||
22 | /// </summary> | ||
23 | [Required] | ||
24 | public ITaskItem[] Compile | ||
25 | { | ||
26 | get; | ||
27 | set; | ||
28 | } | ||
29 | |||
30 | /// <summary> | ||
31 | /// The list of files with ObjectPath metadata. | ||
32 | /// </summary> | ||
33 | [Output] | ||
34 | public ITaskItem[] CompileWithObjectPath | ||
35 | { | ||
36 | get; | ||
37 | private set; | ||
38 | } | ||
39 | |||
40 | /// <summary> | ||
41 | /// The folder under which all ObjectPaths should reside. | ||
42 | /// </summary> | ||
43 | [Required] | ||
44 | public string IntermediateOutputPath | ||
45 | { | ||
46 | get; | ||
47 | set; | ||
48 | } | ||
49 | |||
50 | /// <summary> | ||
51 | /// Generate an identifier by hashing data from the row. | ||
52 | /// </summary> | ||
53 | /// <param name="prefix">Three letter or less prefix for generated row identifier.</param> | ||
54 | /// <param name="args">Information to hash.</param> | ||
55 | /// <returns>The generated identifier.</returns> | ||
56 | [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.InvalidOperationException.#ctor(System.String)")] | ||
57 | public static string GenerateIdentifier(string prefix, params string[] args) | ||
58 | { | ||
59 | string stringData = String.Join("|", args); | ||
60 | byte[] data = Encoding.Unicode.GetBytes(stringData); | ||
61 | |||
62 | // hash the data | ||
63 | byte[] hash; | ||
64 | |||
65 | using (MD5 md5 = new MD5CryptoServiceProvider()) | ||
66 | { | ||
67 | hash = md5.ComputeHash(data); | ||
68 | } | ||
69 | |||
70 | // build up the identifier | ||
71 | StringBuilder identifier = new StringBuilder(35, 35); | ||
72 | identifier.Append(prefix); | ||
73 | |||
74 | // hard coded to 16 as that is the most bytes that can be used to meet the length requirements. SHA1 is 20 bytes. | ||
75 | for (int i = 0; i < 16; i++) | ||
76 | { | ||
77 | identifier.Append(hash[i].ToString("X2", CultureInfo.InvariantCulture.NumberFormat)); | ||
78 | } | ||
79 | |||
80 | return identifier.ToString(); | ||
81 | } | ||
82 | |||
83 | /// <summary> | ||
84 | /// Gets the full path of the directory in which the file is found. | ||
85 | /// </summary> | ||
86 | /// <param name='file'>The file from which to extract the directory.</param> | ||
87 | /// <returns>The generated identifier.</returns> | ||
88 | private static string GetDirectory(ITaskItem file) | ||
89 | { | ||
90 | return file.GetMetadata("RootDir") + file.GetMetadata("Directory"); | ||
91 | } | ||
92 | |||
93 | /// <summary> | ||
94 | /// Sets the object path to use for the file. | ||
95 | /// </summary> | ||
96 | /// <param name='file'>The file on which to set the ObjectPath metadata.</param> | ||
97 | /// <remarks> | ||
98 | /// For the same input path it will return the same ObjectPath. Case is not ignored, however that isn't a problem. | ||
99 | /// </remarks> | ||
100 | private void SetObjectPath(ITaskItem file) | ||
101 | { | ||
102 | // If the source file is in the project directory or in the intermediate directory, use the intermediate directory. | ||
103 | if (string.IsNullOrEmpty(file.GetMetadata("RelativeDir")) || string.Compare(file.GetMetadata("RelativeDir"), this.IntermediateOutputPath, StringComparison.OrdinalIgnoreCase) == 0) | ||
104 | { | ||
105 | file.SetMetadata("ObjectPath", this.IntermediateOutputPath); | ||
106 | } | ||
107 | // Otherwise use a subdirectory of the intermediate directory. The subfolder's name is based on the full path of the folder containing the source file. | ||
108 | else | ||
109 | { | ||
110 | file.SetMetadata("ObjectPath", Path.Combine(this.IntermediateOutputPath, GenerateIdentifier("pth", GetDirectory(file))) + Path.DirectorySeparatorChar); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | /// <summary> | ||
115 | /// Gets a complete list of external cabs referenced by the given installer database file. | ||
116 | /// </summary> | ||
117 | /// <returns>True upon completion of the task execution.</returns> | ||
118 | public override bool Execute() | ||
119 | { | ||
120 | if (string.IsNullOrEmpty(this.IntermediateOutputPath)) | ||
121 | { | ||
122 | this.Log.LogError("IntermediateOutputPath parameter is required and cannot be empty"); | ||
123 | return false; | ||
124 | } | ||
125 | |||
126 | if (this.Compile == null || this.Compile.Length == 0) | ||
127 | { | ||
128 | return true; | ||
129 | } | ||
130 | |||
131 | this.CompileWithObjectPath = new ITaskItem[this.Compile.Length]; | ||
132 | for (int i = 0; i < this.Compile.Length; ++i) | ||
133 | { | ||
134 | this.CompileWithObjectPath[i] = new TaskItem(this.Compile[i].ItemSpec, this.Compile[i].CloneCustomMetadata()); | ||
135 | |||
136 | // Do not overwrite the ObjectPath metadata if it already was set. | ||
137 | if (string.IsNullOrEmpty(this.CompileWithObjectPath[i].GetMetadata("ObjectPath"))) | ||
138 | { | ||
139 | SetObjectPath(this.CompileWithObjectPath[i]); | ||
140 | } | ||
141 | } | ||
142 | |||
143 | return true; | ||
144 | } | ||
145 | } | ||
146 | } | ||
diff --git a/src/WixToolset.BuildTasks/GetCabList.cs b/src/WixToolset.BuildTasks/GetCabList.cs new file mode 100644 index 00000000..e97538af --- /dev/null +++ b/src/WixToolset.BuildTasks/GetCabList.cs | |||
@@ -0,0 +1,87 @@ | |||
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.Collections; | ||
7 | using System.Collections.Generic; | ||
8 | using System.Diagnostics; | ||
9 | using System.IO; | ||
10 | using System.Reflection; | ||
11 | using System.Xml; | ||
12 | using Microsoft.Build.Framework; | ||
13 | using Microsoft.Build.Utilities; | ||
14 | using WixToolset.Dtf.WindowsInstaller; | ||
15 | using Microsoft.Win32; | ||
16 | |||
17 | /// <summary> | ||
18 | /// This task assigns Culture metadata to files based on the value of the Culture attribute on the | ||
19 | /// WixLocalization element inside the file. | ||
20 | /// </summary> | ||
21 | public class GetCabList : Task | ||
22 | { | ||
23 | private ITaskItem database; | ||
24 | private ITaskItem[] cabList; | ||
25 | |||
26 | /// <summary> | ||
27 | /// The list of database files to find cabs in | ||
28 | /// </summary> | ||
29 | [Required] | ||
30 | public ITaskItem Database | ||
31 | { | ||
32 | get { return this.database; } | ||
33 | set { this.database = value; } | ||
34 | } | ||
35 | |||
36 | /// <summary> | ||
37 | /// The total list of cabs in this database | ||
38 | /// </summary> | ||
39 | [Output] | ||
40 | public ITaskItem[] CabList | ||
41 | { | ||
42 | get { return this.cabList; } | ||
43 | } | ||
44 | |||
45 | /// <summary> | ||
46 | /// Gets a complete list of external cabs referenced by the given installer database file. | ||
47 | /// </summary> | ||
48 | /// <returns>True upon completion of the task execution.</returns> | ||
49 | public override bool Execute() | ||
50 | { | ||
51 | string databaseFile = this.database.ItemSpec; | ||
52 | Object []args = { }; | ||
53 | System.Collections.Generic.List<ITaskItem> cabNames = new System.Collections.Generic.List<ITaskItem>(); | ||
54 | |||
55 | // If the file doesn't exist, no cabs to return, so exit now | ||
56 | if (!File.Exists(databaseFile)) | ||
57 | { | ||
58 | return true; | ||
59 | } | ||
60 | |||
61 | using (Database database = new Database(databaseFile)) | ||
62 | { | ||
63 | // If the media table doesn't exist, no cabs to return, so exit now | ||
64 | if (null == database.Tables["Media"]) | ||
65 | { | ||
66 | return true; | ||
67 | } | ||
68 | |||
69 | System.Collections.IList records = database.ExecuteQuery("SELECT `Cabinet` FROM `Media`", args); | ||
70 | |||
71 | foreach (string cabName in records) | ||
72 | { | ||
73 | if (String.IsNullOrEmpty(cabName) || cabName.StartsWith("#", StringComparison.Ordinal)) | ||
74 | { | ||
75 | continue; | ||
76 | } | ||
77 | |||
78 | cabNames.Add(new TaskItem(Path.Combine(Path.GetDirectoryName(databaseFile), cabName))); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | this.cabList = cabNames.ToArray(); | ||
83 | |||
84 | return true; | ||
85 | } | ||
86 | } | ||
87 | } | ||
diff --git a/src/WixToolset.BuildTasks/GetLooseFileList.cs b/src/WixToolset.BuildTasks/GetLooseFileList.cs new file mode 100644 index 00000000..bd403426 --- /dev/null +++ b/src/WixToolset.BuildTasks/GetLooseFileList.cs | |||
@@ -0,0 +1,230 @@ | |||
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.Collections; | ||
7 | using System.Collections.Generic; | ||
8 | using System.Diagnostics; | ||
9 | using System.IO; | ||
10 | using System.Reflection; | ||
11 | using System.Xml; | ||
12 | using Microsoft.Build.Framework; | ||
13 | using Microsoft.Build.Utilities; | ||
14 | using WixToolset.Dtf.WindowsInstaller; | ||
15 | using Microsoft.Win32; | ||
16 | |||
17 | /// <summary> | ||
18 | /// This task assigns Culture metadata to files based on the value of the Culture attribute on the | ||
19 | /// WixLocalization element inside the file. | ||
20 | /// </summary> | ||
21 | public class GetLooseFileList : Task | ||
22 | { | ||
23 | private ITaskItem database; | ||
24 | private ITaskItem[] looseFileList; | ||
25 | |||
26 | internal const int MsidbFileAttributesNoncompressed = 8192; | ||
27 | internal const int MsidbFileAttributesCompressed = 16384; | ||
28 | |||
29 | /// <summary> | ||
30 | /// The list of database files to find Loose Files in | ||
31 | /// </summary> | ||
32 | [Required] | ||
33 | public ITaskItem Database | ||
34 | { | ||
35 | get { return this.database; } | ||
36 | set { this.database = value; } | ||
37 | } | ||
38 | |||
39 | /// <summary> | ||
40 | /// The total list of Loose Files in this database | ||
41 | /// </summary> | ||
42 | [Output] | ||
43 | public ITaskItem[] LooseFileList | ||
44 | { | ||
45 | get { return this.looseFileList; } | ||
46 | } | ||
47 | |||
48 | /// <summary> | ||
49 | /// Takes the "defaultDir" column | ||
50 | /// </summary> | ||
51 | /// <returns>Returns the corresponding sourceDir.</returns> | ||
52 | public string SourceDirFromDefaultDir(string defaultDir) | ||
53 | { | ||
54 | string sourceDir; | ||
55 | |||
56 | string[] splitted = defaultDir.Split(':'); | ||
57 | |||
58 | if (1 == splitted.Length) | ||
59 | { | ||
60 | sourceDir = splitted[0]; | ||
61 | } | ||
62 | else | ||
63 | { | ||
64 | sourceDir = splitted[1]; | ||
65 | } | ||
66 | |||
67 | splitted = sourceDir.Split('|'); | ||
68 | |||
69 | if (1 == splitted.Length) | ||
70 | { | ||
71 | sourceDir = splitted[0]; | ||
72 | } | ||
73 | else | ||
74 | { | ||
75 | sourceDir = splitted[1]; | ||
76 | } | ||
77 | |||
78 | return sourceDir; | ||
79 | } | ||
80 | |||
81 | /// <summary> | ||
82 | /// Takes the "FileName" column | ||
83 | /// </summary> | ||
84 | /// <returns>Returns the corresponding source file name.</returns> | ||
85 | public string SourceFileFromFileName(string fileName) | ||
86 | { | ||
87 | string sourceFile; | ||
88 | |||
89 | string[] splitted = fileName.Split('|'); | ||
90 | |||
91 | if (1 == splitted.Length) | ||
92 | { | ||
93 | sourceFile = splitted[0]; | ||
94 | } | ||
95 | else | ||
96 | { | ||
97 | sourceFile = splitted[1]; | ||
98 | } | ||
99 | |||
100 | return sourceFile; | ||
101 | } | ||
102 | |||
103 | /// <summary> | ||
104 | /// Gets a complete list of external Loose Files referenced by the given installer database file. | ||
105 | /// </summary> | ||
106 | /// <returns>True upon completion of the task execution.</returns> | ||
107 | public override bool Execute() | ||
108 | { | ||
109 | string databaseFile = this.database.ItemSpec; | ||
110 | Object []emptyArgs = { }; | ||
111 | System.Collections.Generic.List<ITaskItem> looseFileNames = new System.Collections.Generic.List<ITaskItem>(); | ||
112 | Dictionary<string, string> ComponentFullDirectory = new Dictionary<string, string>(); | ||
113 | Dictionary<string, string> DirectoryIdDefaultDir = new Dictionary<string, string>(); | ||
114 | Dictionary<string, string> DirectoryIdParent = new Dictionary<string, string>(); | ||
115 | Dictionary<string, string> DirectoryIdFullSource = new Dictionary<string, string>(); | ||
116 | int i; | ||
117 | string databaseDir = Path.GetDirectoryName(databaseFile); | ||
118 | |||
119 | // If the file doesn't exist, no Loose Files to return, so exit now | ||
120 | if (!File.Exists(databaseFile)) | ||
121 | { | ||
122 | return true; | ||
123 | } | ||
124 | |||
125 | using (Database database = new Database(databaseFile)) | ||
126 | { | ||
127 | bool compressed = false; | ||
128 | if (2 == (database.SummaryInfo.WordCount & 2)) | ||
129 | { | ||
130 | compressed = true; | ||
131 | } | ||
132 | |||
133 | // If the media table doesn't exist, no Loose Files to return, so exit now | ||
134 | if (null == database.Tables["File"]) | ||
135 | { | ||
136 | return true; | ||
137 | } | ||
138 | |||
139 | // Only setup all these helpful indexes if the database is marked as uncompressed. If it's marked as compressed, files are stored at the root, | ||
140 | // so none of these indexes will be used | ||
141 | if (!compressed) | ||
142 | { | ||
143 | if (null == database.Tables["Directory"] || null == database.Tables["Component"]) | ||
144 | { | ||
145 | return true; | ||
146 | } | ||
147 | |||
148 | System.Collections.IList directoryRecords = database.ExecuteQuery("SELECT `Directory`,`Directory_Parent`,`DefaultDir` FROM `Directory`", emptyArgs); | ||
149 | |||
150 | // First setup a simple index from DirectoryId to DefaultDir | ||
151 | for (i = 0; i < directoryRecords.Count; i += 3) | ||
152 | { | ||
153 | string directoryId = (string)(directoryRecords[i]); | ||
154 | string directoryParent = (string)(directoryRecords[i + 1]); | ||
155 | string defaultDir = (string)(directoryRecords[i + 2]); | ||
156 | |||
157 | string sourceDir = SourceDirFromDefaultDir(defaultDir); | ||
158 | |||
159 | DirectoryIdDefaultDir[directoryId] = sourceDir; | ||
160 | DirectoryIdParent[directoryId] = directoryParent; | ||
161 | } | ||
162 | |||
163 | // Setup an index from directory Id to the full source path | ||
164 | for (i = 0; i < directoryRecords.Count; i += 3) | ||
165 | { | ||
166 | string directoryId = (string)(directoryRecords[i]); | ||
167 | string directoryParent = (string)(directoryRecords[i + 1]); | ||
168 | string defaultDir = (string)(directoryRecords[i + 2]); | ||
169 | |||
170 | string sourceDir = DirectoryIdDefaultDir[directoryId]; | ||
171 | |||
172 | // The TARGETDIR case | ||
173 | if (String.IsNullOrEmpty(directoryParent)) | ||
174 | { | ||
175 | DirectoryIdFullSource[directoryId] = databaseDir; | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | string tempDirectoryParent = directoryParent; | ||
180 | |||
181 | while (!String.IsNullOrEmpty(tempDirectoryParent) && !String.IsNullOrEmpty(DirectoryIdParent[tempDirectoryParent])) | ||
182 | { | ||
183 | sourceDir = Path.Combine(DirectoryIdDefaultDir[tempDirectoryParent], sourceDir); | ||
184 | |||
185 | tempDirectoryParent = DirectoryIdParent[tempDirectoryParent]; | ||
186 | } | ||
187 | |||
188 | DirectoryIdFullSource[directoryId] = Path.Combine(databaseDir, sourceDir); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | // Setup an index from component Id to full directory path | ||
193 | System.Collections.IList componentRecords = database.ExecuteQuery("SELECT `Component`,`Directory_` FROM `Component`", emptyArgs); | ||
194 | |||
195 | for (i = 0; i < componentRecords.Count; i += 2) | ||
196 | { | ||
197 | string componentId = (string)(componentRecords[i]); | ||
198 | string componentDir = (string)(componentRecords[i + 1]); | ||
199 | |||
200 | ComponentFullDirectory[componentId] = DirectoryIdFullSource[componentDir]; | ||
201 | } | ||
202 | } | ||
203 | |||
204 | System.Collections.IList fileRecords = database.ExecuteQuery("SELECT `Component_`,`FileName`,`Attributes` FROM `File`", emptyArgs); | ||
205 | |||
206 | for (i = 0; i < fileRecords.Count; i += 3) | ||
207 | { | ||
208 | string componentId = (string)(fileRecords[i]); | ||
209 | string fileName = SourceFileFromFileName((string)(fileRecords[i + 1])); | ||
210 | int attributes = (int)(fileRecords[i + 2]); | ||
211 | |||
212 | // If the whole database is marked uncompressed, use the directory layout made above | ||
213 | if ((!compressed && MsidbFileAttributesCompressed != (attributes & MsidbFileAttributesCompressed))) | ||
214 | { | ||
215 | looseFileNames.Add(new TaskItem(Path.GetFullPath(Path.Combine(ComponentFullDirectory[componentId], fileName)))); | ||
216 | } | ||
217 | // If the database is marked as compressed, put files at the root | ||
218 | else if (compressed && (MsidbFileAttributesNoncompressed == (attributes & MsidbFileAttributesNoncompressed))) | ||
219 | { | ||
220 | looseFileNames.Add(new TaskItem(Path.GetFullPath(Path.Combine(databaseDir, fileName)))); | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | |||
225 | this.looseFileList = looseFileNames.ToArray(); | ||
226 | |||
227 | return true; | ||
228 | } | ||
229 | } | ||
230 | } | ||
diff --git a/src/WixToolset.BuildTasks/GlobalSuppressions.cs b/src/WixToolset.BuildTasks/GlobalSuppressions.cs new file mode 100644 index 00000000..65c34c13 --- /dev/null +++ b/src/WixToolset.BuildTasks/GlobalSuppressions.cs | |||
@@ -0,0 +1,8 @@ | |||
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 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "WixToolset")] | ||
4 | |||
5 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Msi", Scope = "namespace", Target = "WixToolset.BuildTasks")] | ||
6 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "wix")] | ||
7 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wix")] | ||
8 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "wix")] | ||
diff --git a/src/WixToolset.BuildTasks/Insignia.cs b/src/WixToolset.BuildTasks/Insignia.cs new file mode 100644 index 00000000..ba30963a --- /dev/null +++ b/src/WixToolset.BuildTasks/Insignia.cs | |||
@@ -0,0 +1,118 @@ | |||
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 Insignia : WixToolTask | ||
18 | { | ||
19 | private const string InsigniaToolName = "insignia.exe"; | ||
20 | |||
21 | /// <summary> | ||
22 | /// Gets or sets the path to the database to inscribe. | ||
23 | /// </summary> | ||
24 | public ITaskItem DatabaseFile { get; set; } | ||
25 | |||
26 | /// <summary> | ||
27 | /// Gets or sets the path to the bundle to inscribe. | ||
28 | /// </summary> | ||
29 | public ITaskItem BundleFile { get; set; } | ||
30 | |||
31 | /// <summary> | ||
32 | /// Gets or sets the path to the original bundle that contains the attached container. | ||
33 | /// </summary> | ||
34 | public ITaskItem OriginalBundleFile { get; set; } | ||
35 | |||
36 | /// <summary> | ||
37 | /// Gets or sets the path to output the inscribed result. | ||
38 | /// </summary> | ||
39 | [Required] | ||
40 | public ITaskItem OutputFile { get; set; } | ||
41 | |||
42 | /// <summary> | ||
43 | /// Gets or sets the output. Only set if insignia does work. | ||
44 | /// </summary> | ||
45 | [Output] | ||
46 | public ITaskItem Output { 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 Insignia.exe.</remarks> | ||
52 | /// <value>The name of the executable.</value> | ||
53 | protected override string ToolName | ||
54 | { | ||
55 | get { return InsigniaToolName; } | ||
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 Insignia.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 InsigniaToolName; | ||
69 | } | ||
70 | |||
71 | return Path.Combine(Path.GetFullPath(this.ToolPath), InsigniaToolName); | ||
72 | } | ||
73 | |||
74 | /// <summary> | ||
75 | /// Builds a command line from options in this task. | ||
76 | /// </summary> | ||
77 | protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder) | ||
78 | { | ||
79 | base.BuildCommandLine(commandLineBuilder); | ||
80 | |||
81 | commandLineBuilder.AppendSwitchIfNotNull("-im ", this.DatabaseFile); | ||
82 | if (null != this.OriginalBundleFile) | ||
83 | { | ||
84 | commandLineBuilder.AppendSwitchIfNotNull("-ab ", this.BundleFile); | ||
85 | commandLineBuilder.AppendFileNameIfNotNull(this.OriginalBundleFile); | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | commandLineBuilder.AppendSwitchIfNotNull("-ib ", this.BundleFile); | ||
90 | } | ||
91 | |||
92 | commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile); | ||
93 | commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions); | ||
94 | } | ||
95 | |||
96 | /// <summary> | ||
97 | /// Executes a tool in-process by loading the tool assembly and invoking its entrypoint. | ||
98 | /// </summary> | ||
99 | /// <param name="pathToTool">Path to the tool to be executed; must be a managed executable.</param> | ||
100 | /// <param name="responseFileCommands">Commands to be written to a response file.</param> | ||
101 | /// <param name="commandLineCommands">Commands to be passed directly on the command-line.</param> | ||
102 | /// <returns>The tool exit code.</returns> | ||
103 | protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands) | ||
104 | { | ||
105 | int returnCode = base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands); | ||
106 | if (0 == returnCode) // successfully did work. | ||
107 | { | ||
108 | this.Output = this.OutputFile; | ||
109 | } | ||
110 | else if (-1 == returnCode) // no work done. | ||
111 | { | ||
112 | returnCode = 0; | ||
113 | } | ||
114 | |||
115 | return returnCode; | ||
116 | } | ||
117 | } | ||
118 | } | ||
diff --git a/src/WixToolset.BuildTasks/Light.cs b/src/WixToolset.BuildTasks/Light.cs new file mode 100644 index 00000000..b7d0b4f7 --- /dev/null +++ b/src/WixToolset.BuildTasks/Light.cs | |||
@@ -0,0 +1,488 @@ | |||
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.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 new file mode 100644 index 00000000..1df964ae --- /dev/null +++ b/src/WixToolset.BuildTasks/Lit.cs | |||
@@ -0,0 +1,178 @@ | |||
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.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 new file mode 100644 index 00000000..f6b069da --- /dev/null +++ b/src/WixToolset.BuildTasks/Pyro.cs | |||
@@ -0,0 +1,140 @@ | |||
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.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/RefreshBundleGeneratedFile.cs b/src/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs new file mode 100644 index 00000000..5445e0cd --- /dev/null +++ b/src/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs | |||
@@ -0,0 +1,132 @@ | |||
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.Collections; | ||
7 | using System.Globalization; | ||
8 | using System.IO; | ||
9 | using System.Text.RegularExpressions; | ||
10 | using System.Xml; | ||
11 | using Microsoft.Build.Framework; | ||
12 | using Microsoft.Build.Utilities; | ||
13 | |||
14 | /// <summary> | ||
15 | /// This task refreshes the generated file for bundle projects. | ||
16 | /// </summary> | ||
17 | public class RefreshBundleGeneratedFile : Task | ||
18 | { | ||
19 | private static readonly Regex AddPrefix = new Regex(@"^[^a-zA-Z_]", RegexOptions.Compiled); | ||
20 | private static readonly Regex IllegalIdentifierCharacters = new Regex(@"[^A-Za-z0-9_\.]|\.{2,}", RegexOptions.Compiled); // non 'words' and assorted valid characters | ||
21 | |||
22 | private ITaskItem[] generatedFiles; | ||
23 | private ITaskItem[] projectReferencePaths; | ||
24 | |||
25 | /// <summary> | ||
26 | /// The list of files to generate. | ||
27 | /// </summary> | ||
28 | [Required] | ||
29 | public ITaskItem[] GeneratedFiles | ||
30 | { | ||
31 | get { return this.generatedFiles; } | ||
32 | set { this.generatedFiles = value; } | ||
33 | } | ||
34 | |||
35 | /// <summary> | ||
36 | /// All the project references in the project. | ||
37 | /// </summary> | ||
38 | [Required] | ||
39 | public ITaskItem[] ProjectReferencePaths | ||
40 | { | ||
41 | get { return this.projectReferencePaths; } | ||
42 | set { this.projectReferencePaths = value; } | ||
43 | } | ||
44 | |||
45 | /// <summary> | ||
46 | /// Gets a complete list of external cabs referenced by the given installer database file. | ||
47 | /// </summary> | ||
48 | /// <returns>True upon completion of the task execution.</returns> | ||
49 | public override bool Execute() | ||
50 | { | ||
51 | ArrayList payloadGroupRefs = new ArrayList(); | ||
52 | ArrayList packageGroupRefs = new ArrayList(); | ||
53 | for (int i = 0; i < this.ProjectReferencePaths.Length; i++) | ||
54 | { | ||
55 | ITaskItem item = this.ProjectReferencePaths[i]; | ||
56 | |||
57 | if (!String.IsNullOrEmpty(item.GetMetadata(Common.DoNotHarvest))) | ||
58 | { | ||
59 | continue; | ||
60 | } | ||
61 | |||
62 | string projectPath = CreateProjectReferenceDefineConstants.GetProjectPath(this.ProjectReferencePaths, i); | ||
63 | string projectName = Path.GetFileNameWithoutExtension(projectPath); | ||
64 | string referenceName = Common.GetIdentifierFromName(CreateProjectReferenceDefineConstants.GetReferenceName(item, projectName)); | ||
65 | |||
66 | string[] pogs = item.GetMetadata("RefProjectOutputGroups").Split(';'); | ||
67 | foreach (string pog in pogs) | ||
68 | { | ||
69 | if (!String.IsNullOrEmpty(pog)) | ||
70 | { | ||
71 | // TODO: Add payload group references and package group references once heat is generating them | ||
72 | ////payloadGroupRefs.Add(String.Format(CultureInfo.InvariantCulture, "{0}.{1}", referenceName, pog)); | ||
73 | packageGroupRefs.Add(String.Format(CultureInfo.InvariantCulture, "{0}.{1}", referenceName, pog)); | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | |||
78 | XmlDocument doc = new XmlDocument(); | ||
79 | |||
80 | XmlProcessingInstruction head = doc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); | ||
81 | doc.AppendChild(head); | ||
82 | |||
83 | XmlElement rootElement = doc.CreateElement("Wix"); | ||
84 | rootElement.SetAttribute("xmlns", "http://wixtoolset.org/schemas/v4/wxs"); | ||
85 | doc.AppendChild(rootElement); | ||
86 | |||
87 | XmlElement fragment = doc.CreateElement("Fragment"); | ||
88 | rootElement.AppendChild(fragment); | ||
89 | |||
90 | XmlElement payloadGroup = doc.CreateElement("PayloadGroup"); | ||
91 | payloadGroup.SetAttribute("Id", "Bundle.Generated.Payloads"); | ||
92 | fragment.AppendChild(payloadGroup); | ||
93 | |||
94 | XmlElement packageGroup = doc.CreateElement("PackageGroup"); | ||
95 | packageGroup.SetAttribute("Id", "Bundle.Generated.Packages"); | ||
96 | fragment.AppendChild(packageGroup); | ||
97 | |||
98 | foreach (string payloadGroupRef in payloadGroupRefs) | ||
99 | { | ||
100 | XmlElement payloadGroupRefElement = doc.CreateElement("PayloadGroupRef"); | ||
101 | payloadGroupRefElement.SetAttribute("Id", payloadGroupRef); | ||
102 | payloadGroup.AppendChild(payloadGroupRefElement); | ||
103 | } | ||
104 | |||
105 | foreach (string packageGroupRef in packageGroupRefs) | ||
106 | { | ||
107 | XmlElement packageGroupRefElement = doc.CreateElement("PackageGroupRef"); | ||
108 | packageGroupRefElement.SetAttribute("Id", packageGroupRef); | ||
109 | packageGroup.AppendChild(packageGroupRefElement); | ||
110 | } | ||
111 | |||
112 | foreach (ITaskItem item in this.GeneratedFiles) | ||
113 | { | ||
114 | string fullPath = item.GetMetadata("FullPath"); | ||
115 | |||
116 | payloadGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath) + ".Payloads"); | ||
117 | packageGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath) + ".Packages"); | ||
118 | try | ||
119 | { | ||
120 | doc.Save(fullPath); | ||
121 | } | ||
122 | catch (Exception e) | ||
123 | { | ||
124 | // e.Message will be something like: "Access to the path 'fullPath' is denied." | ||
125 | this.Log.LogMessage(MessageImportance.High, "Unable to save generated file to '{0}'. {1}", fullPath, e.Message); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | return true; | ||
130 | } | ||
131 | } | ||
132 | } | ||
diff --git a/src/WixToolset.BuildTasks/RefreshGeneratedFile.cs b/src/WixToolset.BuildTasks/RefreshGeneratedFile.cs new file mode 100644 index 00000000..fdfc4774 --- /dev/null +++ b/src/WixToolset.BuildTasks/RefreshGeneratedFile.cs | |||
@@ -0,0 +1,118 @@ | |||
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.Collections; | ||
7 | using System.Globalization; | ||
8 | using System.IO; | ||
9 | using System.Text.RegularExpressions; | ||
10 | using System.Xml; | ||
11 | using Microsoft.Build.Framework; | ||
12 | using Microsoft.Build.Utilities; | ||
13 | |||
14 | /// <summary> | ||
15 | /// This task refreshes the generated file that contains ComponentGroupRefs | ||
16 | /// to harvested output. | ||
17 | /// </summary> | ||
18 | public class RefreshGeneratedFile : Task | ||
19 | { | ||
20 | private static readonly Regex AddPrefix = new Regex(@"^[^a-zA-Z_]", RegexOptions.Compiled); | ||
21 | private static readonly Regex IllegalIdentifierCharacters = new Regex(@"[^A-Za-z0-9_\.]|\.{2,}", RegexOptions.Compiled); // non 'words' and assorted valid characters | ||
22 | |||
23 | private ITaskItem[] generatedFiles; | ||
24 | private ITaskItem[] projectReferencePaths; | ||
25 | |||
26 | /// <summary> | ||
27 | /// The list of files to generate. | ||
28 | /// </summary> | ||
29 | [Required] | ||
30 | public ITaskItem[] GeneratedFiles | ||
31 | { | ||
32 | get { return this.generatedFiles; } | ||
33 | set { this.generatedFiles = value; } | ||
34 | } | ||
35 | |||
36 | /// <summary> | ||
37 | /// All the project references in the project. | ||
38 | /// </summary> | ||
39 | [Required] | ||
40 | public ITaskItem[] ProjectReferencePaths | ||
41 | { | ||
42 | get { return this.projectReferencePaths; } | ||
43 | set { this.projectReferencePaths = value; } | ||
44 | } | ||
45 | |||
46 | /// <summary> | ||
47 | /// Gets a complete list of external cabs referenced by the given installer database file. | ||
48 | /// </summary> | ||
49 | /// <returns>True upon completion of the task execution.</returns> | ||
50 | public override bool Execute() | ||
51 | { | ||
52 | ArrayList componentGroupRefs = new ArrayList(); | ||
53 | for (int i = 0; i < this.ProjectReferencePaths.Length; i++) | ||
54 | { | ||
55 | ITaskItem item = this.ProjectReferencePaths[i]; | ||
56 | |||
57 | if (!String.IsNullOrEmpty(item.GetMetadata(Common.DoNotHarvest))) | ||
58 | { | ||
59 | continue; | ||
60 | } | ||
61 | |||
62 | string projectPath = CreateProjectReferenceDefineConstants.GetProjectPath(this.ProjectReferencePaths, i); | ||
63 | string projectName = Path.GetFileNameWithoutExtension(projectPath); | ||
64 | string referenceName = Common.GetIdentifierFromName(CreateProjectReferenceDefineConstants.GetReferenceName(item, projectName)); | ||
65 | |||
66 | string[] pogs = item.GetMetadata("RefProjectOutputGroups").Split(';'); | ||
67 | foreach (string pog in pogs) | ||
68 | { | ||
69 | if (!String.IsNullOrEmpty(pog)) | ||
70 | { | ||
71 | componentGroupRefs.Add(String.Format(CultureInfo.InvariantCulture, "{0}.{1}", referenceName, pog)); | ||
72 | } | ||
73 | } | ||
74 | } | ||
75 | |||
76 | XmlDocument doc = new XmlDocument(); | ||
77 | |||
78 | XmlProcessingInstruction head = doc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); | ||
79 | doc.AppendChild(head); | ||
80 | |||
81 | XmlElement rootElement = doc.CreateElement("Wix"); | ||
82 | rootElement.SetAttribute("xmlns", "http://wixtoolset.org/schemas/v4/wxs"); | ||
83 | doc.AppendChild(rootElement); | ||
84 | |||
85 | XmlElement fragment = doc.CreateElement("Fragment"); | ||
86 | rootElement.AppendChild(fragment); | ||
87 | |||
88 | XmlElement componentGroup = doc.CreateElement("ComponentGroup"); | ||
89 | componentGroup.SetAttribute("Id", "Product.Generated"); | ||
90 | fragment.AppendChild(componentGroup); | ||
91 | |||
92 | foreach (string componentGroupRef in componentGroupRefs) | ||
93 | { | ||
94 | XmlElement componentGroupRefElement = doc.CreateElement("ComponentGroupRef"); | ||
95 | componentGroupRefElement.SetAttribute("Id", componentGroupRef); | ||
96 | componentGroup.AppendChild(componentGroupRefElement); | ||
97 | } | ||
98 | |||
99 | foreach (ITaskItem item in this.GeneratedFiles) | ||
100 | { | ||
101 | string fullPath = item.GetMetadata("FullPath"); | ||
102 | |||
103 | componentGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath)); | ||
104 | try | ||
105 | { | ||
106 | doc.Save(fullPath); | ||
107 | } | ||
108 | catch (Exception e) | ||
109 | { | ||
110 | // e.Message will be something like: "Access to the path 'fullPath' is denied." | ||
111 | this.Log.LogMessage(MessageImportance.High, "Unable to save generated file to '{0}'. {1}", fullPath, e.Message); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | return true; | ||
116 | } | ||
117 | } | ||
118 | } | ||
diff --git a/src/WixToolset.BuildTasks/ReplaceString.cs b/src/WixToolset.BuildTasks/ReplaceString.cs new file mode 100644 index 00000000..e5041923 --- /dev/null +++ b/src/WixToolset.BuildTasks/ReplaceString.cs | |||
@@ -0,0 +1,54 @@ | |||
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 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/ResolveWixReferences.cs b/src/WixToolset.BuildTasks/ResolveWixReferences.cs new file mode 100644 index 00000000..9b8cfe6f --- /dev/null +++ b/src/WixToolset.BuildTasks/ResolveWixReferences.cs | |||
@@ -0,0 +1,212 @@ | |||
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.Collections.Generic; | ||
7 | using Microsoft.Build.Utilities; | ||
8 | using Microsoft.Build.Framework; | ||
9 | using System.IO; | ||
10 | |||
11 | /// <summary> | ||
12 | /// This task searches for paths to references using the order specified in SearchPaths. | ||
13 | /// </summary> | ||
14 | public class ResolveWixReferences : Task | ||
15 | { | ||
16 | /// <summary> | ||
17 | /// Token value used in SearchPaths to indicate that the item's HintPath metadata should | ||
18 | /// be searched as a full file path to resolve the reference. | ||
19 | /// Must match wix.targets, case sensitive. | ||
20 | /// </summary> | ||
21 | private const string HintPathToken = "{HintPathFromItem}"; | ||
22 | |||
23 | /// <summary> | ||
24 | /// Token value used in SearchPaths to indicate that the item's Identity should | ||
25 | /// be searched as a full file path to resolve the reference. | ||
26 | /// Must match wix.targets, case sensitive. | ||
27 | /// </summary> | ||
28 | private const string RawFileNameToken = "{RawFileName}"; | ||
29 | |||
30 | /// <summary> | ||
31 | /// The list of references to resolve. | ||
32 | /// </summary> | ||
33 | [Required] | ||
34 | public ITaskItem[] WixReferences | ||
35 | { | ||
36 | get; | ||
37 | set; | ||
38 | } | ||
39 | |||
40 | /// <summary> | ||
41 | /// The directories or special locations that are searched to find the files | ||
42 | /// on disk that represent the references. The order in which the search paths are listed | ||
43 | /// is important. For each reference, the list of paths is searched from left to right. | ||
44 | /// When a file that represents the reference is found, that search stops and the search | ||
45 | /// for the next reference starts. | ||
46 | /// | ||
47 | /// This parameter accepts the following types of values: | ||
48 | /// A directory path. | ||
49 | /// {HintPathFromItem}: Specifies that the task will examine the HintPath metadata | ||
50 | /// of the base item. | ||
51 | /// TODO : {CandidateAssemblyFiles}: Specifies that the task will examine the files | ||
52 | /// passed in through the CandidateAssemblyFiles parameter. | ||
53 | /// TODO : {Registry:_AssemblyFoldersBase_, _RuntimeVersion_, _AssemblyFoldersSuffix_}: | ||
54 | /// TODO : {AssemblyFolders}: Specifies the task will use the Visual Studio.NET 2003 | ||
55 | /// finding-assemblies-from-registry scheme. | ||
56 | /// TODO : {GAC}: Specifies the task will search in the GAC. | ||
57 | /// {RawFileName}: Specifies the task will consider the Include value of the item to be | ||
58 | /// an exact path and file name. | ||
59 | /// </summary> | ||
60 | public string[] SearchPaths | ||
61 | { | ||
62 | get; | ||
63 | set; | ||
64 | } | ||
65 | |||
66 | /// <summary> | ||
67 | /// The filename extension(s) to be checked when searching. | ||
68 | /// </summary> | ||
69 | public string[] SearchFilenameExtensions | ||
70 | { | ||
71 | get; | ||
72 | set; | ||
73 | } | ||
74 | |||
75 | /// <summary> | ||
76 | /// Output items that contain the same metadata as input references and have been resolved to full paths. | ||
77 | /// </summary> | ||
78 | [Output] | ||
79 | public ITaskItem[] ResolvedWixReferences | ||
80 | { | ||
81 | get; | ||
82 | private set; | ||
83 | } | ||
84 | |||
85 | /// <summary> | ||
86 | /// Resolves reference paths by searching for referenced items using the specified SearchPaths. | ||
87 | /// </summary> | ||
88 | /// <returns>True on success, or throws an exception on failure.</returns> | ||
89 | public override bool Execute() | ||
90 | { | ||
91 | List<ITaskItem> resolvedReferences = new List<ITaskItem>(); | ||
92 | |||
93 | foreach (ITaskItem reference in this.WixReferences) | ||
94 | { | ||
95 | ITaskItem resolvedReference = ResolveWixReferences.ResolveReference(reference, this.SearchPaths, this.SearchFilenameExtensions, this.Log); | ||
96 | |||
97 | this.Log.LogMessage(MessageImportance.Low, "Resolved path {0}", resolvedReference.ItemSpec); | ||
98 | resolvedReferences.Add(resolvedReference); | ||
99 | } | ||
100 | |||
101 | this.ResolvedWixReferences = resolvedReferences.ToArray(); | ||
102 | return true; | ||
103 | } | ||
104 | |||
105 | /// <summary> | ||
106 | /// Resolves a single reference item by searcheing for referenced items using the specified SearchPaths. | ||
107 | /// This method is made public so the resolution logic can be reused by other tasks. | ||
108 | /// </summary> | ||
109 | /// <param name="reference">The referenced item.</param> | ||
110 | /// <param name="searchPaths">The paths to search.</param> | ||
111 | /// <param name="searchFilenameExtensions">Filename extensions to check.</param> | ||
112 | /// <param name="log">Logging helper.</param> | ||
113 | /// <returns>The resolved reference item, or the original reference if it could not be resolved.</returns> | ||
114 | public static ITaskItem ResolveReference(ITaskItem reference, string[] searchPaths, string[] searchFilenameExtensions, TaskLoggingHelper log) | ||
115 | { | ||
116 | if (reference == null) | ||
117 | { | ||
118 | throw new ArgumentNullException("reference"); | ||
119 | } | ||
120 | |||
121 | if (searchPaths == null) | ||
122 | { | ||
123 | // Nothing to search, so just return the original reference item. | ||
124 | return reference; | ||
125 | } | ||
126 | |||
127 | if (searchFilenameExtensions == null) | ||
128 | { | ||
129 | searchFilenameExtensions = new string[] { }; | ||
130 | } | ||
131 | |||
132 | // Copy all the metadata from the source | ||
133 | TaskItem resolvedReference = new TaskItem(reference); | ||
134 | log.LogMessage(MessageImportance.Low, "WixReference: {0}", reference.ItemSpec); | ||
135 | |||
136 | // Now find the resolved path based on our order of precedence | ||
137 | foreach (string searchPath in searchPaths) | ||
138 | { | ||
139 | log.LogMessage(MessageImportance.Low, "Trying {0}", searchPath); | ||
140 | if (searchPath.Equals(HintPathToken, StringComparison.Ordinal)) | ||
141 | { | ||
142 | string path = reference.GetMetadata("HintPath"); | ||
143 | log.LogMessage(MessageImportance.Low, "Trying path {0}", path); | ||
144 | if (File.Exists(path)) | ||
145 | { | ||
146 | resolvedReference.ItemSpec = path; | ||
147 | break; | ||
148 | } | ||
149 | } | ||
150 | else if (searchPath.Equals(RawFileNameToken, StringComparison.Ordinal)) | ||
151 | { | ||
152 | log.LogMessage(MessageImportance.Low, "Trying path {0}", resolvedReference.ItemSpec); | ||
153 | if (File.Exists(resolvedReference.ItemSpec)) | ||
154 | { | ||
155 | break; | ||
156 | } | ||
157 | |||
158 | if (ResolveWixReferences.ResolveFilenameExtensions(resolvedReference, | ||
159 | resolvedReference.ItemSpec, searchFilenameExtensions, log)) | ||
160 | { | ||
161 | break; | ||
162 | } | ||
163 | } | ||
164 | else | ||
165 | { | ||
166 | string path = Path.Combine(searchPath, Path.GetFileName(reference.ItemSpec)); | ||
167 | log.LogMessage(MessageImportance.Low, "Trying path {0}", path); | ||
168 | if (File.Exists(path)) | ||
169 | { | ||
170 | resolvedReference.ItemSpec = path; | ||
171 | break; | ||
172 | } | ||
173 | |||
174 | if (ResolveWixReferences.ResolveFilenameExtensions(resolvedReference, | ||
175 | path, searchFilenameExtensions, log)) | ||
176 | { | ||
177 | break; | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | |||
182 | // Normalize the item path | ||
183 | resolvedReference.ItemSpec = resolvedReference.GetMetadata("FullPath"); | ||
184 | |||
185 | return resolvedReference; | ||
186 | } | ||
187 | |||
188 | /// <summary> | ||
189 | /// Helper method for checking filename extensions when resolving references. | ||
190 | /// </summary> | ||
191 | /// <param name="reference">The reference being resolved.</param> | ||
192 | /// <param name="basePath">Full filename path without extension.</param> | ||
193 | /// <param name="filenameExtensions">Filename extensions to check.</param> | ||
194 | /// <param name="log">Logging helper.</param> | ||
195 | /// <returns>True if the item was resolved, else false.</returns> | ||
196 | private static bool ResolveFilenameExtensions(ITaskItem reference, string basePath, string[] filenameExtensions, TaskLoggingHelper log) | ||
197 | { | ||
198 | foreach (string filenameExtension in filenameExtensions) | ||
199 | { | ||
200 | string path = basePath + filenameExtension; | ||
201 | log.LogMessage(MessageImportance.Low, "Trying path {0}", path); | ||
202 | if (File.Exists(path)) | ||
203 | { | ||
204 | reference.ItemSpec = path; | ||
205 | return true; | ||
206 | } | ||
207 | } | ||
208 | |||
209 | return false; | ||
210 | } | ||
211 | } | ||
212 | } | ||
diff --git a/src/WixToolset.BuildTasks/TaskBase.cs b/src/WixToolset.BuildTasks/TaskBase.cs new file mode 100644 index 00000000..3d58fc06 --- /dev/null +++ b/src/WixToolset.BuildTasks/TaskBase.cs | |||
@@ -0,0 +1,65 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolset.BuildTasks | ||
4 | { | ||
5 | using Microsoft.Build.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 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 | } | ||
diff --git a/src/WixToolset.BuildTasks/WixAssignCulture.cs b/src/WixToolset.BuildTasks/WixAssignCulture.cs new file mode 100644 index 00000000..7a03dc47 --- /dev/null +++ b/src/WixToolset.BuildTasks/WixAssignCulture.cs | |||
@@ -0,0 +1,231 @@ | |||
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.Collections.Generic; | ||
7 | using System.Diagnostics; | ||
8 | using System.IO; | ||
9 | using System.Xml; | ||
10 | using Microsoft.Build.Framework; | ||
11 | using Microsoft.Build.Utilities; | ||
12 | |||
13 | /// <summary> | ||
14 | /// This task assigns Culture metadata to files based on the value of the Culture attribute on the | ||
15 | /// WixLocalization element inside the file. | ||
16 | /// </summary> | ||
17 | public class WixAssignCulture : Task | ||
18 | { | ||
19 | private const string CultureAttributeName = "Culture"; | ||
20 | private const string OutputFolderMetadataName = "OutputFolder"; | ||
21 | private const string InvariantCultureIdentifier = "neutral"; | ||
22 | private const string NullCultureIdentifier = "null"; | ||
23 | |||
24 | /// <summary> | ||
25 | /// The list of cultures to build. Cultures are specified in the following form: | ||
26 | /// primary culture,first fallback culture, second fallback culture;... | ||
27 | /// Culture groups are seperated by semi-colons | ||
28 | /// Culture precedence within a culture group is evaluated from left to right where fallback cultures are | ||
29 | /// separated with commas. | ||
30 | /// The first (primary) culture in a culture group will be used as the output sub-folder. | ||
31 | /// </summary> | ||
32 | public string Cultures { get; set; } | ||
33 | |||
34 | /// <summary> | ||
35 | /// The list of files to apply culture information to. | ||
36 | /// </summary> | ||
37 | [Required] | ||
38 | public ITaskItem[] Files | ||
39 | { | ||
40 | get; | ||
41 | set; | ||
42 | } | ||
43 | |||
44 | /// <summary> | ||
45 | /// The files that had culture information applied | ||
46 | /// </summary> | ||
47 | [Output] | ||
48 | public ITaskItem[] CultureGroups | ||
49 | { | ||
50 | get; | ||
51 | private set; | ||
52 | } | ||
53 | |||
54 | /// <summary> | ||
55 | /// Applies culture information to the files specified by the Files property. | ||
56 | /// This task intentionally does not validate that strings are valid Cultures so that we can support | ||
57 | /// psuedo-loc. | ||
58 | /// </summary> | ||
59 | /// <returns>True upon completion of the task execution.</returns> | ||
60 | public override bool Execute() | ||
61 | { | ||
62 | // First, process the culture group list the user specified in the cultures property | ||
63 | List<CultureGroup> cultureGroups = new List<CultureGroup>(); | ||
64 | |||
65 | if (!String.IsNullOrEmpty(this.Cultures)) | ||
66 | { | ||
67 | // Get rid of extra quotes | ||
68 | this.Cultures = this.Cultures.Trim('\"'); | ||
69 | |||
70 | foreach (string cultureGroupString in this.Cultures.Split(';')) | ||
71 | { | ||
72 | if (0 == cultureGroupString.Length) | ||
73 | { | ||
74 | // MSBuild v2.0.50727 cannnot handle "" items | ||
75 | // for the invariant culture we require the neutral keyword | ||
76 | continue; | ||
77 | } | ||
78 | CultureGroup cultureGroup = new CultureGroup(cultureGroupString); | ||
79 | cultureGroups.Add(cultureGroup); | ||
80 | } | ||
81 | } | ||
82 | else | ||
83 | { | ||
84 | // Only process the EmbeddedResource items if cultures was unspecified | ||
85 | foreach (ITaskItem file in this.Files) | ||
86 | { | ||
87 | // Ignore non-wxls | ||
88 | if (!String.Equals(file.GetMetadata("Extension"), ".wxl", StringComparison.OrdinalIgnoreCase)) | ||
89 | { | ||
90 | Log.LogError("Unable to retrieve the culture for EmbeddedResource {0}. The file type is not supported.", file.ItemSpec); | ||
91 | return false; | ||
92 | } | ||
93 | XmlDocument wxlFile = new XmlDocument(); | ||
94 | |||
95 | try | ||
96 | { | ||
97 | wxlFile.Load(file.ItemSpec); | ||
98 | } | ||
99 | catch (FileNotFoundException) | ||
100 | { | ||
101 | Log.LogError("Unable to retrieve the culture for EmbeddedResource {0}. The file was not found.", file.ItemSpec); | ||
102 | return false; | ||
103 | } | ||
104 | catch (Exception e) | ||
105 | { | ||
106 | Log.LogError("Unable to retrieve the culture for EmbeddedResource {0}: {1}", file.ItemSpec, e.Message); | ||
107 | return false; | ||
108 | } | ||
109 | |||
110 | // Take the culture value and try using it to create a culture. | ||
111 | XmlAttribute cultureAttr = wxlFile.DocumentElement.Attributes[WixAssignCulture.CultureAttributeName]; | ||
112 | string wxlCulture = null == cultureAttr ? String.Empty : cultureAttr.Value; | ||
113 | if (0 == wxlCulture.Length) | ||
114 | { | ||
115 | // We use a keyword for the invariant culture because MSBuild v2.0.50727 cannnot handle "" items | ||
116 | wxlCulture = InvariantCultureIdentifier; | ||
117 | } | ||
118 | |||
119 | // We found the culture for the WXL, we now need to determine if it maps to a culture group specified | ||
120 | // in the Cultures property or if we need to create a new one. | ||
121 | Log.LogMessage(MessageImportance.Low, "Culture \"{0}\" from EmbeddedResource {1}.", wxlCulture, file.ItemSpec); | ||
122 | |||
123 | bool cultureGroupExists = false; | ||
124 | foreach (CultureGroup cultureGroup in cultureGroups) | ||
125 | { | ||
126 | foreach (string culture in cultureGroup.Cultures) | ||
127 | { | ||
128 | if (String.Equals(wxlCulture, culture, StringComparison.OrdinalIgnoreCase)) | ||
129 | { | ||
130 | cultureGroupExists = true; | ||
131 | break; | ||
132 | } | ||
133 | } | ||
134 | } | ||
135 | |||
136 | // The WXL didn't match a culture group we already have so create a new one. | ||
137 | if (!cultureGroupExists) | ||
138 | { | ||
139 | cultureGroups.Add(new CultureGroup(wxlCulture)); | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | |||
144 | // If we didn't create any culture groups the culture was unspecificed and no WXLs were included | ||
145 | // Build an unlocalized target in the output folder | ||
146 | if (cultureGroups.Count == 0) | ||
147 | { | ||
148 | cultureGroups.Add(new CultureGroup()); | ||
149 | } | ||
150 | |||
151 | List<TaskItem> cultureGroupItems = new List<TaskItem>(); | ||
152 | |||
153 | if (1 == cultureGroups.Count && 0 == this.Files.Length) | ||
154 | { | ||
155 | // Maintain old behavior, if only one culturegroup is specified and no WXL, output to the default folder | ||
156 | TaskItem cultureGroupItem = new TaskItem(cultureGroups[0].ToString()); | ||
157 | cultureGroupItem.SetMetadata(OutputFolderMetadataName, CultureGroup.DefaultFolder); | ||
158 | cultureGroupItems.Add(cultureGroupItem); | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | foreach (CultureGroup cultureGroup in cultureGroups) | ||
163 | { | ||
164 | TaskItem cultureGroupItem = new TaskItem(cultureGroup.ToString()); | ||
165 | cultureGroupItem.SetMetadata(OutputFolderMetadataName, cultureGroup.OutputFolder); | ||
166 | cultureGroupItems.Add(cultureGroupItem); | ||
167 | Log.LogMessage("Culture: {0}", cultureGroup.ToString()); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | this.CultureGroups = cultureGroupItems.ToArray(); | ||
172 | return true; | ||
173 | } | ||
174 | |||
175 | private class CultureGroup | ||
176 | { | ||
177 | private List<string> cultures = new List<string>(); | ||
178 | |||
179 | /// <summary> | ||
180 | /// TargetPath already has a '\', do not double it! | ||
181 | /// </summary> | ||
182 | public const string DefaultFolder = ""; | ||
183 | |||
184 | /// <summary> | ||
185 | /// Initialize a null culture group | ||
186 | /// </summary> | ||
187 | public CultureGroup() | ||
188 | { | ||
189 | } | ||
190 | |||
191 | public CultureGroup(string cultureGroupString) | ||
192 | { | ||
193 | Debug.Assert(!String.IsNullOrEmpty(cultureGroupString)); | ||
194 | foreach (string cultureString in cultureGroupString.Split(',')) | ||
195 | { | ||
196 | this.cultures.Add(cultureString); | ||
197 | } | ||
198 | } | ||
199 | |||
200 | public List<string> Cultures { get { return cultures; } } | ||
201 | |||
202 | public string OutputFolder | ||
203 | { | ||
204 | get | ||
205 | { | ||
206 | string result = DefaultFolder; | ||
207 | if (this.Cultures.Count > 0 && | ||
208 | !this.Cultures[0].Equals(InvariantCultureIdentifier, StringComparison.OrdinalIgnoreCase)) | ||
209 | { | ||
210 | result = this.Cultures[0] + "\\"; | ||
211 | } | ||
212 | |||
213 | return result; | ||
214 | } | ||
215 | } | ||
216 | |||
217 | public override string ToString() | ||
218 | { | ||
219 | if (this.Cultures.Count > 0) | ||
220 | { | ||
221 | return String.Join(",", this.Cultures.ToArray()); | ||
222 | } | ||
223 | |||
224 | // We use a keyword for a null culture because MSBuild cannnot handle "" items | ||
225 | // Null is different from neutral. For neutral we still want to do WXL | ||
226 | // filtering in Light. | ||
227 | return NullCultureIdentifier; | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | } | ||
diff --git a/src/WixToolset.BuildTasks/WixCommandLineBuilder.cs b/src/WixToolset.BuildTasks/WixCommandLineBuilder.cs new file mode 100644 index 00000000..9a6a005d --- /dev/null +++ b/src/WixToolset.BuildTasks/WixCommandLineBuilder.cs | |||
@@ -0,0 +1,180 @@ | |||
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 | /// Helper class for appending the command line arguments. | ||
16 | /// </summary> | ||
17 | public class WixCommandLineBuilder : CommandLineBuilder | ||
18 | { | ||
19 | internal const int Unspecified = -1; | ||
20 | |||
21 | /// <summary> | ||
22 | /// Append a switch to the command line if the value has been specified. | ||
23 | /// </summary> | ||
24 | /// <param name="switchName">Switch to append.</param> | ||
25 | /// <param name="value">Value specified by the user.</param> | ||
26 | public void AppendIfSpecified(string switchName, int value) | ||
27 | { | ||
28 | if (value != Unspecified) | ||
29 | { | ||
30 | this.AppendSwitchIfNotNull(switchName, value.ToString(CultureInfo.InvariantCulture)); | ||
31 | } | ||
32 | } | ||
33 | |||
34 | /// <summary> | ||
35 | /// Append a switch to the command line if the condition is true. | ||
36 | /// </summary> | ||
37 | /// <param name="switchName">Switch to append.</param> | ||
38 | /// <param name="condition">Condition specified by the user.</param> | ||
39 | public void AppendIfTrue(string switchName, bool condition) | ||
40 | { | ||
41 | if (condition) | ||
42 | { | ||
43 | this.AppendSwitch(switchName); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | /// <summary> | ||
48 | /// Append a switch to the command line if any values in the array have been specified. | ||
49 | /// </summary> | ||
50 | /// <param name="switchName">Switch to append.</param> | ||
51 | /// <param name="values">Values specified by the user.</param> | ||
52 | public void AppendArrayIfNotNull(string switchName, ITaskItem[] values) | ||
53 | { | ||
54 | if (values != null) | ||
55 | { | ||
56 | foreach (ITaskItem value in values) | ||
57 | { | ||
58 | this.AppendSwitchIfNotNull(switchName, value); | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | |||
63 | /// <summary> | ||
64 | /// Append a switch to the command line if any values in the array have been specified. | ||
65 | /// </summary> | ||
66 | /// <param name="switchName">Switch to append.</param> | ||
67 | /// <param name="values">Values specified by the user.</param> | ||
68 | public void AppendArrayIfNotNull(string switchName, string[] values) | ||
69 | { | ||
70 | if (values != null) | ||
71 | { | ||
72 | foreach (string value in values) | ||
73 | { | ||
74 | this.AppendSwitchIfNotNull(switchName, value); | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | |||
79 | /// <summary> | ||
80 | /// Build the extensions argument. Each extension is searched in the current folder, user defined search | ||
81 | /// directories (ReferencePath), HintPath, and under Wix Extension Directory in that order. | ||
82 | /// The order of precednce is based off of that described in Microsoft.Common.Targets's SearchPaths | ||
83 | /// property for the ResolveAssemblyReferences task. | ||
84 | /// </summary> | ||
85 | /// <param name="extensions">The list of extensions to include.</param> | ||
86 | /// <param name="wixExtensionDirectory">Evaluated default folder for Wix Extensions</param> | ||
87 | /// <param name="referencePaths">User defined reference directories to search in</param> | ||
88 | public void AppendExtensions(ITaskItem[] extensions, string wixExtensionDirectory, string [] referencePaths) | ||
89 | { | ||
90 | if (extensions == null) | ||
91 | { | ||
92 | return; | ||
93 | } | ||
94 | |||
95 | string resolvedPath; | ||
96 | |||
97 | foreach (ITaskItem extension in extensions) | ||
98 | { | ||
99 | string className = extension.GetMetadata("Class"); | ||
100 | |||
101 | string fileName = Path.GetFileName(extension.ItemSpec); | ||
102 | |||
103 | if (Path.GetExtension(fileName).Length == 0) | ||
104 | { | ||
105 | fileName += ".dll"; | ||
106 | } | ||
107 | |||
108 | // First try reference paths | ||
109 | resolvedPath = FileSearchHelperMethods.SearchFilePaths(referencePaths, fileName); | ||
110 | |||
111 | if (String.IsNullOrEmpty(resolvedPath)) | ||
112 | { | ||
113 | // Now try HintPath | ||
114 | resolvedPath = extension.GetMetadata("HintPath"); | ||
115 | |||
116 | if (!File.Exists(resolvedPath)) | ||
117 | { | ||
118 | // Now try the item itself | ||
119 | resolvedPath = extension.ItemSpec; | ||
120 | |||
121 | if (Path.GetExtension(resolvedPath).Length == 0) | ||
122 | { | ||
123 | resolvedPath += ".dll"; | ||
124 | } | ||
125 | |||
126 | if (!File.Exists(resolvedPath)) | ||
127 | { | ||
128 | if (!String.IsNullOrEmpty(wixExtensionDirectory)) | ||
129 | { | ||
130 | // Now try the extension directory | ||
131 | resolvedPath = Path.Combine(wixExtensionDirectory, Path.GetFileName(resolvedPath)); | ||
132 | } | ||
133 | |||
134 | if (!File.Exists(resolvedPath)) | ||
135 | { | ||
136 | // Extesnion wasn't found, just set it to the extension name passed in | ||
137 | resolvedPath = extension.ItemSpec; | ||
138 | } | ||
139 | } | ||
140 | } | ||
141 | } | ||
142 | |||
143 | if (String.IsNullOrEmpty(className)) | ||
144 | { | ||
145 | this.AppendSwitchIfNotNull("-ext ", resolvedPath); | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | this.AppendSwitchIfNotNull("-ext ", className + ", " + resolvedPath); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | |||
154 | /// <summary> | ||
155 | /// Append arbitrary text to the command-line if specified. | ||
156 | /// </summary> | ||
157 | /// <param name="textToAppend">Text to append.</param> | ||
158 | public void AppendTextIfNotNull(string textToAppend) | ||
159 | { | ||
160 | if (!String.IsNullOrEmpty(textToAppend)) | ||
161 | { | ||
162 | this.AppendSpaceIfNotEmpty(); | ||
163 | this.AppendTextUnquoted(textToAppend); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | /// <summary> | ||
168 | /// Append arbitrary text to the command-line if specified. | ||
169 | /// </summary> | ||
170 | /// <param name="textToAppend">Text to append.</param> | ||
171 | public void AppendTextIfNotWhitespace(string textToAppend) | ||
172 | { | ||
173 | if (!String.IsNullOrWhiteSpace(textToAppend)) | ||
174 | { | ||
175 | this.AppendSpaceIfNotEmpty(); | ||
176 | this.AppendTextUnquoted(textToAppend); | ||
177 | } | ||
178 | } | ||
179 | } | ||
180 | } | ||
diff --git a/src/WixToolset.BuildTasks/WixToolTask.cs b/src/WixToolset.BuildTasks/WixToolTask.cs new file mode 100644 index 00000000..2e5e8705 --- /dev/null +++ b/src/WixToolset.BuildTasks/WixToolTask.cs | |||
@@ -0,0 +1,406 @@ | |||
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.Collections.Generic; | ||
7 | using System.Diagnostics; | ||
8 | using System.Diagnostics.CodeAnalysis; | ||
9 | using System.Globalization; | ||
10 | using System.IO; | ||
11 | using System.Reflection; | ||
12 | using System.Text; | ||
13 | using System.Threading; | ||
14 | |||
15 | using Microsoft.Build.Framework; | ||
16 | using Microsoft.Build.Utilities; | ||
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 | Util.RunningInMsBuild = true; | ||
188 | |||
189 | WixToolTaskLogger logger = new WixToolTaskLogger(this.messageQueue, this.messagesAvailable); | ||
190 | TextWriter saveConsoleOut = Console.Out; | ||
191 | TextWriter saveConsoleError = Console.Error; | ||
192 | Console.SetOut(logger); | ||
193 | Console.SetError(logger); | ||
194 | |||
195 | string responseFile = null; | ||
196 | try | ||
197 | { | ||
198 | string responseFileSwitch; | ||
199 | responseFile = this.GetTemporaryResponseFile(responseFileCommands, out responseFileSwitch); | ||
200 | if (!String.IsNullOrEmpty(responseFileSwitch)) | ||
201 | { | ||
202 | commandLineCommands = commandLineCommands + " " + responseFileSwitch; | ||
203 | } | ||
204 | |||
205 | string[] arguments = CommandLineResponseFile.ParseArgumentsToArray(commandLineCommands); | ||
206 | |||
207 | Thread toolThread = new Thread(new ParameterizedThreadStart(this.ExecuteToolThread)); | ||
208 | toolThread.Start(new object[] { pathToTool, arguments }); | ||
209 | |||
210 | this.HandleToolMessages(); | ||
211 | |||
212 | if (this.exitCode == 0 && this.Log.HasLoggedErrors) | ||
213 | { | ||
214 | this.exitCode = -1; | ||
215 | } | ||
216 | |||
217 | return this.exitCode; | ||
218 | } | ||
219 | finally | ||
220 | { | ||
221 | if (responseFile != null) | ||
222 | { | ||
223 | File.Delete(responseFile); | ||
224 | } | ||
225 | |||
226 | Console.SetOut(saveConsoleOut); | ||
227 | Console.SetError(saveConsoleError); | ||
228 | } | ||
229 | } | ||
230 | |||
231 | /// <summary> | ||
232 | /// Called by a new thread to execute the tool in that thread. | ||
233 | /// </summary> | ||
234 | /// <param name="parameters">Tool path and arguments array.</param> | ||
235 | private void ExecuteToolThread(object parameters) | ||
236 | { | ||
237 | try | ||
238 | { | ||
239 | object[] pathAndArguments = (object[])parameters; | ||
240 | Assembly toolAssembly = Assembly.LoadFrom((string)pathAndArguments[0]); | ||
241 | this.exitCode = (int)toolAssembly.EntryPoint.Invoke(null, new object[] { pathAndArguments[1] }); | ||
242 | } | ||
243 | catch (FileNotFoundException fnfe) | ||
244 | { | ||
245 | Log.LogError("Unable to load tool from path {0}. Consider setting the ToolPath parameter to $(WixToolPath).", fnfe.FileName); | ||
246 | this.exitCode = -1; | ||
247 | } | ||
248 | catch (Exception ex) | ||
249 | { | ||
250 | this.exitCode = -1; | ||
251 | this.LogEventsFromTextOutput(ex.Message, MessageImportance.High); | ||
252 | foreach (string stackTraceLine in ex.StackTrace.Split('\n')) | ||
253 | { | ||
254 | this.LogEventsFromTextOutput(stackTraceLine.TrimEnd(), MessageImportance.High); | ||
255 | } | ||
256 | |||
257 | throw; | ||
258 | } | ||
259 | finally | ||
260 | { | ||
261 | this.toolExited.Set(); | ||
262 | } | ||
263 | } | ||
264 | |||
265 | /// <summary> | ||
266 | /// Waits for messages from the tool thread and sends them to the MSBuild logger on the original thread. | ||
267 | /// Returns when the tool thread exits. | ||
268 | /// </summary> | ||
269 | private void HandleToolMessages() | ||
270 | { | ||
271 | WaitHandle[] waitHandles = new WaitHandle[] { this.messagesAvailable, this.toolExited }; | ||
272 | while (WaitHandle.WaitAny(waitHandles) == 0) | ||
273 | { | ||
274 | lock (this.messageQueue) | ||
275 | { | ||
276 | while (this.messageQueue.Count > 0) | ||
277 | { | ||
278 | this.LogEventsFromTextOutput(messageQueue.Dequeue(), MessageImportance.Normal); | ||
279 | } | ||
280 | |||
281 | this.messagesAvailable.Reset(); | ||
282 | } | ||
283 | } | ||
284 | } | ||
285 | |||
286 | /// <summary> | ||
287 | /// Creates a temporary response file for tool execution. | ||
288 | /// </summary> | ||
289 | /// <returns>Path to the response file.</returns> | ||
290 | /// <remarks> | ||
291 | /// The temporary file should be deleted after the tool execution is finished. | ||
292 | /// </remarks> | ||
293 | private string GetTemporaryResponseFile(string responseFileCommands, out string responseFileSwitch) | ||
294 | { | ||
295 | string responseFile = null; | ||
296 | responseFileSwitch = null; | ||
297 | |||
298 | if (!String.IsNullOrEmpty(responseFileCommands)) | ||
299 | { | ||
300 | responseFile = Path.GetTempFileName(); | ||
301 | using (StreamWriter writer = new StreamWriter(responseFile, false, this.ResponseFileEncoding)) | ||
302 | { | ||
303 | writer.Write(responseFileCommands); | ||
304 | } | ||
305 | responseFileSwitch = this.GetResponseFileSwitch(responseFile); | ||
306 | } | ||
307 | return responseFile; | ||
308 | } | ||
309 | |||
310 | /// <summary> | ||
311 | /// Cycles thru each task to find correct path of the file in question. | ||
312 | /// Looks at item spec, hintpath and then in user defined Reference Paths | ||
313 | /// </summary> | ||
314 | /// <param name="tasks">Input task array</param> | ||
315 | /// <param name="referencePaths">SemiColon delimited directories to search</param> | ||
316 | /// <returns>List of task item file paths</returns> | ||
317 | [SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")] | ||
318 | protected static List<string> AdjustFilePaths(ITaskItem[] tasks, string[] referencePaths) | ||
319 | { | ||
320 | List<string> sourceFilePaths = new List<string>(); | ||
321 | |||
322 | if (tasks == null) | ||
323 | { | ||
324 | return sourceFilePaths; | ||
325 | } | ||
326 | |||
327 | foreach (ITaskItem task in tasks) | ||
328 | { | ||
329 | string filePath = task.ItemSpec; | ||
330 | if (!File.Exists(filePath)) | ||
331 | { | ||
332 | filePath = task.GetMetadata("HintPath"); | ||
333 | if (!File.Exists(filePath)) | ||
334 | { | ||
335 | string searchPath = FileSearchHelperMethods.SearchFilePaths(referencePaths, filePath); | ||
336 | if (!String.IsNullOrEmpty(searchPath)) | ||
337 | { | ||
338 | filePath = searchPath; | ||
339 | } | ||
340 | } | ||
341 | } | ||
342 | sourceFilePaths.Add(filePath); | ||
343 | } | ||
344 | |||
345 | return sourceFilePaths; | ||
346 | } | ||
347 | |||
348 | /// <summary> | ||
349 | /// Used as a replacement for Console.Out to capture output from a tool | ||
350 | /// and redirect it to the MSBuild logging system. | ||
351 | /// </summary> | ||
352 | private class WixToolTaskLogger : TextWriter | ||
353 | { | ||
354 | private StringBuilder buffer; | ||
355 | private Queue<string> messageQueue; | ||
356 | private ManualResetEvent messagesAvailable; | ||
357 | |||
358 | /// <summary> | ||
359 | /// Creates a new logger that sends tool output to the tool task's log handler. | ||
360 | /// </summary> | ||
361 | public WixToolTaskLogger(Queue<string> messageQueue, ManualResetEvent messagesAvailable) : base(CultureInfo.CurrentCulture) | ||
362 | { | ||
363 | this.messageQueue = messageQueue; | ||
364 | this.messagesAvailable = messagesAvailable; | ||
365 | this.buffer = new StringBuilder(); | ||
366 | } | ||
367 | |||
368 | /// <summary> | ||
369 | /// Gets the encoding of the logger. | ||
370 | /// </summary> | ||
371 | public override Encoding Encoding | ||
372 | { | ||
373 | get { return Encoding.Unicode; } | ||
374 | } | ||
375 | |||
376 | /// <summary> | ||
377 | /// Redirects output to a buffer; watches for newlines and sends each line to the | ||
378 | /// MSBuild logging system. | ||
379 | /// </summary> | ||
380 | /// <param name="value">Character being written.</param> | ||
381 | /// <remarks>All other Write() variants eventually call into this one.</remarks> | ||
382 | public override void Write(char value) | ||
383 | { | ||
384 | lock (this.messageQueue) | ||
385 | { | ||
386 | if (value == '\n') | ||
387 | { | ||
388 | if (this.buffer.Length > 0 && this.buffer[this.buffer.Length - 1] == '\r') | ||
389 | { | ||
390 | this.buffer.Length = this.buffer.Length - 1; | ||
391 | } | ||
392 | |||
393 | this.messageQueue.Enqueue(this.buffer.ToString()); | ||
394 | this.messagesAvailable.Set(); | ||
395 | |||
396 | this.buffer.Length = 0; | ||
397 | } | ||
398 | else | ||
399 | { | ||
400 | this.buffer.Append(value); | ||
401 | } | ||
402 | } | ||
403 | } | ||
404 | } | ||
405 | } | ||
406 | } | ||
diff --git a/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj b/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj new file mode 100644 index 00000000..34a1a9f5 --- /dev/null +++ b/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj | |||
@@ -0,0 +1,38 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <!-- 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. --> | ||
3 | |||
4 | <Project Sdk="Microsoft.NET.Sdk"> | ||
5 | <PropertyGroup> | ||
6 | <TargetFramework>net462</TargetFramework> | ||
7 | <Description></Description> | ||
8 | <Title>WiX Toolset MSBuild Tasks</Title> | ||
9 | </PropertyGroup> | ||
10 | |||
11 | <PropertyGroup> | ||
12 | <!-- <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> --> | ||
13 | <NoWarn>NU1701</NoWarn> | ||
14 | </PropertyGroup> | ||
15 | |||
16 | <ItemGroup> | ||
17 | <Content Include="redirect.wix.targets" CopyToOutputDirectory="PreserveNewest" /> | ||
18 | <Content Include="redirect.wix.ca.targets" CopyToOutputDirectory="PreserveNewest" /> | ||
19 | <Content Include="wix.targets" CopyToOutputDirectory="PreserveNewest" /> | ||
20 | <Content Include="wix.ca.targets" CopyToOutputDirectory="PreserveNewest" /> | ||
21 | <Content Include="wix.harvest.targets" CopyToOutputDirectory="PreserveNewest" /> | ||
22 | <Content Include="wix.signing.targets" CopyToOutputDirectory="PreserveNewest" /> | ||
23 | </ItemGroup> | ||
24 | |||
25 | <ItemGroup> | ||
26 | <ProjectReference Include="..\WixToolset.Core\WixToolset.Core.csproj" /> | ||
27 | </ItemGroup> | ||
28 | |||
29 | <ItemGroup> | ||
30 | <PackageReference Include="WixToolset.Dtf.WindowsInstaller" Version="4.0.*" /> | ||
31 | </ItemGroup> | ||
32 | |||
33 | <ItemGroup> | ||
34 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.0.41" PrivateAssets="all" /> | ||
35 | <PackageReference Include="Microsoft.Build.Tasks.Core" Version="14.3" PrivateAssets="all" Condition="'$(TargetFramework)'=='net462' " /> | ||
36 | <PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.3.409" PrivateAssets="all" Condition="'$(TargetFramework)'=='netstandard2.0' " /> | ||
37 | </ItemGroup> | ||
38 | </Project> | ||
diff --git a/src/WixToolset.BuildTasks/heatdirectory.cs b/src/WixToolset.BuildTasks/heatdirectory.cs new file mode 100644 index 00000000..1d5f104a --- /dev/null +++ b/src/WixToolset.BuildTasks/heatdirectory.cs | |||
@@ -0,0 +1,103 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolset.BuildTasks | ||
4 | { | ||
5 | using Microsoft.Build.Framework; | ||
6 | |||
7 | public sealed class HeatDirectory : HeatTask | ||
8 | { | ||
9 | private string directory; | ||
10 | private bool keepEmptyDirectories; | ||
11 | private bool suppressCom; | ||
12 | private bool suppressRootDirectory; | ||
13 | private bool suppressRegistry; | ||
14 | private string template; | ||
15 | private string componentGroupName; | ||
16 | private string directoryRefId; | ||
17 | private string preprocessorVariable; | ||
18 | |||
19 | public string ComponentGroupName | ||
20 | { | ||
21 | get { return this.componentGroupName; } | ||
22 | set { this.componentGroupName = value; } | ||
23 | } | ||
24 | |||
25 | [Required] | ||
26 | public string Directory | ||
27 | { | ||
28 | get { return this.directory; } | ||
29 | set { this.directory = value; } | ||
30 | } | ||
31 | |||
32 | public string DirectoryRefId | ||
33 | { | ||
34 | get { return this.directoryRefId; } | ||
35 | set { this.directoryRefId = value; } | ||
36 | } | ||
37 | |||
38 | public bool KeepEmptyDirectories | ||
39 | { | ||
40 | get { return this.keepEmptyDirectories; } | ||
41 | set { this.keepEmptyDirectories = value; } | ||
42 | } | ||
43 | |||
44 | public string PreprocessorVariable | ||
45 | { | ||
46 | get { return this.preprocessorVariable; } | ||
47 | set { this.preprocessorVariable = value; } | ||
48 | } | ||
49 | |||
50 | public bool SuppressCom | ||
51 | { | ||
52 | get { return this.suppressCom; } | ||
53 | set { this.suppressCom = value; } | ||
54 | } | ||
55 | |||
56 | public bool SuppressRootDirectory | ||
57 | { | ||
58 | get { return this.suppressRootDirectory; } | ||
59 | set { this.suppressRootDirectory = value; } | ||
60 | } | ||
61 | |||
62 | public bool SuppressRegistry | ||
63 | { | ||
64 | get { return this.suppressRegistry; } | ||
65 | set { this.suppressRegistry = value; } | ||
66 | } | ||
67 | |||
68 | public string Template | ||
69 | { | ||
70 | get { return this.template; } | ||
71 | set { this.template = value; } | ||
72 | } | ||
73 | |||
74 | protected override string OperationName | ||
75 | { | ||
76 | get { return "dir"; } | ||
77 | } | ||
78 | |||
79 | /// <summary> | ||
80 | /// Generate the command line arguments to write to the response file from the properties. | ||
81 | /// </summary> | ||
82 | /// <returns>Command line string.</returns> | ||
83 | protected override string GenerateResponseFileCommands() | ||
84 | { | ||
85 | WixCommandLineBuilder commandLineBuilder = new WixCommandLineBuilder(); | ||
86 | |||
87 | commandLineBuilder.AppendSwitch(this.OperationName); | ||
88 | commandLineBuilder.AppendFileNameIfNotNull(this.Directory); | ||
89 | |||
90 | commandLineBuilder.AppendSwitchIfNotNull("-cg ", this.ComponentGroupName); | ||
91 | commandLineBuilder.AppendSwitchIfNotNull("-dr ", this.DirectoryRefId); | ||
92 | commandLineBuilder.AppendIfTrue("-ke", this.KeepEmptyDirectories); | ||
93 | commandLineBuilder.AppendIfTrue("-scom", this.SuppressCom); | ||
94 | commandLineBuilder.AppendIfTrue("-sreg", this.SuppressRegistry); | ||
95 | commandLineBuilder.AppendIfTrue("-srd", this.SuppressRootDirectory); | ||
96 | commandLineBuilder.AppendSwitchIfNotNull("-template ", this.Template); | ||
97 | commandLineBuilder.AppendSwitchIfNotNull("-var ", this.PreprocessorVariable); | ||
98 | |||
99 | base.BuildCommandLine(commandLineBuilder); | ||
100 | return commandLineBuilder.ToString(); | ||
101 | } | ||
102 | } | ||
103 | } | ||
diff --git a/src/WixToolset.BuildTasks/heatfile.cs b/src/WixToolset.BuildTasks/heatfile.cs new file mode 100644 index 00000000..69e11b88 --- /dev/null +++ b/src/WixToolset.BuildTasks/heatfile.cs | |||
@@ -0,0 +1,95 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolset.BuildTasks | ||
4 | { | ||
5 | using Microsoft.Build.Framework; | ||
6 | |||
7 | public sealed class HeatFile : HeatTask | ||
8 | { | ||
9 | private string file; | ||
10 | private bool suppressCom; | ||
11 | private bool suppressRegistry; | ||
12 | private bool suppressRootDirectory; | ||
13 | private string template; | ||
14 | private string componentGroupName; | ||
15 | private string directoryRefId; | ||
16 | private string preprocessorVariable; | ||
17 | |||
18 | public string ComponentGroupName | ||
19 | { | ||
20 | get { return this.componentGroupName; } | ||
21 | set { this.componentGroupName = value; } | ||
22 | } | ||
23 | |||
24 | public string DirectoryRefId | ||
25 | { | ||
26 | get { return this.directoryRefId; } | ||
27 | set { this.directoryRefId = value; } | ||
28 | } | ||
29 | |||
30 | [Required] | ||
31 | public string File | ||
32 | { | ||
33 | get { return this.file; } | ||
34 | set { this.file = value; } | ||
35 | } | ||
36 | |||
37 | public string PreprocessorVariable | ||
38 | { | ||
39 | get { return this.preprocessorVariable; } | ||
40 | set { this.preprocessorVariable = value; } | ||
41 | } | ||
42 | |||
43 | public bool SuppressCom | ||
44 | { | ||
45 | get { return this.suppressCom; } | ||
46 | set { this.suppressCom = value; } | ||
47 | } | ||
48 | |||
49 | public bool SuppressRegistry | ||
50 | { | ||
51 | get { return this.suppressRegistry; } | ||
52 | set { this.suppressRegistry = value; } | ||
53 | } | ||
54 | |||
55 | public bool SuppressRootDirectory | ||
56 | { | ||
57 | get { return this.suppressRootDirectory; } | ||
58 | set { this.suppressRootDirectory = value; } | ||
59 | } | ||
60 | |||
61 | public string Template | ||
62 | { | ||
63 | get { return this.template; } | ||
64 | set { this.template = value; } | ||
65 | } | ||
66 | |||
67 | protected override string OperationName | ||
68 | { | ||
69 | get { return "file"; } | ||
70 | } | ||
71 | |||
72 | /// <summary> | ||
73 | /// Generate the command line arguments to write to the response file from the properties. | ||
74 | /// </summary> | ||
75 | /// <returns>Command line string.</returns> | ||
76 | protected override string GenerateResponseFileCommands() | ||
77 | { | ||
78 | WixCommandLineBuilder commandLineBuilder = new WixCommandLineBuilder(); | ||
79 | |||
80 | commandLineBuilder.AppendSwitch(this.OperationName); | ||
81 | commandLineBuilder.AppendFileNameIfNotNull(this.File); | ||
82 | |||
83 | commandLineBuilder.AppendSwitchIfNotNull("-cg ", this.ComponentGroupName); | ||
84 | commandLineBuilder.AppendSwitchIfNotNull("-dr ", this.DirectoryRefId); | ||
85 | commandLineBuilder.AppendIfTrue("-scom", this.SuppressCom); | ||
86 | commandLineBuilder.AppendIfTrue("-srd", this.SuppressRootDirectory); | ||
87 | commandLineBuilder.AppendIfTrue("-sreg", this.SuppressRegistry); | ||
88 | commandLineBuilder.AppendSwitchIfNotNull("-template ", this.Template); | ||
89 | commandLineBuilder.AppendSwitchIfNotNull("-var ", this.PreprocessorVariable); | ||
90 | |||
91 | base.BuildCommandLine(commandLineBuilder); | ||
92 | return commandLineBuilder.ToString(); | ||
93 | } | ||
94 | } | ||
95 | } | ||
diff --git a/src/WixToolset.BuildTasks/heatproject.cs b/src/WixToolset.BuildTasks/heatproject.cs new file mode 100644 index 00000000..8620ffa3 --- /dev/null +++ b/src/WixToolset.BuildTasks/heatproject.cs | |||
@@ -0,0 +1,108 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolset.BuildTasks | ||
4 | { | ||
5 | using Microsoft.Build.Framework; | ||
6 | |||
7 | public sealed class HeatProject : HeatTask | ||
8 | { | ||
9 | private string configuration; | ||
10 | private string directoryIds; | ||
11 | private string generateType; | ||
12 | private bool generateWixVariables; | ||
13 | private string platform; | ||
14 | private string project; | ||
15 | private string projectName; | ||
16 | private string[] projectOutputGroups; | ||
17 | |||
18 | public string Configuration | ||
19 | { | ||
20 | get { return this.configuration; } | ||
21 | set { this.configuration = value; } | ||
22 | } | ||
23 | |||
24 | public string DirectoryIds | ||
25 | { | ||
26 | get { return this.directoryIds; } | ||
27 | set { this.directoryIds = value; } | ||
28 | } | ||
29 | |||
30 | public bool GenerateWixVariables | ||
31 | { | ||
32 | get { return this.generateWixVariables; } | ||
33 | set { this.generateWixVariables = value; } | ||
34 | } | ||
35 | |||
36 | public string GenerateType | ||
37 | { | ||
38 | get { return this.generateType; } | ||
39 | set { this.generateType = value; } | ||
40 | } | ||
41 | |||
42 | public string Platform | ||
43 | { | ||
44 | get { return this.platform; } | ||
45 | set { this.platform = value; } | ||
46 | } | ||
47 | |||
48 | [Required] | ||
49 | public string Project | ||
50 | { | ||
51 | get { return this.project; } | ||
52 | set { this.project = value; } | ||
53 | } | ||
54 | |||
55 | public string ProjectName | ||
56 | { | ||
57 | get { return this.projectName; } | ||
58 | set { this.projectName = value; } | ||
59 | } | ||
60 | |||
61 | public string[] ProjectOutputGroups | ||
62 | { | ||
63 | get | ||
64 | { | ||
65 | return this.projectOutputGroups; | ||
66 | } | ||
67 | set | ||
68 | { | ||
69 | this.projectOutputGroups = value; | ||
70 | |||
71 | // If it's just one string and it contains semicolons, let's | ||
72 | // split it into separate items. | ||
73 | if (this.projectOutputGroups.Length == 1) | ||
74 | { | ||
75 | this.projectOutputGroups = this.projectOutputGroups[0].Split(new char[] { ';' }); | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | |||
80 | protected override string OperationName | ||
81 | { | ||
82 | get { return "project"; } | ||
83 | } | ||
84 | |||
85 | /// <summary> | ||
86 | /// Generate the command line arguments to write to the response file from the properties. | ||
87 | /// </summary> | ||
88 | /// <returns>Command line string.</returns> | ||
89 | protected override string GenerateResponseFileCommands() | ||
90 | { | ||
91 | WixCommandLineBuilder commandLineBuilder = new WixCommandLineBuilder(); | ||
92 | |||
93 | commandLineBuilder.AppendSwitch(this.OperationName); | ||
94 | commandLineBuilder.AppendFileNameIfNotNull(this.Project); | ||
95 | |||
96 | commandLineBuilder.AppendSwitchIfNotNull("-configuration ", this.Configuration); | ||
97 | commandLineBuilder.AppendSwitchIfNotNull("-directoryid ", this.DirectoryIds); | ||
98 | commandLineBuilder.AppendSwitchIfNotNull("-generate ", this.GenerateType); | ||
99 | commandLineBuilder.AppendSwitchIfNotNull("-platform ", this.Platform); | ||
100 | commandLineBuilder.AppendArrayIfNotNull("-pog ", this.ProjectOutputGroups); | ||
101 | commandLineBuilder.AppendSwitchIfNotNull("-projectname ", this.ProjectName); | ||
102 | commandLineBuilder.AppendIfTrue("-wixvar", this.GenerateWixVariables); | ||
103 | |||
104 | base.BuildCommandLine(commandLineBuilder); | ||
105 | return commandLineBuilder.ToString(); | ||
106 | } | ||
107 | } | ||
108 | } | ||
diff --git a/src/WixToolset.BuildTasks/heattask.cs b/src/WixToolset.BuildTasks/heattask.cs new file mode 100644 index 00000000..bf0a2ad3 --- /dev/null +++ b/src/WixToolset.BuildTasks/heattask.cs | |||
@@ -0,0 +1,121 @@ | |||
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 | /// A base MSBuild task to run the WiX harvester. | ||
16 | /// Specific harvester tasks should extend this class. | ||
17 | /// </summary> | ||
18 | public abstract class HeatTask : WixToolTask | ||
19 | { | ||
20 | private const string HeatToolName = "Heat.exe"; | ||
21 | |||
22 | private bool autogenerageGuids; | ||
23 | private bool generateGuidsNow; | ||
24 | private ITaskItem outputFile; | ||
25 | private bool suppressFragments; | ||
26 | private bool suppressUniqueIds; | ||
27 | private string[] transforms; | ||
28 | |||
29 | public bool AutogenerateGuids | ||
30 | { | ||
31 | get { return this.autogenerageGuids; } | ||
32 | set { this.autogenerageGuids = value; } | ||
33 | } | ||
34 | |||
35 | public bool GenerateGuidsNow | ||
36 | { | ||
37 | get { return this.generateGuidsNow; } | ||
38 | set { this.generateGuidsNow = value; } | ||
39 | } | ||
40 | |||
41 | [Required] | ||
42 | [Output] | ||
43 | public ITaskItem OutputFile | ||
44 | { | ||
45 | get { return this.outputFile; } | ||
46 | set { this.outputFile = value; } | ||
47 | } | ||
48 | |||
49 | public bool SuppressFragments | ||
50 | { | ||
51 | get { return this.suppressFragments; } | ||
52 | set { this.suppressFragments = value; } | ||
53 | } | ||
54 | |||
55 | public bool SuppressUniqueIds | ||
56 | { | ||
57 | get { return this.suppressUniqueIds; } | ||
58 | set { this.suppressUniqueIds = value; } | ||
59 | } | ||
60 | |||
61 | public string[] Transforms | ||
62 | { | ||
63 | get { return this.transforms; } | ||
64 | set { this.transforms = value; } | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// Get the name of the executable. | ||
69 | /// </summary> | ||
70 | /// <remarks>The ToolName is used with the ToolPath to get the location of heat.exe.</remarks> | ||
71 | /// <value>The name of the executable.</value> | ||
72 | protected override string ToolName | ||
73 | { | ||
74 | get { return HeatToolName; } | ||
75 | } | ||
76 | |||
77 | /// <summary> | ||
78 | /// Gets the name of the heat operation performed by the task. | ||
79 | /// </summary> | ||
80 | /// <remarks>This is the first parameter passed on the heat.exe command-line.</remarks> | ||
81 | /// <value>The name of the heat operation performed by the task.</value> | ||
82 | protected abstract string OperationName | ||
83 | { | ||
84 | get; | ||
85 | } | ||
86 | |||
87 | /// <summary> | ||
88 | /// Get the path to the executable. | ||
89 | /// </summary> | ||
90 | /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks> | ||
91 | /// <returns>The full path to the executable or simply heat.exe if it's expected to be in the system path.</returns> | ||
92 | protected override string GenerateFullPathToTool() | ||
93 | { | ||
94 | // If there's not a ToolPath specified, it has to be in the system path. | ||
95 | if (String.IsNullOrEmpty(this.ToolPath)) | ||
96 | { | ||
97 | return HeatToolName; | ||
98 | } | ||
99 | |||
100 | return Path.Combine(Path.GetFullPath(this.ToolPath), HeatToolName); | ||
101 | } | ||
102 | |||
103 | /// <summary> | ||
104 | /// Builds a command line from options in this task. | ||
105 | /// </summary> | ||
106 | protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder) | ||
107 | { | ||
108 | base.BuildCommandLine(commandLineBuilder); | ||
109 | |||
110 | commandLineBuilder.AppendIfTrue("-ag", this.AutogenerateGuids); | ||
111 | commandLineBuilder.AppendIfTrue("-gg", this.GenerateGuidsNow); | ||
112 | commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo); | ||
113 | commandLineBuilder.AppendIfTrue("-sfrag", this.SuppressFragments); | ||
114 | commandLineBuilder.AppendIfTrue("-suid", this.SuppressUniqueIds); | ||
115 | commandLineBuilder.AppendArrayIfNotNull("-sw", this.SuppressSpecificWarnings); | ||
116 | commandLineBuilder.AppendArrayIfNotNull("-t ", this.Transforms); | ||
117 | commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions); | ||
118 | commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile); | ||
119 | } | ||
120 | } | ||
121 | } | ||
diff --git a/src/WixToolset.BuildTasks/redirect.wix.ca.targets b/src/WixToolset.BuildTasks/redirect.wix.ca.targets new file mode 100644 index 00000000..74e6ec3c --- /dev/null +++ b/src/WixToolset.BuildTasks/redirect.wix.ca.targets | |||
@@ -0,0 +1,11 @@ | |||
1 | <?xml version="1.0" encoding="utf-8" ?> | ||
2 | <!-- 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. --> | ||
3 | |||
4 | |||
5 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> | ||
6 | <PropertyGroup> | ||
7 | <WixInstallFolder>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\WiX Toolset\v4', 'InstallFolder', null, RegistryView.Registry32))</WixInstallFolder> | ||
8 | </PropertyGroup> | ||
9 | |||
10 | <Import Project="$(WixInstallFolder)sdk\wix.ca.targets" /> | ||
11 | </Project> | ||
diff --git a/src/WixToolset.BuildTasks/redirect.wix.targets b/src/WixToolset.BuildTasks/redirect.wix.targets new file mode 100644 index 00000000..b40c4c36 --- /dev/null +++ b/src/WixToolset.BuildTasks/redirect.wix.targets | |||
@@ -0,0 +1,11 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <!-- 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. --> | ||
3 | |||
4 | |||
5 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> | ||
6 | <PropertyGroup> | ||
7 | <WixInstallFolder>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\WiX Toolset\v4', 'InstallFolder', null, RegistryView.Registry32))</WixInstallFolder> | ||
8 | </PropertyGroup> | ||
9 | |||
10 | <Import Project="$(WixInstallFolder)bin\wix.targets" /> | ||
11 | </Project> | ||
diff --git a/src/WixToolset.BuildTasks/wix.ca.targets b/src/WixToolset.BuildTasks/wix.ca.targets new file mode 100644 index 00000000..4578c2d8 --- /dev/null +++ b/src/WixToolset.BuildTasks/wix.ca.targets | |||
@@ -0,0 +1,123 @@ | |||
1 | <?xml version="1.0" encoding="utf-8" ?> | ||
2 | <!-- 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. --> | ||
3 | |||
4 | |||
5 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> | ||
6 | |||
7 | <Import Project="$(CustomBeforeWixCATargets)" Condition=" '$(CustomBeforeWixCATargets)' != '' and Exists('$(CustomBeforeWixCATargets)')" /> | ||
8 | |||
9 | <PropertyGroup> | ||
10 | <WixCATargetsImported>true</WixCATargetsImported> | ||
11 | |||
12 | <TargetCAFileName Condition=" '$(TargetCAFileName)' == '' ">$(TargetName).CA$(TargetExt)</TargetCAFileName> | ||
13 | |||
14 | <WixSdkPath Condition=" '$(WixSdkPath)' == '' ">$(MSBuildThisFileDirectory)</WixSdkPath> | ||
15 | <WixSdkX86Path Condition=" '$(WixSdkX86Path)' == '' ">$(WixSdkPath)x86\</WixSdkX86Path> | ||
16 | <WixSdkX64Path Condition=" '$(WixSdkX64Path)' == '' ">$(WixSdkPath)x64\</WixSdkX64Path> | ||
17 | |||
18 | <MakeSfxCA Condition=" '$(MakeSfxCA)' == '' ">$(WixSdkPath)MakeSfxCA.exe</MakeSfxCA> | ||
19 | <SfxCADll Condition=" '$(SfxCADll)' == '' and '$(Platform)' == 'x64' ">$(WixSdkX64Path)SfxCA.dll</SfxCADll> | ||
20 | <SfxCADll Condition=" '$(SfxCADll)' == '' ">$(WixSdkX86Path)SfxCA.dll</SfxCADll> | ||
21 | </PropertyGroup> | ||
22 | |||
23 | <!-- | ||
24 | ================================================================================================== | ||
25 | PackCustomAction | ||
26 | |||
27 | Creates an MSI managed custom action package that includes the custom action assembly, | ||
28 | local assembly dependencies, and project content files. | ||
29 | |||
30 | [IN] | ||
31 | @(IntermediateAssembly) - Managed custom action assembly. | ||
32 | @(Content) - Project items of type Content will be included in the package. | ||
33 | $(CustomActionContents) - Optional space-delimited list of additional files to include. | ||
34 | |||
35 | [OUT] | ||
36 | $(IntermediateOutputPath)$(TargetCAFileName) - Managed custom action package with unmanaged stub. | ||
37 | ================================================================================================== | ||
38 | --> | ||
39 | <Target Name="PackCustomAction" | ||
40 | Inputs="@(IntermediateAssembly);@(Content);$(CustomActionContents)" | ||
41 | Outputs="$(IntermediateOutputPath)$(TargetCAFileName)"> | ||
42 | |||
43 | <!-- Find all referenced items marked CopyLocal, but exclude non-binary files. --> | ||
44 | <ItemGroup> | ||
45 | <CustomActionReferenceContents Include="@(ReferenceCopyLocalPaths)" | ||
46 | Condition=" '%(Extension)' == '.dll' or '%(Extension)' == '.exe' " /> | ||
47 | <CustomActionReferenceContents Include="@(ReferenceComWrappersToCopyLocal)" | ||
48 | Condition=" '%(Extension)' == '.dll' or '%(Extension)' == '.exe' " /> | ||
49 | |||
50 | <!-- include PDBs for Debug only --> | ||
51 | <CustomActionReferenceContents Include="@(IntermediateAssembly->'%(RootDir)%(Directory)%(Filename).pdb')" | ||
52 | Condition=" Exists('%(RootDir)%(Directory)%(Filename).pdb') and '$(Configuration)' == 'Debug' " /> | ||
53 | <CustomActionReferenceContents Include="@(ReferenceCopyLocalPaths)" | ||
54 | Condition=" '%(Extension)' == '.pdb' and '$(Configuration)' == 'Debug' " /> | ||
55 | <CustomActionReferenceContents Include="@(ReferenceComWrappersToCopyLocal)" | ||
56 | Condition=" '%(Extension)' == '.pdb' and '$(Configuration)' == 'Debug' " /> | ||
57 | </ItemGroup> | ||
58 | |||
59 | <!-- | ||
60 | Items to include in the CA package: | ||
61 | - Reference assemblies marked CopyLocal | ||
62 | - Project items of type Content | ||
63 | - Additional items in the CustomActionContents property | ||
64 | --> | ||
65 | <PropertyGroup> | ||
66 | <CustomActionContents>@(CustomActionReferenceContents);@(Content->'%(FullPath)');$(CustomActionContents)</CustomActionContents> | ||
67 | </PropertyGroup> | ||
68 | |||
69 | <ItemGroup> | ||
70 | <IntermediateCAAssembly Include="@(IntermediateAssembly->'%(FullPath)')" /> | ||
71 | <IntermediateCAPackage Include="@(IntermediateAssembly->'%(RootDir)%(Directory)$(TargetCAFileName)')" /> | ||
72 | </ItemGroup> | ||
73 | |||
74 | <!-- Run the MakeSfxCA.exe CA packaging tool. --> | ||
75 | <Exec Command='"$(MakeSfxCA)" "@(IntermediateCAPackage)" "$(SfxCADll)" "@(IntermediateCAAssembly)" "$(CustomActionContents)"' | ||
76 | WorkingDirectory="$(ProjectDir)" /> | ||
77 | |||
78 | <!-- Add modules to be copied to output dir. --> | ||
79 | <ItemGroup> | ||
80 | <AddModules Include="@(IntermediateCAPackage)" /> | ||
81 | </ItemGroup> | ||
82 | </Target> | ||
83 | |||
84 | <!-- | ||
85 | ================================================================================================== | ||
86 | CleanCustomAction | ||
87 | |||
88 | Cleans the .CA.dll binary created by the PackCustomAction target. | ||
89 | |||
90 | ================================================================================================== | ||
91 | --> | ||
92 | <Target Name="CleanCustomAction"> | ||
93 | <Delete Files="$(IntermediateOutputPath)$(TargetCAFileName)" | ||
94 | TreatErrorsAsWarnings="true" /> | ||
95 | </Target> | ||
96 | |||
97 | <!-- | ||
98 | ================================================================================================== | ||
99 | AfterCompile (redefinition) | ||
100 | |||
101 | Calls the PackCustomAction target after compiling. | ||
102 | Overrides the empty AfterCompile target from Microsoft.Common.targets. | ||
103 | |||
104 | ================================================================================================== | ||
105 | --> | ||
106 | <Target Name="AfterCompile" | ||
107 | DependsOnTargets="PackCustomAction" /> | ||
108 | |||
109 | <!-- | ||
110 | ================================================================================================== | ||
111 | BeforeClean (redefinition) | ||
112 | |||
113 | Calls the CleanCustomAction target before cleaning. | ||
114 | Overrides the empty AfterCompile target from Microsoft.Common.targets. | ||
115 | |||
116 | ================================================================================================== | ||
117 | --> | ||
118 | <Target Name="BeforeClean" | ||
119 | DependsOnTargets="CleanCustomAction" /> | ||
120 | |||
121 | <Import Project="$(CustomAfterWixCATargets)" Condition=" '$(CustomAfterWixCATargets)' != '' and Exists('$(CustomAfterWixCATargets)')" /> | ||
122 | |||
123 | </Project> | ||
diff --git a/src/WixToolset.BuildTasks/wix.harvest.targets b/src/WixToolset.BuildTasks/wix.harvest.targets new file mode 100644 index 00000000..e94dfcea --- /dev/null +++ b/src/WixToolset.BuildTasks/wix.harvest.targets | |||
@@ -0,0 +1,511 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <!-- 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. --> | ||
3 | |||
4 | |||
5 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
6 | |||
7 | <!-- These properties can be overridden to support non-default installations. --> | ||
8 | <PropertyGroup> | ||
9 | <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildThisFileFullPath)</WixTargetsPath> | ||
10 | <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixTargetsPath)WixTasks.dll</WixTasksPath> | ||
11 | </PropertyGroup> | ||
12 | |||
13 | <!-- These tasks are extensions for harvesting WiX source code from other sources. --> | ||
14 | <UsingTask TaskName="HeatFile" AssemblyFile="$(WixTasksPath)" /> | ||
15 | <UsingTask TaskName="HeatDirectory" AssemblyFile="$(WixTasksPath)" /> | ||
16 | <UsingTask TaskName="HeatProject" AssemblyFile="$(WixTasksPath)" /> | ||
17 | |||
18 | <UsingTask TaskName="RefreshGeneratedFile" AssemblyFile="$(WixTasksPath)"/> | ||
19 | <UsingTask TaskName="RefreshBundleGeneratedFile" AssemblyFile="$(WixTasksPath)"/> | ||
20 | |||
21 | <!-- Default Harvester properties--> | ||
22 | <PropertyGroup> | ||
23 | <HarvestNoLogo Condition=" '$(HarvestNoLogo)' == '' ">$(NoLogo)</HarvestNoLogo> | ||
24 | <HarvestSuppressAllWarnings Condition=" '$(HarvestSuppressAllWarnings)' == '' ">$(SuppressAllWarnings)</HarvestSuppressAllWarnings> | ||
25 | <HarvestSuppressSpecificWarnings Condition=" '$(HarvestSuppressSpecificWarnings)' == '' ">$(SuppressSpecificWarnings)</HarvestSuppressSpecificWarnings> | ||
26 | <HarvestTreatWarningsAsErrors Condition=" '$(HarvestTreatWarningsAsErrors)' == '' ">$(TreatWarningsAsErrors)</HarvestTreatWarningsAsErrors> | ||
27 | <HarvestTreatSpecificWarningsAsErrors Condition=" '$(HarvestTreatSpecificWarningsAsErrors)' == '' ">$(TreatSpecificWarningsAsErrors)</HarvestTreatSpecificWarningsAsErrors> | ||
28 | <HarvestVerboseOutput Condition=" '$(HarvestVerboseOutput)' == '' ">$(VerboseOutput)</HarvestVerboseOutput> | ||
29 | <HarvestAutogenerateGuids Condition=" '$(HarvestAutogenerateGuids)' == '' ">true</HarvestAutogenerateGuids> | ||
30 | <HarvestGenerateGuidsNow Condition=" '$(HarvestGenerateGuidsNow)' == '' ">false</HarvestGenerateGuidsNow> | ||
31 | <HarvestSuppressFragments Condition=" '$(HarvestSuppressFragments)' == '' ">true</HarvestSuppressFragments> | ||
32 | <HarvestSuppressUniqueIds Condition=" '$(HarvestSuppressUniqueIds)' == '' ">false</HarvestSuppressUniqueIds> | ||
33 | </PropertyGroup> | ||
34 | |||
35 | <!-- Default HarvestProjects properties --> | ||
36 | <PropertyGroup> | ||
37 | <!-- Project harvesting is defaulted to off until it works more consistently. --> | ||
38 | <EnableProjectHarvesting Condition=" '$(EnableProjectHarvesting)'=='' ">false</EnableProjectHarvesting> | ||
39 | |||
40 | <HarvestProjectsNoLogo Condition=" '$(HarvestProjectsNoLogo)' == '' ">$(HarvestNoLogo)</HarvestProjectsNoLogo> | ||
41 | <HarvestProjectsSuppressAllWarnings Condition=" '$(HarvestProjectsSuppressAllWarnings)' == '' ">$(HarvestSuppressAllWarnings)</HarvestProjectsSuppressAllWarnings> | ||
42 | <HarvestProjectsSuppressSpecificWarnings Condition=" '$(HarvestProjectsSuppressSpecificWarnings)' == '' ">$(HarvestSuppressSpecificWarnings)</HarvestProjectsSuppressSpecificWarnings> | ||
43 | <HarvestProjectsTreatWarningsAsErrors Condition=" '$(HarvestProjectsTreatWarningsAsErrors)' == '' ">$(HarvestTreatWarningsAsErrors)</HarvestProjectsTreatWarningsAsErrors> | ||
44 | <HarvestProjectsTreatSpecificWarningsAsErrors Condition=" '$(HarvestProjectsTreatSpecificWarningsAsErrors)' == '' ">$(HarvestTreatSpecificWarningsAsErrors)</HarvestProjectsTreatSpecificWarningsAsErrors> | ||
45 | <HarvestProjectsVerboseOutput Condition=" '$(HarvestProjectsVerboseOutput)' == '' ">$(HarvestVerboseOutput)</HarvestProjectsVerboseOutput> | ||
46 | <HarvestProjectsAutogenerateGuids Condition=" '$(HarvestProjectsAutogenerateGuids)' == '' ">$(HarvestAutogenerateGuids)</HarvestProjectsAutogenerateGuids> | ||
47 | <HarvestProjectsGenerateGuidsNow Condition=" '$(HarvestProjectsGenerateGuidsNow)' == '' ">$(HarvestGenerateGuidsNow)</HarvestProjectsGenerateGuidsNow> | ||
48 | <HarvestProjectsSuppressFragments Condition=" '$(HarvestProjectsSuppressFragments)' == '' ">$(HarvestSuppressFragments)</HarvestProjectsSuppressFragments> | ||
49 | <HarvestProjectsSuppressUniqueIds Condition=" '$(HarvestProjectsSuppressUniqueIds)' == '' ">$(HarvestSuppressUniqueIds)</HarvestProjectsSuppressUniqueIds> | ||
50 | <HarvestProjectsTransforms Condition=" '$(HarvestProjectsTransforms)' == '' ">$(HarvestTransforms)</HarvestProjectsTransforms> | ||
51 | <HarvestProjectsGeneratedFile Condition=" '$(HarvestProjectsGeneratedFile)' == '' and '$(OutputType)' != 'Bundle' ">$(IntermediateOutputPath)Product.Generated.wxs</HarvestProjectsGeneratedFile> | ||
52 | <HarvestProjectsGeneratedFile Condition=" '$(HarvestProjectsGeneratedFile)' == '' and '$(OutputType)' == 'Bundle' ">$(IntermediateOutputPath)Bundle.Generated.wxs</HarvestProjectsGeneratedFile> | ||
53 | </PropertyGroup> | ||
54 | |||
55 | <!-- Default HarvestDirectory properties --> | ||
56 | <PropertyGroup> | ||
57 | <HarvestDirectoryNoLogo Condition=" '$(HarvestDirectoryNoLogo)' == '' ">$(HarvestNoLogo)</HarvestDirectoryNoLogo> | ||
58 | <HarvestDirectorySuppressAllWarnings Condition=" '$(HarvestDirectorySuppressAllWarnings)' == '' ">$(HarvestSuppressAllWarnings)</HarvestDirectorySuppressAllWarnings> | ||
59 | <HarvestDirectorySuppressSpecificWarnings Condition=" '$(HarvestDirectorySuppressSpecificWarnings)' == '' ">$(HarvestSuppressSpecificWarnings)</HarvestDirectorySuppressSpecificWarnings> | ||
60 | <HarvestDirectoryTreatWarningsAsErrors Condition=" '$(HarvestDirectoryTreatWarningsAsErrors)' == '' ">$(HarvestTreatWarningsAsErrors)</HarvestDirectoryTreatWarningsAsErrors> | ||
61 | <HarvestDirectoryTreatSpecificWarningsAsErrors Condition=" '$(HarvestDirectoryTreatSpecificWarningsAsErrors)' == '' ">$(HarvestTreatSpecificWarningsAsErrors)</HarvestDirectoryTreatSpecificWarningsAsErrors> | ||
62 | <HarvestDirectoryVerboseOutput Condition=" '$(HarvestDirectoryVerboseOutput)' == '' ">$(HarvestVerboseOutput)</HarvestDirectoryVerboseOutput> | ||
63 | <HarvestDirectoryAutogenerateGuids Condition=" '$(HarvestDirectoryAutogenerateGuids)' == '' ">$(HarvestAutogenerateGuids)</HarvestDirectoryAutogenerateGuids> | ||
64 | <HarvestDirectoryGenerateGuidsNow Condition=" '$(HarvestDirectoryGenerateGuidsNow)' == '' ">$(HarvestGenerateGuidsNow)</HarvestDirectoryGenerateGuidsNow> | ||
65 | <HarvestDirectorySuppressFragments Condition=" '$(HarvestDirectorySuppressFragments)' == '' ">$(HarvestSuppressFragments)</HarvestDirectorySuppressFragments> | ||
66 | <HarvestDirectorySuppressUniqueIds Condition=" '$(HarvestDirectorySuppressUniqueIds)' == '' ">$(HarvestSuppressUniqueIds)</HarvestDirectorySuppressUniqueIds> | ||
67 | <HarvestDirectoryTransforms Condition=" '$(HarvestDirectoryTransforms)' == '' ">$(HarvestTransforms)</HarvestDirectoryTransforms> | ||
68 | </PropertyGroup> | ||
69 | |||
70 | <!-- Default HarvestFile properties --> | ||
71 | <PropertyGroup> | ||
72 | <HarvestFileNoLogo Condition=" '$(HarvestFileNoLogo)' == '' ">$(HarvestNoLogo)</HarvestFileNoLogo> | ||
73 | <HarvestFileSuppressAllWarnings Condition=" '$(HarvestFileSuppressAllWarnings)' == '' ">$(HarvestSuppressAllWarnings)</HarvestFileSuppressAllWarnings> | ||
74 | <HarvestFileSuppressSpecificWarnings Condition=" '$(HarvestFileSuppressSpecificWarnings)' == '' ">$(HarvestSuppressSpecificWarnings)</HarvestFileSuppressSpecificWarnings> | ||
75 | <HarvestFileTreatWarningsAsErrors Condition=" '$(HarvestFileTreatWarningsAsErrors)' == '' ">$(HarvestTreatWarningsAsErrors)</HarvestFileTreatWarningsAsErrors> | ||
76 | <HarvestFileTreatSpecificWarningsAsErrors Condition=" '$(HarvestFileTreatSpecificWarningsAsErrors)' == '' ">$(HarvestTreatSpecificWarningsAsErrors)</HarvestFileTreatSpecificWarningsAsErrors> | ||
77 | <HarvestFileVerboseOutput Condition=" '$(HarvestFileVerboseOutput)' == '' ">$(HarvestVerboseOutput)</HarvestFileVerboseOutput> | ||
78 | <HarvestFileAutogenerateGuids Condition=" '$(HarvestFileAutogenerateGuids)' == '' ">$(HarvestAutogenerateGuids)</HarvestFileAutogenerateGuids> | ||
79 | <HarvestFileGenerateGuidsNow Condition=" '$(HarvestFileGenerateGuidsNow)' == '' ">$(HarvestGenerateGuidsNow)</HarvestFileGenerateGuidsNow> | ||
80 | <HarvestFileSuppressFragments Condition=" '$(HarvestFileSuppressFragments)' == '' ">$(HarvestSuppressFragments)</HarvestFileSuppressFragments> | ||
81 | <HarvestFileSuppressUniqueIds Condition=" '$(HarvestFileSuppressUniqueIds)' == '' ">$(HarvestSuppressUniqueIds)</HarvestFileSuppressUniqueIds> | ||
82 | <HarvestFileTransforms Condition=" '$(HarvestFileTransforms)' == '' ">$(HarvestTransforms)</HarvestFileTransforms> | ||
83 | </PropertyGroup> | ||
84 | |||
85 | <!-- | ||
86 | ================================================================================================== | ||
87 | Harvest | ||
88 | ================================================================================================== | ||
89 | --> | ||
90 | <PropertyGroup> | ||
91 | <HarvestDependsOn> | ||
92 | ConvertReferences; | ||
93 | ConvertBundleReferences; | ||
94 | HarvestProjects; | ||
95 | HarvestDirectory; | ||
96 | HarvestFile; | ||
97 | GenerateCode; | ||
98 | </HarvestDependsOn> | ||
99 | </PropertyGroup> | ||
100 | <Target | ||
101 | Name="Harvest" | ||
102 | DependsOnTargets="$(HarvestDependsOn)" /> | ||
103 | |||
104 | <!-- | ||
105 | ================================================================================================== | ||
106 | GenerateCode | ||
107 | ================================================================================================== | ||
108 | --> | ||
109 | <PropertyGroup> | ||
110 | <GenerateCodeDependsOn> | ||
111 | RefreshGeneratedFile; | ||
112 | RefreshBundleGeneratedFile | ||
113 | </GenerateCodeDependsOn> | ||
114 | </PropertyGroup> | ||
115 | <Target | ||
116 | Name="GenerateCode" | ||
117 | DependsOnTargets="$(GenerateCodeDependsOn)" /> | ||
118 | |||
119 | <!-- | ||
120 | ================================================================================================ | ||
121 | ConvertReferences | ||
122 | |||
123 | Converts project references to HeatProject items to auto generate authoring. | ||
124 | ================================================================================================ | ||
125 | --> | ||
126 | <Target | ||
127 | Name="ConvertReferences" | ||
128 | Condition=" $(EnableProjectHarvesting) and ('$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module') "> | ||
129 | |||
130 | <ItemGroup> | ||
131 | <_HeatProjectReference Include="@(_MSBuildProjectReferenceExistent)" Condition=" '%(_MSBuildProjectReferenceExistent.DoNotHarvest)' == '' "> | ||
132 | <DirectoryIds>%(_MSBuildProjectReferenceExistent.RefTargetDir)</DirectoryIds> | ||
133 | <ProjectOutputGroups>Binaries;Symbols;Sources;Content;Satellites;Documents</ProjectOutputGroups> | ||
134 | <ProjectName>%(_MSBuildProjectReferenceExistent.Name)</ProjectName> | ||
135 | <HeatOutput>$(IntermediateOutputPath)_%(_MSBuildProjectReferenceExistent.Filename).wxs</HeatOutput> | ||
136 | </_HeatProjectReference> | ||
137 | <HeatProject Include="@(_HeatProjectReference)" /> | ||
138 | </ItemGroup> | ||
139 | |||
140 | <Error | ||
141 | Text="The following files are deprecated and should be removed from your project(s): @(Compile->'%(Identity)', ', ')" | ||
142 | Condition=" '%(Compile.GenerateComponentGroups)' != '' " /> | ||
143 | |||
144 | <ItemGroup> | ||
145 | <!-- Unconditionally generate Compile items so they are always linked in. --> | ||
146 | <Compile Include="$(HarvestProjectsGeneratedFile)" /> | ||
147 | <_GeneratedFiles Include="$(HarvestProjectsGeneratedFile)" /> | ||
148 | </ItemGroup> | ||
149 | |||
150 | </Target> | ||
151 | |||
152 | <!-- | ||
153 | ================================================================================================ | ||
154 | ConvertBundleReferences | ||
155 | |||
156 | Converts project references in Bundle projects to HeatProject items to auto generate authoring. | ||
157 | ================================================================================================ | ||
158 | --> | ||
159 | <Target | ||
160 | Name="ConvertBundleReferences" | ||
161 | Condition=" $(EnableProjectHarvesting) and ('$(OutputType)' == 'Bundle') "> | ||
162 | |||
163 | <ItemGroup> | ||
164 | <_HeatProjectReference Include="@(_MSBuildProjectReferenceExistent)" Condition=" '%(_MSBuildProjectReferenceExistent.DoNotHarvest)' == '' "> | ||
165 | <ProjectOutputGroups>Binaries;Symbols;Sources;Content;Satellites;Documents</ProjectOutputGroups> | ||
166 | <GenerateType>payloadgroup</GenerateType> | ||
167 | <HeatOutput>$(IntermediateOutputPath)_%(_MSBuildProjectReferenceExistent.Filename).wxs</HeatOutput> | ||
168 | </_HeatProjectReference> | ||
169 | <HeatProject Include="@(_HeatProjectReference)" /> | ||
170 | </ItemGroup> | ||
171 | |||
172 | <Error | ||
173 | Text="The following files are deprecated and should be removed from your project(s): @(Compile->'%(Identity)', ', ')" | ||
174 | Condition=" '%(Compile.GenerateComponentGroups)' != '' " /> | ||
175 | |||
176 | <ItemGroup> | ||
177 | <!-- Unconditionally generate Compile items so they are always linked in. --> | ||
178 | <Compile Include="$(HarvestProjectsGeneratedFile)" /> | ||
179 | <_GeneratedFiles Include="$(HarvestProjectsGeneratedFile)" /> | ||
180 | </ItemGroup> | ||
181 | |||
182 | </Target> | ||
183 | |||
184 | <!-- | ||
185 | ================================================================================================ | ||
186 | CombineHarvestProjects | ||
187 | |||
188 | Combines HeatProject and HarvestProject items together and ensures each has HeatOutput metadata. | ||
189 | ================================================================================================ | ||
190 | --> | ||
191 | <Target | ||
192 | Name="CombineHarvestProjects" | ||
193 | Condition=" '@(HeatProject)' != '' or '@(HarvestProject)' != '' "> | ||
194 | |||
195 | <!-- Add default HeatOutputs for those without one specified --> | ||
196 | <CreateItem Include="@(HeatProject)" Condition= " '%(HeatProject.HeatOutput)' == '' " | ||
197 | AdditionalMetadata="HeatOutput=$(IntermediateOutputPath)_%(HeatProject.Filename).wxs"> | ||
198 | <Output TaskParameter="Include" ItemName="_AllHeatProjects" /> | ||
199 | </CreateItem> | ||
200 | <CreateItem Include="@(HarvestProject)" Condition= " '%(HarvestProject.HeatOutput)' == '' " | ||
201 | AdditionalMetadata="HeatOutput=$(IntermediateOutputPath)_%(HarvestProject.Filename).wxs"> | ||
202 | <Output TaskParameter="Include" ItemName="_AllHeatProjects" /> | ||
203 | </CreateItem> | ||
204 | |||
205 | |||
206 | <CreateItem Include="@(HeatProject)" Condition= " '%(HeatProject.HeatOutput)' != '' "> | ||
207 | <Output TaskParameter="Include" ItemName="_AllHeatProjects" /> | ||
208 | </CreateItem> | ||
209 | <CreateItem Include="@(HarvestProject)" Condition= " '%(HarvestProject.HeatOutput)' != '' "> | ||
210 | <Output TaskParameter="Include" ItemName="_AllHeatProjects" /> | ||
211 | </CreateItem> | ||
212 | |||
213 | </Target> | ||
214 | |||
215 | <!-- | ||
216 | ================================================================================================ | ||
217 | HarvestProjects | ||
218 | |||
219 | Harvests outputs of other MSBuild projects files using the VS project extension to heat.exe. | ||
220 | |||
221 | [IN] | ||
222 | @(HarvestProject) | ||
223 | @(HeatProject) | ||
224 | - The list of projects to harvest. HeatProject is provided for backward compatibility. | ||
225 | You should use HarvestProject instead. | ||
226 | |||
227 | %(HarvestProject.Transforms) | ||
228 | %(HeatProject.Transforms) | ||
229 | - XSL transforms to apply to the harvested WiX. | ||
230 | |||
231 | %(HarvestProject.ProjectOutputGroups) | ||
232 | %(HeatProjects.ProjectOutputGroups) | ||
233 | - The project output groups to harvest | ||
234 | |||
235 | [OUT] | ||
236 | %(HeatOutput) | ||
237 | - The generated .wxs files which are added to the @(Compile) item list. | ||
238 | ================================================================================================ | ||
239 | --> | ||
240 | <ItemDefinitionGroup> | ||
241 | <HeatProject> | ||
242 | <Transforms>$(HarvestProjectsTransforms)</Transforms> | ||
243 | <ProjectOutputGroups>$(HarvestProjectsProjectOutputGroups)</ProjectOutputGroups> | ||
244 | <DirectoryIds>$(HarvestProjectsDirectoryIds)</DirectoryIds> | ||
245 | </HeatProject> | ||
246 | <HarvestProject> | ||
247 | <Transforms>$(HarvestProjectsTransforms)</Transforms> | ||
248 | <ProjectOutputGroups>$(HarvestProjectsProjectOutputGroups)</ProjectOutputGroups> | ||
249 | <DirectoryIds>$(HarvestProjectsDirectoryIds)</DirectoryIds> | ||
250 | </HarvestProject> | ||
251 | </ItemDefinitionGroup> | ||
252 | |||
253 | <PropertyGroup> | ||
254 | <HarvestProjectsDependsOn>CombineHarvestProjects</HarvestProjectsDependsOn> | ||
255 | </PropertyGroup> | ||
256 | <Target Name="HarvestProjects" | ||
257 | DependsOnTargets="$(HarvestProjectsDependsOn)" | ||
258 | Inputs="@(_AllHeatProjects);%(_AllHeatProjects.Transforms);$(MSBuildAllProjects);$(ProjectPath)" | ||
259 | Outputs="@(_AllHeatProjects -> '%(HeatOutput)')" | ||
260 | Condition=" $(EnableProjectHarvesting) and ('@(HeatProject)' != '' or '@(HarvestProject)' != '') "> | ||
261 | |||
262 | <HeatProject | ||
263 | NoLogo="$(HarvestProjectsNoLogo)" | ||
264 | SuppressAllWarnings="$(HarvestProjectsSuppressAllWarnings)" | ||
265 | SuppressSpecificWarnings="$(HarvestProjectsSuppressSpecificWarnings)" | ||
266 | ToolPath="$(WixToolPath)" | ||
267 | TreatWarningsAsErrors="$(HarvestProjectsTreatWarningsAsErrors)" | ||
268 | TreatSpecificWarningsAsErrors="$(HarvestProjectsTreatSpecificWarningsAsErrors)" | ||
269 | VerboseOutput="$(HarvestProjectsVerboseOutput)" | ||
270 | AutogenerateGuids="$(HarvestProjectsAutogenerateGuids)" | ||
271 | GenerateGuidsNow="$(HarvestProjectsGenerateGuidsNow)" | ||
272 | OutputFile="%(_AllHeatProjects.HeatOutput)" | ||
273 | SuppressFragments="$(HarvestProjectsSuppressFragments)" | ||
274 | SuppressUniqueIds="$(HarvestProjectsSuppressUniqueIds)" | ||
275 | Transforms="%(_AllHeatProjects.Transforms)" | ||
276 | Project="%(_AllHeatProjects.FullPath)" | ||
277 | ProjectOutputGroups="%(_AllHeatProjects.ProjectOutputGroups)" | ||
278 | GenerateType="%(_AllHeatProjects.GenerateType)" | ||
279 | DirectoryIds="%(_AllHeatProjects.DirectoryIds)" | ||
280 | ProjectName="%(_AllHeatProjects.ProjectName)" | ||
281 | Configuration="%(_AllHeatProjects.Configuration)" | ||
282 | Platform="%(_AllHeatProjects.Platform)" | ||
283 | RunAsSeparateProcess="$(RunWixToolsOutOfProc)" | ||
284 | GenerateWixVariables="$(HarvestProjectsGenerateWixVariables)" | ||
285 | AdditionalOptions="$(HarvestProjectsAdditionalOptions)"> | ||
286 | |||
287 | <Output TaskParameter="OutputFile" ItemName="Compile" /> | ||
288 | <Output TaskParameter="OutputFile" ItemName="FileWrites" /> | ||
289 | |||
290 | </HeatProject> | ||
291 | |||
292 | </Target> | ||
293 | |||
294 | <!-- | ||
295 | ================================================================================================ | ||
296 | HarvestDirectory | ||
297 | |||
298 | Harvests directories using heat.exe. | ||
299 | |||
300 | [IN] | ||
301 | @(HarvestDirectory) - The list of directories to harvest. | ||
302 | %(HarvestDirectory.Transforms) - XSL transforms to apply to the harvested WiX. | ||
303 | %(HarvestDirectory.ComponentGroupName) - The name of the ComponentGroup to create. | ||
304 | %(HarvestDirectory.DirectoryRefId) - The ID of the directory to reference instead of TARGETDIR. | ||
305 | %(HarvestDirectory.KeepEmptyDirectories) - Whether to create Directory entries for empty directories. | ||
306 | %(HarvestDirectory.PreprocessorVariable) - Substitute SourceDir for another variable name (ex: var.Dir). | ||
307 | %(HarvestDirectory.SuppressCom) - Suppress COM elements. | ||
308 | %(HarvestDirectory.SuppressRootDirectory) - Suppress a Directory element for the root directory. | ||
309 | $(HarvestDirectory.SuppressRegistry) - Suppress registry harvesting. | ||
310 | |||
311 | [OUT] | ||
312 | $(IntermediateOutputPath)_%(HarvestDirectory.ComponentGroupName)_dir.wxs | ||
313 | - The generated .wxs files which are added to the @(Compile) item list. | ||
314 | ================================================================================================ | ||
315 | --> | ||
316 | |||
317 | <ItemDefinitionGroup> | ||
318 | <HarvestDirectory> | ||
319 | <Transforms>$(HarvestDirectoryTransforms)</Transforms> | ||
320 | <ComponentGroupName>$(HarvestDirectoryComponentGroupName)</ComponentGroupName> | ||
321 | <DirectoryRefId>$(HarvestDirectoryDirectoryRefId)</DirectoryRefId> | ||
322 | <KeepEmptyDirectories>$(HarvestDirectoryKeepEmptyDirectories)</KeepEmptyDirectories> | ||
323 | <PreprocessorVariable>$(HarvestDirectoryPreprocessorVariable)</PreprocessorVariable> | ||
324 | <SuppressCom>$(HarvestDirectorySuppressCom)</SuppressCom> | ||
325 | <SuppressRootDirectory>$(HarvestDirectorySuppressRootDirectory)</SuppressRootDirectory> | ||
326 | <SuppressRegistry>$(HarvestDirectorySuppressRegistry)</SuppressRegistry> | ||
327 | </HarvestDirectory> | ||
328 | </ItemDefinitionGroup> | ||
329 | |||
330 | <PropertyGroup> | ||
331 | <HarvestDirectoryDependsOn> | ||
332 | GetHarvestDirectoryContent | ||
333 | </HarvestDirectoryDependsOn> | ||
334 | </PropertyGroup> | ||
335 | |||
336 | <!-- Creates items to include content since wildcards will not work in Target/@Inputs. --> | ||
337 | <Target Name="GetHarvestDirectoryContent"> | ||
338 | <CreateItem Include="@(HarvestDirectory->'%(FullPath)\**\*')"> | ||
339 | <Output TaskParameter="Include" ItemName="_HarvestDirectoryContent" /> | ||
340 | </CreateItem> | ||
341 | </Target> | ||
342 | |||
343 | <Target Name="HarvestDirectory" | ||
344 | DependsOnTargets="$(HarvestDirectoryDependsOn)" | ||
345 | Inputs="@(_HarvestDirectoryContent);%(HarvestDirectory.Transforms)" | ||
346 | Outputs="$(IntermediateOutputPath)_%(HarvestDirectory.ComponentGroupName)_dir.wxs" | ||
347 | Condition=" '@(HarvestDirectory)' != '' "> | ||
348 | |||
349 | <HeatDirectory | ||
350 | NoLogo="$(HarvestDirectoryNoLogo)" | ||
351 | SuppressAllWarnings="$(HarvestDirectorySuppressAllWarnings)" | ||
352 | SuppressSpecificWarnings="$(HarvestDirectorySuppressSpecificWarnings)" | ||
353 | ToolPath="$(WixToolPath)" | ||
354 | TreatWarningsAsErrors="$(HarvestDirectoryTreatWarningsAsErrors)" | ||
355 | TreatSpecificWarningsAsErrors="$(HarvestDirectoryTreatSpecificWarningsAsErrors)" | ||
356 | VerboseOutput="$(HarvestDirectoryVerboseOutput)" | ||
357 | AutogenerateGuids="$(HarvestDirectoryAutogenerateGuids)" | ||
358 | GenerateGuidsNow="$(HarvestDirectoryGenerateGuidsNow)" | ||
359 | OutputFile="$(IntermediateOutputPath)_%(HarvestDirectory.ComponentGroupName)_dir.wxs" | ||
360 | SuppressFragments="$(HarvestDirectorySuppressFragments)" | ||
361 | SuppressUniqueIds="$(HarvestDirectorySuppressUniqueIds)" | ||
362 | Transforms="%(HarvestDirectory.Transforms)" | ||
363 | Directory="@(HarvestDirectory)" | ||
364 | ComponentGroupName="%(HarvestDirectory.ComponentGroupName)" | ||
365 | DirectoryRefId="%(HarvestDirectory.DirectoryRefId)" | ||
366 | KeepEmptyDirectories="%(HarvestDirectory.KeepEmptyDirectories)" | ||
367 | PreprocessorVariable="%(HarvestDirectory.PreprocessorVariable)" | ||
368 | RunAsSeparateProcess="$(RunWixToolsOutOfProc)" | ||
369 | SuppressCom="%(HarvestDirectory.SuppressCom)" | ||
370 | SuppressRootDirectory="%(HarvestDirectory.SuppressRootDirectory)" | ||
371 | SuppressRegistry="%(HarvestDirectory.SuppressRegistry)" | ||
372 | AdditionalOptions="$(HarvestDirectoryAdditionalOptions)"> | ||
373 | |||
374 | <Output TaskParameter="OutputFile" ItemName="Compile" /> | ||
375 | <Output TaskParameter="OutputFile" ItemName="FileWrites" /> | ||
376 | |||
377 | </HeatDirectory> | ||
378 | |||
379 | </Target> | ||
380 | |||
381 | <!-- | ||
382 | ================================================================================================ | ||
383 | HarvestFile | ||
384 | |||
385 | Harvests files of different types using heat.exe. This can harvest registry from | ||
386 | self-registering files, files with typelibs, and more. | ||
387 | |||
388 | [IN] | ||
389 | @(HarvestFile) - The list of files to harvest. | ||
390 | %(HarvestFile.Transforms) - XSL transforms to apply to the harvested WiX. | ||
391 | %(HarvestFile.ComponentGroupName) - The name of the ComponentGroup to create. | ||
392 | %(HarvestFile.DirectoryRefId) - The ID of the directory to reference instead of TARGETDIR. | ||
393 | %(HarvestFile.PreprocessorVariable) - Substitute SourceDir for another variable name (ex: var.Dir). | ||
394 | %(HarvestFile.SuppressCom) - Suppress COM elements. | ||
395 | %(HarvestFile.SuppressRootDirectory) - Suppress a Directory element for the root directory. | ||
396 | $(HarvestFile.SuppressRegistry) - Suppress registry harvesting. | ||
397 | |||
398 | [OUT] | ||
399 | $(IntermediateOutputPath)_%(HarvestFile.Filename)_file.wxs | ||
400 | - The generated .wxs files which are added to the @(Compile) item list. | ||
401 | ================================================================================================ | ||
402 | --> | ||
403 | |||
404 | <ItemDefinitionGroup> | ||
405 | <HarvestFile> | ||
406 | <Transforms>$(HarvestFileTransforms)</Transforms> | ||
407 | <ComponentGroupName>$(HarvestFileComponentGroupName)</ComponentGroupName> | ||
408 | <DirectoryRefId>$(HarvestFileDirectoryRefId)</DirectoryRefId> | ||
409 | <PreprocessorVariable>$(HarvestFilePreprocessorVariable)</PreprocessorVariable> | ||
410 | <SuppressCom>$(HarvestFileSuppressCom)</SuppressCom> | ||
411 | <SuppressRegistry>$(HarvestFileSuppressRegistry)</SuppressRegistry> | ||
412 | <SuppressRootDirectory>$(HarvestFileSuppressRootDirectory)</SuppressRootDirectory> | ||
413 | </HarvestFile> | ||
414 | </ItemDefinitionGroup> | ||
415 | |||
416 | <PropertyGroup> | ||
417 | <HarvestFileDependsOn></HarvestFileDependsOn> | ||
418 | </PropertyGroup> | ||
419 | <Target Name="HarvestFile" | ||
420 | DependsOnTargets="$(HarvestFileDependsOn)" | ||
421 | Inputs="@(HarvestFile);%(HarvestFile.Transforms)" | ||
422 | Outputs="$(IntermediateOutputPath)_%(HarvestFile.Filename)_file.wxs" | ||
423 | Condition=" '@(HarvestFile)' != '' "> | ||
424 | |||
425 | <HeatFile | ||
426 | NoLogo="$(HarvestFileNoLogo)" | ||
427 | SuppressAllWarnings="$(HarvestFileSuppressAllWarnings)" | ||
428 | SuppressSpecificWarnings="$(HarvestFileSuppressSpecificWarnings)" | ||
429 | ToolPath="$(WixToolPath)" | ||
430 | TreatWarningsAsErrors="$(HarvestFileTreatWarningsAsErrors)" | ||
431 | TreatSpecificWarningsAsErrors="$(HarvestFileTreatSpecificWarningsAsErrors)" | ||
432 | VerboseOutput="$(HarvestFileVerboseOutput)" | ||
433 | AutogenerateGuids="$(HarvestFileAutogenerateGuids)" | ||
434 | GenerateGuidsNow="$(HarvestFileGenerateGuidsNow)" | ||
435 | OutputFile="$(IntermediateOutputPath)_%(HarvestFile.Filename)_file.wxs" | ||
436 | SuppressFragments="$(HarvestFileSuppressFragments)" | ||
437 | SuppressUniqueIds="$(HarvestFileSuppressUniqueIds)" | ||
438 | Transforms="%(HarvestFile.Transforms)" | ||
439 | File="@(HarvestFile)" | ||
440 | ComponentGroupName="%(HarvestFile.ComponentGroupName)" | ||
441 | DirectoryRefId="%(HarvestFile.DirectoryRefId)" | ||
442 | PreprocessorVariable="%(HarvestFile.PreprocessorVariable)" | ||
443 | RunAsSeparateProcess="$(RunWixToolsOutOfProc)" | ||
444 | SuppressCom="%(HarvestFile.SuppressCom)" | ||
445 | SuppressRegistry="%(HarvestFile.SuppressRegistry)" | ||
446 | SuppressRootDirectory="%(HarvestFile.SuppressRootDirectory)" | ||
447 | AdditionalOptions="$(HarvestFileAdditionalOptions)"> | ||
448 | |||
449 | <Output TaskParameter="OutputFile" ItemName="Compile" /> | ||
450 | <Output TaskParameter="OutputFile" ItemName="FileWrites" /> | ||
451 | |||
452 | </HeatFile> | ||
453 | |||
454 | </Target> | ||
455 | |||
456 | <!-- | ||
457 | ================================================================================================ | ||
458 | RefreshGeneratedFile | ||
459 | |||
460 | Generates code based on metadata defined in project references. | ||
461 | |||
462 | [IN] | ||
463 | @(_MSBuildResolvedProjectReferencePaths) - The list of MSBuildable project references. | ||
464 | |||
465 | [OUT] | ||
466 | @(_GeneratedFiles) - The generated source file. | ||
467 | ================================================================================================ | ||
468 | --> | ||
469 | <PropertyGroup> | ||
470 | <RefreshGeneratedFileDependsOn></RefreshGeneratedFileDependsOn> | ||
471 | </PropertyGroup> | ||
472 | <Target Name="RefreshGeneratedFile" | ||
473 | DependsOnTargets="$(RefreshGeneratedFileDependsOn)" | ||
474 | Inputs="@(_MSBuildResolvedProjectReferencePaths);@(Compile);$(ProjectPath)" | ||
475 | Outputs="@(_GeneratedFiles)" | ||
476 | Condition=" $(EnableProjectHarvesting) and ('$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module') and '@(_GeneratedFiles)' != '' "> | ||
477 | |||
478 | <RefreshGeneratedFile | ||
479 | GeneratedFiles="@(_GeneratedFiles)" | ||
480 | ProjectReferencePaths="@(_MSBuildResolvedProjectReferencePaths)" /> | ||
481 | |||
482 | </Target> | ||
483 | |||
484 | <!-- | ||
485 | ================================================================================================ | ||
486 | RefreshBundleGeneratedFile | ||
487 | |||
488 | Generates code for bundle projects based on metadata defined in project references. | ||
489 | |||
490 | [IN] | ||
491 | @(_MSBuildResolvedProjectReferencePaths) - The list of MSBuildable project references. | ||
492 | |||
493 | [OUT] | ||
494 | @(_GeneratedFiles) - The generated source file. | ||
495 | ================================================================================================ | ||
496 | --> | ||
497 | <PropertyGroup> | ||
498 | <RefreshBundleGeneratedFileDependsOn></RefreshBundleGeneratedFileDependsOn> | ||
499 | </PropertyGroup> | ||
500 | <Target Name="RefreshBundleGeneratedFile" | ||
501 | DependsOnTargets="$(RefreshBundleGeneratedFileDependsOn)" | ||
502 | Inputs="@(_MSBuildResolvedProjectReferencePaths);@(Compile);$(ProjectPath)" | ||
503 | Outputs="@(_GeneratedFiles)" | ||
504 | Condition=" $(EnableProjectHarvesting) and ('$(OutputType)' == 'Bundle' and '@(_GeneratedFiles)' != '') "> | ||
505 | |||
506 | <RefreshBundleGeneratedFile | ||
507 | GeneratedFiles="@(_GeneratedFiles)" | ||
508 | ProjectReferencePaths="@(_MSBuildResolvedProjectReferencePaths)" /> | ||
509 | </Target> | ||
510 | |||
511 | </Project> | ||
diff --git a/src/WixToolset.BuildTasks/wix.signing.targets b/src/WixToolset.BuildTasks/wix.signing.targets new file mode 100644 index 00000000..6351cc8b --- /dev/null +++ b/src/WixToolset.BuildTasks/wix.signing.targets | |||
@@ -0,0 +1,378 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <!-- 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. --> | ||
3 | |||
4 | |||
5 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
6 | |||
7 | <!-- These properties can be overridden to support non-default installations. --> | ||
8 | <PropertyGroup> | ||
9 | <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildThisFileFullPath)</WixTargetsPath> | ||
10 | <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixTargetsPath)WixTasks.dll</WixTasksPath> | ||
11 | |||
12 | <SignedFile Condition=" '$(SignedFile)' == '' ">$(MSBuildProjectFile).Signed.txt</SignedFile> | ||
13 | </PropertyGroup> | ||
14 | |||
15 | <UsingTask TaskName="Insignia" AssemblyFile="$(WixTasksPath)" /> | ||
16 | |||
17 | <!-- Default Inscribe properties. --> | ||
18 | <PropertyGroup> | ||
19 | <InscribeNoLogo Condition=" '$(InscribeNoLogo)' == '' ">$(NoLogo)</InscribeNoLogo> | ||
20 | <InscribeSuppressAllWarnings Condition=" '$(InscribeSuppressAllWarnings)' == '' ">$(SuppressAllWarnings)</InscribeSuppressAllWarnings> | ||
21 | <InscribeSuppressSpecificWarnings Condition=" '$(InscribeSuppressSpecificWarnings)' == '' ">$(SuppressSpecificWarnings)</InscribeSuppressSpecificWarnings> | ||
22 | <InscribeTreatWarningsAsErrors Condition=" '$(InscribeTreatWarningsAsErrors)' == '' ">$(TreatWarningsAsErrors)</InscribeTreatWarningsAsErrors> | ||
23 | <InscribeTreatSpecificWarningsAsErrors Condition=" '$(InscribeTreatSpecificWarningsAsErrors)' == '' ">$(TreatSpecificWarningsAsErrors)</InscribeTreatSpecificWarningsAsErrors> | ||
24 | <InscribeVerboseOutput Condition=" '$(InscribeVerboseOutput)' == '' ">$(VerboseOutput)</InscribeVerboseOutput> | ||
25 | </PropertyGroup> | ||
26 | |||
27 | <!-- | ||
28 | ================================================================================================== | ||
29 | Signing | ||
30 | ================================================================================================== | ||
31 | --> | ||
32 | <PropertyGroup> | ||
33 | <InternalSignDependsOn Condition=" '$(OutputType)' == 'Module' "> | ||
34 | GetMsmsToSign; | ||
35 | InternalSignMsm; | ||
36 | </InternalSignDependsOn> | ||
37 | <InternalSignDependsOn Condition=" '$(OutputType)' == 'Package' "> | ||
38 | GetCabsToSign; | ||
39 | GetMsiToSign; | ||
40 | InternalSignCabs; | ||
41 | InscribeMsi; | ||
42 | InternalSignMsi; | ||
43 | </InternalSignDependsOn> | ||
44 | <InternalSignDependsOn Condition=" '$(OutputType)' == 'Bundle' "> | ||
45 | GetContainersToSign; | ||
46 | InternalSignContainers; | ||
47 | InscribeBundleEngine; | ||
48 | InternalSignBundleEngine; | ||
49 | InscribeBundle; | ||
50 | InternalSignBundle; | ||
51 | </InternalSignDependsOn> | ||
52 | |||
53 | <SigningDependsOn> | ||
54 | CompileAndLink; | ||
55 | BeforeSigning; | ||
56 | $(InternalSignDependsOn); | ||
57 | AfterSigning | ||
58 | </SigningDependsOn> | ||
59 | </PropertyGroup> | ||
60 | <Target | ||
61 | Name="Signing" | ||
62 | DependsOnTargets="$(SigningDependsOn)" | ||
63 | Inputs="@(SignTargetPath)" | ||
64 | Outputs="$(IntermediateOutputPath)$(SignedFile)" | ||
65 | Condition=" '@(SignTargetPath)' != '' "> | ||
66 | |||
67 | <CreateItem Include="$(IntermediateOutputPath)$(SignedFile)"> | ||
68 | <Output TaskParameter="Include" ItemName="FileWrites" /> | ||
69 | </CreateItem> | ||
70 | |||
71 | <WriteLinesToFile | ||
72 | File="$(IntermediateOutputPath)$(SignedFile)" | ||
73 | Lines="^$(MSBuildProjectFullPath);@(SignMsm);@(SignCabs);@(SignMsi);@(SignContainers);@(SignBundleEngine);@(SignBundle)" | ||
74 | Overwrite="true" /> | ||
75 | </Target> | ||
76 | |||
77 | <!-- Internal targets so correct signing targets are called. --> | ||
78 | <Target | ||
79 | Name="GetMsmsToSign" | ||
80 | Inputs="@(SignTargetPath)" | ||
81 | Outputs="$(IntermediateOutputPath)$(SignedFile)"> | ||
82 | <CreateItem Include="@(SignTargetPath)"> | ||
83 | <Output TaskParameter="Include" ItemName="SignMsm" /> | ||
84 | <Output TaskParameter="Include" ItemName="FileWrites" /> | ||
85 | </CreateItem> | ||
86 | </Target> | ||
87 | |||
88 | <Target | ||
89 | Name="InternalSignMsm" | ||
90 | DependsOnTargets="SignMsm" | ||
91 | Condition=" '@(SignMsm)' != '' " /> | ||
92 | |||
93 | <Target | ||
94 | Name="GetCabsToSign" | ||
95 | Inputs="@(SignTargetPath)" | ||
96 | Outputs="$(IntermediateOutputPath)$(SignedFile)"> | ||
97 | <GetCabList Database="%(SignTargetPath.FullPath)"> | ||
98 | <Output TaskParameter="CabList" ItemName="SignCabs" /> | ||
99 | <Output TaskParameter="CabList" ItemName="FileWrites" /> | ||
100 | </GetCabList> | ||
101 | </Target> | ||
102 | |||
103 | <Target | ||
104 | Name="InternalSignCabs" | ||
105 | DependsOnTargets="SignCabs" | ||
106 | Condition=" '@(SignCabs)' != '' " /> | ||
107 | |||
108 | <Target | ||
109 | Name="GetMsiToSign" | ||
110 | Inputs="@(SignTargetPath)" | ||
111 | Outputs="$(IntermediateOutputPath)$(SignedFile)"> | ||
112 | <CreateItemAvoidingInference InputProperties="@(SignTargetPath)"> | ||
113 | <Output TaskParameter="OuputItems" ItemName="SignMsi" /> | ||
114 | <Output TaskParameter="OuputItems" ItemName="FileWrites" /> | ||
115 | </CreateItemAvoidingInference> | ||
116 | </Target> | ||
117 | |||
118 | <Target | ||
119 | Name="InternalSignMsi" | ||
120 | DependsOnTargets="SignMsi" | ||
121 | Inputs="@(SignTargetPath)" | ||
122 | Outputs="$(IntermediateOutputPath)$(SignedFile)" | ||
123 | Condition=" '@(SignMsi)' != '' " /> | ||
124 | |||
125 | <Target | ||
126 | Name="GetContainersToSign" | ||
127 | Inputs="@(SignTargetPath)" | ||
128 | Outputs="$(IntermediateOutputPath)$(SignedFile)"> | ||
129 | <!-- TODO: implement signing detached containers --> | ||
130 | </Target> | ||
131 | |||
132 | <Target | ||
133 | Name="InternalSignContainers" | ||
134 | DependsOnTargets="SignContainers" | ||
135 | Condition=" '@(SignContainers)' != '' " /> | ||
136 | |||
137 | <Target | ||
138 | Name="InternalSignBundleEngine" | ||
139 | DependsOnTargets="SignBundleEngine" | ||
140 | Condition=" '@(SignBundleEngine)' != '' " /> | ||
141 | |||
142 | <Target | ||
143 | Name="InternalSignBundle" | ||
144 | DependsOnTargets="SignBundle" | ||
145 | Condition=" '@(SignBundle)' != '' " /> | ||
146 | |||
147 | <!-- | ||
148 | ================================================================================================ | ||
149 | InscribeMsi | ||
150 | |||
151 | To be called after signing an MSI's cabs - inscribes an MSI with the digital signature of its | ||
152 | external cabs. | ||
153 | |||
154 | [IN/OUT] | ||
155 | @(SignTargetPath) - The database file to inscribe - database file will be modified in-place. | ||
156 | |||
157 | [OUT] | ||
158 | @(SignMsi) - The database file to sign. | ||
159 | ================================================================================================ | ||
160 | --> | ||
161 | <PropertyGroup> | ||
162 | <InscribeMsiDependsOn> | ||
163 | PrepareForBuild; | ||
164 | ResolveWixExtensionReferences; | ||
165 | CompileAndLink; | ||
166 | InternalSignCabs | ||
167 | </InscribeMsiDependsOn> | ||
168 | </PropertyGroup> | ||
169 | <Target | ||
170 | Name="InscribeMsi" | ||
171 | DependsOnTargets="$(InscribeMsiDependsOn)" | ||
172 | Inputs="@(SignTargetPath)" | ||
173 | Outputs="$(IntermediateOutputPath)$(SignedFile)" | ||
174 | Condition=" '@(SignCabs)' != '' "> | ||
175 | |||
176 | <Insignia | ||
177 | DatabaseFile="%(SignTargetPath.FullPath)" | ||
178 | OutputFile="%(SignTargetPath.FullPath)" | ||
179 | ToolPath="$(WixToolPath)" | ||
180 | NoLogo="$(InscribeNoLogo)" | ||
181 | RunAsSeparateProcess="$(RunWixToolsOutOfProc)" | ||
182 | SuppressAllWarnings="$(InscribeSuppressAllWarnings)" | ||
183 | SuppressSpecificWarnings="$(InscribeSuppressSpecificWarnings)" | ||
184 | TreatWarningsAsErrors="$(InscribeTreatWarningsAsErrors)" | ||
185 | TreatSpecificWarningsAsErrors="$(InscribeTreatSpecificWarningsAsErrors)" | ||
186 | VerboseOutput="$(InscribeVerboseOutput)" | ||
187 | AdditionalOptions="$(InscribeAdditionalOptions)" /> | ||
188 | </Target> | ||
189 | |||
190 | <!-- | ||
191 | ================================================================================================ | ||
192 | InscribeBundleEngine | ||
193 | |||
194 | To be called after signing a bundle's detached containers. Also removes attached container | ||
195 | so engine can be signed without attached container. | ||
196 | |||
197 | [IN] | ||
198 | @(SignTargetPath) - The bundle to inscribe. | ||
199 | |||
200 | [OUT] | ||
201 | @(SignBundleEngine) - The bundle engine file to be signed. | ||
202 | ================================================================================================ | ||
203 | --> | ||
204 | <PropertyGroup> | ||
205 | <InscribeBundleEngineDependsOn> | ||
206 | PrepareForBuild; | ||
207 | ResolveWixExtensionReferences; | ||
208 | CompileAndLink; | ||
209 | InternalSignContainers | ||
210 | </InscribeBundleEngineDependsOn> | ||
211 | </PropertyGroup> | ||
212 | <Target | ||
213 | Name="InscribeBundleEngine" | ||
214 | DependsOnTargets="$(InscribeBundleEngineDependsOn)" | ||
215 | Inputs="@(SignTargetPath)" | ||
216 | Outputs="$(IntermediateOutputPath)$(SignedFile)"> | ||
217 | |||
218 | <Insignia | ||
219 | BundleFile="@(SignTargetPath)" | ||
220 | OutputFile="$(IntermediateOutputPath)%(SignTargetPath.Filename)%(SignTargetPath.Extension)" | ||
221 | ToolPath="$(WixToolPath)" | ||
222 | NoLogo="$(InscribeNoLogo)" | ||
223 | RunAsSeparateProcess="$(RunWixToolsOutOfProc)" | ||
224 | SuppressAllWarnings="$(InscribeSuppressAllWarnings)" | ||
225 | SuppressSpecificWarnings="$(InscribeSuppressSpecificWarnings)" | ||
226 | TreatWarningsAsErrors="$(InscribeTreatWarningsAsErrors)" | ||
227 | TreatSpecificWarningsAsErrors="$(InscribeTreatSpecificWarningsAsErrors)" | ||
228 | VerboseOutput="$(InscribeVerboseOutput)" | ||
229 | AdditionalOptions="$(InscribeAdditionalOptions)"> | ||
230 | <Output TaskParameter="Output" ItemName="SignBundleEngine" /> | ||
231 | </Insignia> | ||
232 | |||
233 | <!-- Explicitly add output to FileWrites to ensure even when the target is up to date. --> | ||
234 | <CreateItem Include="$(IntermediateOutputPath)%(SignTargetPath.Filename)%(SignTargetPath.Extension)"> | ||
235 | <Output TaskParameter="Include" ItemName="FileWrites" /> | ||
236 | </CreateItem> | ||
237 | |||
238 | </Target> | ||
239 | |||
240 | <!-- | ||
241 | ================================================================================================ | ||
242 | InscribeBundle | ||
243 | |||
244 | To be called after signing the bundle engine to reattach the attached container. | ||
245 | |||
246 | [IN] | ||
247 | @(Inscribe) - The bundle to inscribe. | ||
248 | |||
249 | [OUT] | ||
250 | @(SignBundle) - The bundle engine file to be signed. | ||
251 | ================================================================================================ | ||
252 | --> | ||
253 | <PropertyGroup> | ||
254 | <InscribeBundleDependsOn> | ||
255 | PrepareForBuild; | ||
256 | ResolveWixExtensionReferences; | ||
257 | CompileAndLink; | ||
258 | InternalSignBundleEngine | ||
259 | </InscribeBundleDependsOn> | ||
260 | </PropertyGroup> | ||
261 | <Target | ||
262 | Name="InscribeBundle" | ||
263 | DependsOnTargets="$(InscribeBundleDependsOn)" | ||
264 | Inputs="@(SignTargetPath)" | ||
265 | Outputs="$(IntermediateOutputPath)$(SignedFile)"> | ||
266 | |||
267 | <Insignia | ||
268 | BundleFile="@(SignBundleEngine)" | ||
269 | OriginalBundleFile="@(SignTargetPath)" | ||
270 | OutputFile="@(SignTargetPath)" | ||
271 | ToolPath="$(WixToolPath)" | ||
272 | NoLogo="$(InscribeNoLogo)" | ||
273 | RunAsSeparateProcess="$(RunWixToolsOutOfProc)" | ||
274 | SuppressAllWarnings="$(InscribeSuppressAllWarnings)" | ||
275 | SuppressSpecificWarnings="$(InscribeSuppressSpecificWarnings)" | ||
276 | TreatWarningsAsErrors="$(InscribeTreatWarningsAsErrors)" | ||
277 | TreatSpecificWarningsAsErrors="$(InscribeTreatSpecificWarningsAsErrors)" | ||
278 | VerboseOutput="$(InscribeVerboseOutput)" | ||
279 | AdditionalOptions="$(InscribeAdditionalOptions)"> | ||
280 | <Output TaskParameter="Output" ItemName="SignBundle" /> | ||
281 | <Output TaskParameter="Output" ItemName="FileWrites" /> | ||
282 | </Insignia> | ||
283 | </Target> | ||
284 | |||
285 | <!-- | ||
286 | ================================================================================================== | ||
287 | BeforeSigning | ||
288 | |||
289 | Redefine this target in your project in order to run tasks just before all signing tasks. | ||
290 | ================================================================================================== | ||
291 | --> | ||
292 | <Target Name="BeforeSigning" /> | ||
293 | |||
294 | <!-- | ||
295 | ================================================================================================== | ||
296 | SignMsm | ||
297 | |||
298 | Redefine this target in your project in order to sign merge modules. | ||
299 | |||
300 | [IN] | ||
301 | @(SignMsm) - merge module files to sign. | ||
302 | ================================================================================================== | ||
303 | --> | ||
304 | <Target Name="SignMsm" /> | ||
305 | |||
306 | <!-- | ||
307 | ================================================================================================== | ||
308 | SignCabs | ||
309 | |||
310 | Redefine this target in your project in order to sign the cabs of your database. | ||
311 | |||
312 | [IN] | ||
313 | @(SignCabs) - cabinet files to sign. | ||
314 | ================================================================================================== | ||
315 | --> | ||
316 | <Target Name="SignCabs" /> | ||
317 | |||
318 | <!-- | ||
319 | ================================================================================================== | ||
320 | SignMsi | ||
321 | |||
322 | Redefine this target in your project in order to sign your database, after it has been inscribed | ||
323 | with the signatures of your signed cabs. | ||
324 | |||
325 | [IN] | ||
326 | @(SignMsi) - database files to sign. | ||
327 | ================================================================================================== | ||
328 | --> | ||
329 | <Target Name="SignMsi" /> | ||
330 | |||
331 | <!-- | ||
332 | ================================================================================================== | ||
333 | SignContainers | ||
334 | |||
335 | Redefine this target in your project in order to sign your bundle's detached containers. | ||
336 | |||
337 | [IN] | ||
338 | @(SignContainers) - detached container files to sign. | ||
339 | ================================================================================================== | ||
340 | --> | ||
341 | <Target Name="SignContainers" /> | ||
342 | |||
343 | <!-- | ||
344 | ================================================================================================== | ||
345 | SignBundleEngine | ||
346 | |||
347 | Redefine this target in your project in order to sign your bundle, after it has been inscribed | ||
348 | with the signatures of your signed containers. | ||
349 | |||
350 | [IN] | ||
351 | @(SignBundleEngine) - bundle engine file to sign. | ||
352 | ================================================================================================== | ||
353 | --> | ||
354 | <Target Name="SignBundleEngine" /> | ||
355 | |||
356 | <!-- | ||
357 | ================================================================================================== | ||
358 | SignBundle | ||
359 | |||
360 | Redefine this target in your project in order to sign your bundle, after the attached container | ||
361 | is reattached. | ||
362 | |||
363 | [IN] | ||
364 | @(SignBundle) - bundle file to sign. | ||
365 | ================================================================================================== | ||
366 | --> | ||
367 | <Target Name="SignBundle" /> | ||
368 | |||
369 | <!-- | ||
370 | ================================================================================================== | ||
371 | AfterSigning | ||
372 | |||
373 | Redefine this target in your project in order to run tasks just after all signing tasks. | ||
374 | ================================================================================================== | ||
375 | --> | ||
376 | <Target Name="AfterSigning" /> | ||
377 | |||
378 | </Project> | ||
diff --git a/src/WixToolset.BuildTasks/wix.targets b/src/WixToolset.BuildTasks/wix.targets new file mode 100644 index 00000000..eadd33ec --- /dev/null +++ b/src/WixToolset.BuildTasks/wix.targets | |||
@@ -0,0 +1,1353 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <!-- 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. --> | ||
3 | |||
4 | |||
5 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="_CheckRequiredProperties" DefaultTargets="Build"> | ||
6 | <PropertyGroup> | ||
7 | <WixTargetsImported>true</WixTargetsImported> | ||
8 | </PropertyGroup> | ||
9 | |||
10 | <!-- | ||
11 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
12 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
13 | Extension Points | ||
14 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
15 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
16 | --> | ||
17 | |||
18 | <!-- Allow a user-customized targets files to be used as part of the build. --> | ||
19 | <Import Project="$(CustomBeforeWixTargets)" Condition=" '$(CustomBeforeWixTargets)' != '' and Exists('$(CustomBeforeWixTargets)')" /> | ||
20 | |||
21 | <!-- These properties can be overridden to support non-default installations. --> | ||
22 | <PropertyGroup> | ||
23 | <WixBinDir Condition=" '$(WixBinDir)' == ''">$(MSBuildThisFileDirectory)</WixBinDir> | ||
24 | <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixBinDir)WixToolset.BuildTasks.dll</WixTasksPath> | ||
25 | <WixHarvestTargetsPath Condition=" '$(WixHarvestTargetsPath)' == '' ">$(WixBinDir)wix.harvest.targets</WixHarvestTargetsPath> | ||
26 | <WixSigningTargetsPath Condition=" '$(WixSigningTargetsPath)' == '' ">$(WixBinDir)wix.signing.targets</WixSigningTargetsPath> | ||
27 | <LuxTargetsPath Condition=" '$(LuxTargetsPath)' == '' ">$(WixBinDir)lux.targets</LuxTargetsPath> | ||
28 | <LuxTasksPath Condition=" '$(LuxTasksPath)' == '' ">$(WixBinDir)LuxTasks.dll</LuxTasksPath> | ||
29 | </PropertyGroup> | ||
30 | |||
31 | <!-- This makes the project files a dependency of all targets so that things rebuild if they change --> | ||
32 | <PropertyGroup> | ||
33 | <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
34 | <MSBuildAllProjects Condition="Exists('$(WixHarvestTargetsPath)')">$(MSBuildAllProjects);$(WixHarvestTargetsPath)</MSBuildAllProjects> | ||
35 | <MSBuildAllProjects Condition="Exists('$(WixSigningTargetsPath)')">$(MSBuildAllProjects);$(WixSigningTargetsPath)</MSBuildAllProjects> | ||
36 | <MSBuildAllProjects Condition="Exists('$(LuxTargetsPath)')">$(MSBuildAllProjects);$(LuxTargetsPath)</MSBuildAllProjects> | ||
37 | <MSBuildAllProjects Condition="Exists('$(CustomBeforeWixTargets)')">$(MSBuildAllProjects);$(CustomBeforeWixTargets)</MSBuildAllProjects> | ||
38 | <MSBuildAllProjects Condition="Exists('$(CustomAfterWixTargets)')">$(MSBuildAllProjects);$(CustomAfterWixTargets)</MSBuildAllProjects> | ||
39 | </PropertyGroup> | ||
40 | |||
41 | <!-- | ||
42 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
43 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
44 | Declarations for Microsoft.Common.targets | ||
45 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
46 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
47 | --> | ||
48 | |||
49 | <PropertyGroup> | ||
50 | <DefaultLanguageSourceExtension>.wxs</DefaultLanguageSourceExtension> | ||
51 | <Language>wix</Language> | ||
52 | <TargetRuntime>Managed</TargetRuntime> | ||
53 | |||
54 | <!-- Use OutputName to set the AssemblyName for Microsoft.Common.targets --> | ||
55 | <OutputName Condition=" '$(OutputName)'=='' ">$(MSBuildProjectName)</OutputName> | ||
56 | <AssemblyName>$(OutputName)</AssemblyName> | ||
57 | |||
58 | <!-- Default the OutputType to a known WiX toolset TYPE. --> | ||
59 | <_OriginalOutputType>$(OutputType)</_OriginalOutputType> | ||
60 | <OutputType Condition=" '$(OutputType)' == '' ">Package</OutputType> | ||
61 | </PropertyGroup> | ||
62 | |||
63 | <!-- | ||
64 | IDE Macros available from both integrated builds and from command line builds. | ||
65 | The following properties are 'macros' that are available via IDE for pre and post build steps. | ||
66 | All of them should be added to WixBuildMacroCollection to ensure that they are shown in the UI. | ||
67 | --> | ||
68 | <PropertyGroup> | ||
69 | <TargetExt Condition=" '$(OutputType)' == 'Package' ">.msi</TargetExt> | ||
70 | <TargetExt Condition=" '$(OutputType)' == 'Module' ">.msm</TargetExt> | ||
71 | <TargetExt Condition=" '$(OutputType)' == 'PatchCreation' ">.pcp</TargetExt> | ||
72 | <TargetExt Condition=" '$(OutputType)' == 'Library' ">.wixlib</TargetExt> | ||
73 | <TargetExt Condition=" '$(OutputType)' == 'Bundle' ">.exe</TargetExt> | ||
74 | </PropertyGroup> | ||
75 | |||
76 | <!-- Provide the correct output name for the .wixpdb --> | ||
77 | <ItemGroup Condition="'$(_DebugSymbolsProduced)' == 'true'"> | ||
78 | <_DebugSymbolsIntermediatePath Include="$(PdbOutputDir)$(TargetPdbName)" Condition=" '@(_DebugSymbolsIntermediatePath)' == '' " /> | ||
79 | </ItemGroup> | ||
80 | |||
81 | <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" /> | ||
82 | |||
83 | <PropertyGroup> | ||
84 | <!-- Default pdb output path to the intermediate output directory --> | ||
85 | <PdbOutputDir Condition=" '$(PdbOutputDir)'=='' ">$(IntermediateOutputPath)</PdbOutputDir> | ||
86 | <PdbOutputDir Condition=" '$(PdbOutputDir)' != '' and !HasTrailingSlash('$(PdbOutputDir)') ">$(PdbOutputDir)\</PdbOutputDir> | ||
87 | |||
88 | <!-- Example, C:\MyProjects\MyProject\bin\debug\ --> | ||
89 | <TargetPdbDir Condition=" '$(PdbOutputDir)'!='' ">$([System.IO.Path]::GetFullPath(`$([System.IO.Path]::Combine(`$(MSBuildProjectDirectory)`, `$(PdbOutputDir)`))`))</TargetPdbDir> | ||
90 | |||
91 | <!-- Example, MySetup.wixpdb" --> | ||
92 | <TargetPdbName Condition=" '$(TargetPdbName)' == '' ">$(TargetName).wixpdb</TargetPdbName> | ||
93 | |||
94 | <!-- Example, C:\MyProjects\MyProject\bin\debug\MyPackage.wixpdb --> | ||
95 | <TargetPdbPath Condition=" '$(TargetPdbPath)' == '' ">$(TargetPdbDir)$(TargetPdbName)</TargetPdbPath> | ||
96 | </PropertyGroup> | ||
97 | |||
98 | <!-- | ||
99 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
100 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
101 | Property Declarations | ||
102 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
103 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
104 | --> | ||
105 | |||
106 | <!-- These tasks can be used as general-purpose build tasks. --> | ||
107 | <UsingTask TaskName="Candle" AssemblyFile="$(WixTasksPath)" /> | ||
108 | <UsingTask TaskName="DoIt" AssemblyFile="$(WixTasksPath)" /> | ||
109 | <UsingTask TaskName="Lit" AssemblyFile="$(WixTasksPath)" /> | ||
110 | <UsingTask TaskName="Light" AssemblyFile="$(WixTasksPath)" /> | ||
111 | <UsingTask TaskName="Torch" AssemblyFile="$(WixTasksPath)" /> | ||
112 | |||
113 | <!-- These tasks are specific to the build process defined in this file, and are not considered general-purpose build tasks. --> | ||
114 | <UsingTask TaskName="CreateItemAvoidingInference" AssemblyFile="$(WixTasksPath)" /> | ||
115 | <UsingTask TaskName="CreateProjectReferenceDefineConstants" AssemblyFile="$(WixTasksPath)" /> | ||
116 | <UsingTask TaskName="WixAssignCulture" AssemblyFile="$(WixTasksPath)" /> | ||
117 | <UsingTask TaskName="ResolveWixReferences" AssemblyFile="$(WixTasksPath)"/> | ||
118 | <UsingTask TaskName="ReplaceString" AssemblyFile="$(WixTasksPath)"/> | ||
119 | <UsingTask TaskName="GetCabList" AssemblyFile="$(WixTasksPath)" /> | ||
120 | <UsingTask TaskName="GetLooseFileList" AssemblyFile="$(WixTasksPath)" /> | ||
121 | <UsingTask TaskName="GenerateCompileWithObjectPath" AssemblyFile="$(WixTasksPath)"/> | ||
122 | |||
123 | <!-- WiX tools are 32bit EXEs, so run them out-of-proc when MSBuild is not 32bit. --> | ||
124 | <PropertyGroup> | ||
125 | <RunWixToolsOutOfProc Condition=" '$(PROCESSOR_ARCHITECTURE)'!='x86' ">true</RunWixToolsOutOfProc> | ||
126 | </PropertyGroup> | ||
127 | |||
128 | <PropertyGroup> | ||
129 | <BindContentsFile Condition=" '$(BindContentsFile)' == '' ">$(MSBuildProjectFile).BindContentsFileList.txt</BindContentsFile> | ||
130 | <BindOutputsFile Condition=" '$(BindOutputsFile)' == '' ">$(MSBuildProjectFile).BindOutputsFileList.txt</BindOutputsFile> | ||
131 | <BindBuiltOutputsFile Condition=" '$(BindBuiltOutputsFile)' == '' ">$(MSBuildProjectFile).BindBuiltOutputsFileList.txt</BindBuiltOutputsFile> | ||
132 | </PropertyGroup> | ||
133 | |||
134 | <PropertyGroup> | ||
135 | <CabinetCachePath Condition=" '$(CabinetCachePath)'=='' and '$(ReuseCabinetCache)'=='true' ">$(IntermediateOutputPath)cabcache\</CabinetCachePath> | ||
136 | </PropertyGroup> | ||
137 | |||
138 | <PropertyGroup> | ||
139 | <WixToolDir Condition=" '$(WixToolDir)' == ''">$(WixBinDir)</WixToolDir> | ||
140 | <WixExtDir Condition=" '$(WixExtDir)' == ''">$(WixToolDir)</WixExtDir> | ||
141 | </PropertyGroup> | ||
142 | |||
143 | <!-- | ||
144 | Set the SignTargetPath item directly when output is a Bundle. The AssignCultures target | ||
145 | sets SignTargetPath item for other output types based on the cultures provided. | ||
146 | --> | ||
147 | <ItemGroup> | ||
148 | <SignTargetPath Include="$(TargetPath)" Condition=" '$(OutputType)' == 'Bundle' AND '$(SignOutput)' == 'true' AND '$(SuppressLayout)' != 'true' " /> | ||
149 | </ItemGroup> | ||
150 | |||
151 | <!-- | ||
152 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
153 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
154 | Default Compiler, Linker, and Librarian Property Declarations | ||
155 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
156 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
157 | --> | ||
158 | |||
159 | <!-- If WixExtension was passed in via the command line, then convert it to an ItemGroup --> | ||
160 | <ItemGroup> | ||
161 | <WixExtension Include="$(WixExtension)" Condition=" '$(WixExtension)' != '' " /> | ||
162 | </ItemGroup> | ||
163 | |||
164 | <!-- Defaut Compiler properties. --> | ||
165 | <PropertyGroup> | ||
166 | <CompilerNoLogo Condition=" '$(CompilerNoLogo)' == '' ">$(NoLogo)</CompilerNoLogo> | ||
167 | <CompilerSuppressAllWarnings Condition=" '$(CompilerSuppressAllWarnings)' == '' ">$(SuppressAllWarnings)</CompilerSuppressAllWarnings> | ||
168 | <CompilerSuppressSpecificWarnings Condition=" '$(CompilerSuppressSpecificWarnings)' == '' ">$(SuppressSpecificWarnings)</CompilerSuppressSpecificWarnings> | ||
169 | <CompilerTreatWarningsAsErrors Condition=" '$(CompilerTreatWarningsAsErrors)' == '' ">$(TreatWarningsAsErrors)</CompilerTreatWarningsAsErrors> | ||
170 | <CompilerTreatSpecificWarningsAsErrors Condition=" '$(CompilerTreatSpecificWarningsAsErrors)' == '' ">$(TreatSpecificWarningsAsErrors)</CompilerTreatSpecificWarningsAsErrors> | ||
171 | <CompilerVerboseOutput Condition=" '$(CompilerVerboseOutput)' == '' ">$(VerboseOutput)</CompilerVerboseOutput> | ||
172 | <!-- TODO: This probably doesn't work any longer since Platform won't be defined until Microsoft.Common.targets is included --> | ||
173 | <InstallerPlatform Condition=" '$(InstallerPlatform)' == '' and '$(Platform)' != 'AnyCPU' and '$(Platform)' != 'Any CPU' ">$(Platform)</InstallerPlatform> | ||
174 | </PropertyGroup> | ||
175 | |||
176 | <!-- Default Lib properties. --> | ||
177 | <PropertyGroup> | ||
178 | <LibNoLogo Condition=" '$(LibNoLogo)' == '' ">$(NoLogo)</LibNoLogo> | ||
179 | <LibBindFiles Condition=" '$(LibBindFiles)' == '' ">$(BindFiles)</LibBindFiles> | ||
180 | <LibPedantic Condition=" '$(LibPedantic)' == '' ">$(Pedantic)</LibPedantic> | ||
181 | <LibSuppressAllWarnings Condition=" '$(LibSuppressAllWarnings)' == '' ">$(SuppressAllWarnings)</LibSuppressAllWarnings> | ||
182 | <LibSuppressSpecificWarnings Condition=" '$(LibSuppressSpecificWarnings)' == '' ">$(SuppressSpecificWarnings)</LibSuppressSpecificWarnings> | ||
183 | <LibSuppressSchemaValidation Condition=" '$(LibSuppressSchemaValidation)' == '' ">$(SuppressSchemaValidation)</LibSuppressSchemaValidation> | ||
184 | <LibSuppressIntermediateFileVersionMatching Condition=" '$(LibSuppressIntermediateFileVersionMatching)' == '' ">$(SuppressIntermediateFileVersionMatching)</LibSuppressIntermediateFileVersionMatching> | ||
185 | <LibTreatWarningsAsErrors Condition=" '$(LibTreatWarningsAsErrors)' == '' ">$(TreatWarningsAsErrors)</LibTreatWarningsAsErrors> | ||
186 | <LibTreatSpecificWarningsAsErrors Condition=" '$(LibTreatSpecificWarningsAsErrors)' == '' ">$(TreatSpecificWarningsAsErrors)</LibTreatSpecificWarningsAsErrors> | ||
187 | <LibVerboseOutput Condition=" '$(LibVerboseOutput)' == '' ">$(VerboseOutput)</LibVerboseOutput> | ||
188 | </PropertyGroup> | ||
189 | |||
190 | <!-- Default Linker properties. --> | ||
191 | <PropertyGroup> | ||
192 | <LinkerNoLogo Condition=" '$(LinkerNoLogo)' == '' ">$(NoLogo)</LinkerNoLogo> | ||
193 | <LinkerBindFiles Condition=" '$(LinkerBindFiles)' == '' ">$(BindFiles)</LinkerBindFiles> | ||
194 | <LinkerPedantic Condition=" '$(LinkerPedantic)' == '' ">$(Pedantic)</LinkerPedantic> | ||
195 | <LinkerSuppressAllWarnings Condition=" '$(LinkerSuppressAllWarnings)' == '' ">$(SuppressAllWarnings)</LinkerSuppressAllWarnings> | ||
196 | <LinkerSuppressSpecificWarnings Condition=" '$(LinkerSuppressSpecificWarnings)' == '' ">$(SuppressSpecificWarnings)</LinkerSuppressSpecificWarnings> | ||
197 | <LinkerSuppressSchemaValidation Condition=" '$(LinkerSuppressSchemaValidation)' == '' ">$(SuppressSchemaValidation)</LinkerSuppressSchemaValidation> | ||
198 | <LinkerSuppressIntermediateFileVersionMatching Condition=" '$(LinkerSuppressIntermediateFileVersionMatching)' == '' ">$(SuppressIntermediateFileVersionMatching)</LinkerSuppressIntermediateFileVersionMatching> | ||
199 | <LinkerTreatWarningsAsErrors Condition=" '$(LinkerTreatWarningsAsErrors)' == '' ">$(TreatWarningsAsErrors)</LinkerTreatWarningsAsErrors> | ||
200 | <LinkerTreatSpecificWarningsAsErrors Condition=" '$(LinkerTreatSpecificWarningsAsErrors)' == '' ">$(TreatSpecificWarningsAsErrors)</LinkerTreatSpecificWarningsAsErrors> | ||
201 | <LinkerVerboseOutput Condition=" '$(LinkerVerboseOutput)' == '' ">$(VerboseOutput)</LinkerVerboseOutput> | ||
202 | </PropertyGroup> | ||
203 | |||
204 | <!-- If BindInputPaths (or LinkerBindInputPaths) was passed in via the command line, then convert it to an ItemGroup --> | ||
205 | <ItemGroup> | ||
206 | <BindInputPaths Include="$(BindInputPaths)" Condition=" '$(BindInputPaths)' != '' " /> | ||
207 | <LinkerBindInputPaths Include="$(LinkerBindInputPaths)" Condition=" '$(LinkerBindInputPaths)' != '' " /> | ||
208 | </ItemGroup> | ||
209 | |||
210 | <!-- Default Lit and Light "properties" --> | ||
211 | <ItemGroup> | ||
212 | <LinkerBindInputPaths Condition=" '@(LinkerBindInputPaths)' == '' " Include="@(BindInputPaths)" /> | ||
213 | </ItemGroup> | ||
214 | |||
215 | <!-- | ||
216 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
217 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
218 | Initial Targets | ||
219 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
220 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
221 | --> | ||
222 | |||
223 | <!-- | ||
224 | ================================================================================================== | ||
225 | _CheckRequiredProperties | ||
226 | |||
227 | Checks properties that must be set in the main project file or on the command line before | ||
228 | using this .TARGETS file. | ||
229 | |||
230 | [IN] | ||
231 | $(OutputName) - The name of the MSI/MSM/wixlib to build (without the extension) | ||
232 | $(OutputType) - Possible values are 'package', 'PatchCreation', 'module', 'library', 'bundle' | ||
233 | ================================================================================================== | ||
234 | --> | ||
235 | <PropertyGroup> | ||
236 | <_PleaseSetThisInProjectFile>Please set this in the project file before the <Import> of the wix.targets file.</_PleaseSetThisInProjectFile> | ||
237 | <_OutputTypeDescription>The OutputType defines whether a Windows Installer package (.msi), PatchCreation (.pcp), merge module (.msm), wix library (.wixlib), or self-extracting executable (.exe) is being built. $(_PleaseSetThisInProjectFile) Possible values are 'Package', 'Module', 'Library', and 'Bundle'.</_OutputTypeDescription> | ||
238 | </PropertyGroup> | ||
239 | <Target Name="_CheckRequiredProperties"> | ||
240 | |||
241 | <Error | ||
242 | Code="WIXTARGETS100" | ||
243 | Condition=" '$(OutputName)' == '' " | ||
244 | Text="The OutputName property is not set in project "$(MSBuildProjectFile)". The OutputName defines the name of the output without a file extension. $(_PleaseSetThisInProjectFile)" /> | ||
245 | |||
246 | <Warning | ||
247 | Code="WIXTARGETS101" | ||
248 | Condition=" '$(_OriginalOutputType)' == '' " | ||
249 | Text="The OutputType property is not set in project "$(MSBuildProjectFile)". Defaulting to '$(OutputType)'. $(_OutputTypeDescription)" /> | ||
250 | |||
251 | <Error | ||
252 | Code="WIXTARGETS102" | ||
253 | Condition=" '$(OutputType)' != 'Package' and '$(OutputType)' != 'PatchCreation' and '$(OutputType)' != 'Module' and '$(OutputType)' != 'Library' and '$(OutputType)' != 'Bundle' " | ||
254 | Text="The OutputType property '$(OutputType)' is not valid in project "$(MSBuildProjectFile)". $(_OutputTypeDescription)" /> | ||
255 | |||
256 | <Error | ||
257 | Code="WIXTARGETS103" | ||
258 | Condition=" '$(MSBuildToolsVersion)' == '' OR '$(MSBuildToolsVersion)' < '4.0' " | ||
259 | Text="MSBuild v$(MSBuildToolsVersion) is not supported by the project "$(MSBuildProjectFile)". You must use MSBuild v4.0 or later." /> | ||
260 | |||
261 | </Target> | ||
262 | |||
263 | <!-- | ||
264 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
265 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
266 | Build Targets | ||
267 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
268 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
269 | --> | ||
270 | |||
271 | <!-- | ||
272 | ================================================================================================== | ||
273 | CoreBuild - OVERRIDE DependsOn | ||
274 | |||
275 | The core build step calls each of the build targets. | ||
276 | |||
277 | This is where we insert our targets into the build process. | ||
278 | ================================================================================================== | ||
279 | --> | ||
280 | <PropertyGroup> | ||
281 | <CoreBuildDependsOn> | ||
282 | BuildOnlySettings; | ||
283 | PrepareForBuild; | ||
284 | PreBuildEvent; | ||
285 | ResolveReferences; | ||
286 | |||
287 | <!--CompileAndLink;--> | ||
288 | DoIt; | ||
289 | Signing; | ||
290 | |||
291 | GetTargetPath; | ||
292 | PrepareForRun; | ||
293 | IncrementalClean; | ||
294 | PostBuildEvent | ||
295 | </CoreBuildDependsOn> | ||
296 | </PropertyGroup> | ||
297 | |||
298 | |||
299 | <!-- | ||
300 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
301 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
302 | Resolve References Targets | ||
303 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
304 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
305 | --> | ||
306 | |||
307 | <!-- | ||
308 | ================================================================================================== | ||
309 | ResolveReferences - OVERRIDE DependsOn | ||
310 | |||
311 | ================================================================================================== | ||
312 | --> | ||
313 | <PropertyGroup> | ||
314 | <ResolveReferencesDependsOn> | ||
315 | BeforeResolveReferences; | ||
316 | AssignProjectConfiguration; | ||
317 | ResolveProjectReferences; | ||
318 | ResolveWixLibraryReferences; | ||
319 | ResolveWixExtensionReferences; | ||
320 | AfterResolveReferences | ||
321 | </ResolveReferencesDependsOn> | ||
322 | </PropertyGroup> | ||
323 | |||
324 | <!-- | ||
325 | ================================================================================================ | ||
326 | ResolveProjectReferences | ||
327 | |||
328 | Builds all of the referenced projects to get their outputs. | ||
329 | |||
330 | [IN] | ||
331 | @(NonVCProjectReference) - The list of non-VC project references. | ||
332 | |||
333 | [OUT] | ||
334 | @(ProjectReferenceWithConfiguration) - The list of non-VC project references. | ||
335 | @(WixLibProjects) - Paths to any .wixlibs that were built by referenced projects. | ||
336 | ================================================================================================ | ||
337 | --> | ||
338 | <Target | ||
339 | Name="ResolveProjectReferences" | ||
340 | DependsOnTargets="AssignProjectConfiguration;_SplitProjectReferencesByFileExistence" | ||
341 | Condition=" '@(ProjectReferenceWithConfiguration)' != '' "> | ||
342 | |||
343 | <!-- Issue a warning for each non-existent project. --> | ||
344 | <Warning | ||
345 | Text="The referenced project '%(_MSBuildProjectReferenceNonexistent.Identity)' does not exist." | ||
346 | Condition=" '@(_MSBuildProjectReferenceNonexistent)' != '' " /> | ||
347 | |||
348 | <!-- | ||
349 | When building this project from the IDE or when building a .sln from the command line or | ||
350 | when only building .wixlib project references, gather the referenced build outputs. The | ||
351 | code that builds the .sln will already have built the project, so there's no need to do | ||
352 | it again here and when building only .wixlib project references we'll use the results to | ||
353 | determine which projects to build. | ||
354 | |||
355 | The ContinueOnError setting is here so that, during project load, as much information as | ||
356 | possible will be passed to the compilers. | ||
357 | --> | ||
358 | <MSBuild | ||
359 | Projects="@(_MSBuildProjectReferenceExistent)" | ||
360 | Targets="%(_MSBuildProjectReferenceExistent.Targets);GetTargetPath" | ||
361 | Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration);%(_MSBuildProjectReferenceExistent.SetPlatform)" | ||
362 | Condition="('$(BuildingSolutionFile)' == 'true' or '$(BuildingInsideVisualStudio)' == 'true' or '$(BuildProjectReferences)' != 'true') and '@(_MSBuildProjectReferenceExistent)' != '' " | ||
363 | ContinueOnError="!$(BuildingProject)"> | ||
364 | |||
365 | <Output TaskParameter="TargetOutputs" ItemName="_GatheredProjectReferencePaths" /> | ||
366 | </MSBuild> | ||
367 | |||
368 | <!-- | ||
369 | Determine which project references should be built. Note: we will not build any project references | ||
370 | if building in the IDE because it builds project references directly. | ||
371 | |||
372 | If BuildProjectReferences is 'true' (the default) then take all MSBuild project references that exist | ||
373 | on disk and add them to the list of things to build. This is the easy case. | ||
374 | --> | ||
375 | <CreateItem | ||
376 | Include="@(_MSBuildProjectReferenceExistent)" | ||
377 | Condition=" '$(BuildProjectReferences)' == 'true' and '$(BuildingInsideVisualStudio)' != 'true' "> | ||
378 | |||
379 | <Output TaskParameter="Include" ItemName="_ProjectReferencesToBuild" /> | ||
380 | </CreateItem> | ||
381 | |||
382 | <!-- | ||
383 | If BuildProjectReferences is 'wixlib' then build only the MSBuild project references that exist and | ||
384 | create a .wixlib file. That requires us to first filter the gathered project references down to only | ||
385 | those that build .wixlibs. | ||
386 | --> | ||
387 | <CreateItem | ||
388 | Include="@(_GatheredProjectReferencePaths)" | ||
389 | Condition=" '$(BuildProjectReferences)' == 'wixlib' and '%(Extension)' == '.wixlib' and '$(BuildingInsideVisualStudio)' != 'true' "> | ||
390 | |||
391 | <Output TaskParameter="Include" ItemName="_ReferencedWixLibPaths" /> | ||
392 | </CreateItem> | ||
393 | |||
394 | <!-- | ||
395 | The second step when building only 'wixlib' project references is to create the list of existing MSBuild | ||
396 | project references that do *not* build a .wixlib. These are the projects that will be skipped. | ||
397 | --> | ||
398 | <CreateItem | ||
399 | Include="@(_MSBuildProjectReferenceExistent->'%(FullPath)')" | ||
400 | Exclude="@(_ReferencedWixLibPaths->'%(MSBuildSourceProjectFile)')" | ||
401 | Condition=" '$(BuildProjectReferences)' == 'wixlib' and '$(BuildingInsideVisualStudio)' != 'true' "> | ||
402 | |||
403 | <Output TaskParameter="Include" ItemName="_ProjectReferencesToSkip" /> | ||
404 | </CreateItem> | ||
405 | |||
406 | <!-- | ||
407 | Finally, when building only 'wixlib' project references, the list of projects to build are naturally the | ||
408 | list of projects *not* being skipped. | ||
409 | --> | ||
410 | <CreateItem | ||
411 | Include="@(_MSBuildProjectReferenceExistent->'%(FullPath)')" | ||
412 | Exclude="@(_ProjectReferencesToSkip)" | ||
413 | Condition=" '$(BuildProjectReferences)' == 'wixlib' and '$(BuildingInsideVisualStudio)' != 'true' "> | ||
414 | |||
415 | <Output TaskParameter="Include" ItemName="_ProjectReferencesToBuild" /> | ||
416 | </CreateItem> | ||
417 | |||
418 | <!-- Display a warning for all projects being skipped. --> | ||
419 | <Warning | ||
420 | Text="BuildProjectReferences set to '$(BuildProjectReferences)'. Skipping the non-Library project: %(_ProjectReferencesToSkip.Identity)" | ||
421 | Condition=" '@(_ProjectReferencesToSkip)' != '' " /> | ||
422 | |||
423 | <Message | ||
424 | Importance="low" | ||
425 | Text="Project reference to build: %(_ProjectReferencesToBuild.Identity), properties: %(_ProjectReferencesToBuild.Properties)" | ||
426 | Condition=" '@(_ProjectReferencesToBuild)' != '' " /> | ||
427 | |||
428 | <!-- | ||
429 | Build referenced projects when building from the command line. | ||
430 | |||
431 | The $(ProjectReferenceBuildTargets) will normally be blank so that the project's default target | ||
432 | is used during a P2P reference. However if a custom build process requires that the referenced | ||
433 | project has a different target to build it can be specified. | ||
434 | --> | ||
435 | <MSBuild | ||
436 | Projects="@(_ProjectReferencesToBuild)" | ||
437 | Targets="$(ProjectReferenceBuildTargets)" | ||
438 | Properties="%(_ProjectReferencesToBuild.SetConfiguration);%(_ProjectReferencesToBuild.SetPlatform)" | ||
439 | Condition=" '@(_ProjectReferencesToBuild)' != '' "> | ||
440 | |||
441 | <Output TaskParameter="TargetOutputs" ItemName="_BuiltProjectReferencePaths" /> | ||
442 | </MSBuild> | ||
443 | |||
444 | <!-- | ||
445 | VC project references must build GetNativeTargetPath because neither GetTargetPath nor the return of the default build | ||
446 | target return the output for a native .vcxproj. | ||
447 | --> | ||
448 | <MSBuild | ||
449 | Projects="@(_MSBuildProjectReferenceExistent)" | ||
450 | Targets="GetNativeTargetPath" | ||
451 | Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration);%(_MSBuildProjectReferenceExistent.SetPlatform)" | ||
452 | Condition=" '@(ProjectReferenceWithConfiguration)' != '' and '%(_MSBuildProjectReferenceExistent.Extension)' == '.vcxproj' "> | ||
453 | |||
454 | <Output TaskParameter="TargetOutputs" ItemName="_ResolvedProjectReferencePaths" /> | ||
455 | <Output TaskParameter="TargetOutputs" ItemName="_MSBuildResolvedProjectReferencePaths" /> | ||
456 | </MSBuild> | ||
457 | |||
458 | <!-- Assign the unique gathered and built project references to the resolved project | ||
459 | reference paths. --> | ||
460 | <RemoveDuplicates Inputs="@(_GatheredProjectReferencePaths);@(_BuiltProjectReferencePaths)"> | ||
461 | <Output TaskParameter="Filtered" ItemName="_ResolvedProjectReferencePaths" /> | ||
462 | <Output TaskParameter="Filtered" ItemName="_MSBuildResolvedProjectReferencePaths" /> | ||
463 | </RemoveDuplicates> | ||
464 | |||
465 | <!-- Create list of all .wixlib project references. --> | ||
466 | <CreateItem | ||
467 | Include="@(_ResolvedProjectReferencePaths)" | ||
468 | Condition=" '%(Extension)' == '.wixlib' "> | ||
469 | |||
470 | <Output TaskParameter="Include" ItemName="WixLibProjects" /> | ||
471 | </CreateItem> | ||
472 | |||
473 | <Message | ||
474 | Importance="low" | ||
475 | Text="Library from referenced projects: %(WixLibProjects.Identity)" | ||
476 | Condition=" '@(WixLibProjects)' != '' " /> | ||
477 | |||
478 | </Target> | ||
479 | |||
480 | <!-- | ||
481 | ================================================================================================ | ||
482 | ResolveWixLibraryReferences | ||
483 | |||
484 | Resolve the library references to full paths. | ||
485 | |||
486 | [IN] | ||
487 | @(WixLibrary) - The list of .wixlib files. | ||
488 | |||
489 | [OUT] | ||
490 | @(_ResolvedWixLibraryPaths) - Item group with full paths to libraries | ||
491 | ================================================================================================ | ||
492 | --> | ||
493 | <PropertyGroup> | ||
494 | <ResolveWixLibraryReferencesDependsOn></ResolveWixLibraryReferencesDependsOn> | ||
495 | </PropertyGroup> | ||
496 | <Target | ||
497 | Name="ResolveWixLibraryReferences" | ||
498 | DependsOnTargets="$(ResolveWixLibraryReferencesDependsOn)" | ||
499 | Condition=" '@(WixLibrary)' != ''"> | ||
500 | |||
501 | <!-- | ||
502 | The WixLibrarySearchPaths property is set to find assemblies in the following order: | ||
503 | |||
504 | (1) $(ReferencePaths) - the reference paths property, which comes from the .USER file. | ||
505 | (2) The hintpath from the referenced item itself, indicated by {HintPathFromItem}. | ||
506 | (3) Treat the reference's Include as if it were a real file name. | ||
507 | (4) Path specified by the WixExtDir property. | ||
508 | --> | ||
509 | <CreateProperty Condition=" '$(WixLibrarySearchPaths)' == '' " Value=" | ||
510 | $(ReferencePaths); | ||
511 | {HintPathFromItem}; | ||
512 | {RawFileName}; | ||
513 | $(WixExtDir) | ||
514 | "> | ||
515 | <Output TaskParameter="Value" PropertyName="WixLibrarySearchPaths" /> | ||
516 | </CreateProperty> | ||
517 | |||
518 | <ResolveWixReferences | ||
519 | WixReferences="@(WixLibrary)" | ||
520 | SearchPaths="$(WixLibrarySearchPaths)" | ||
521 | SearchFilenameExtensions=".wixlib"> | ||
522 | <Output TaskParameter="ResolvedWixReferences" ItemName="_AllResolvedWixLibraryPaths" /> | ||
523 | </ResolveWixReferences> | ||
524 | |||
525 | <!-- Remove duplicate library items that would cause build errors --> | ||
526 | <RemoveDuplicates Inputs="@(_AllResolvedWixLibraryPaths)"> | ||
527 | <Output TaskParameter="Filtered" ItemName="_ResolvedWixLibraryPaths" /> | ||
528 | </RemoveDuplicates> | ||
529 | |||
530 | </Target> | ||
531 | |||
532 | <!-- | ||
533 | ================================================================================================== | ||
534 | ResolveWixExtensionReferences | ||
535 | |||
536 | Resolves WiX extension references to full paths. Any properties you use | ||
537 | to resolve paths to extensions must be defined before importing this | ||
538 | file or the extensions will be automatically resolved to $(WixExtDir). | ||
539 | |||
540 | [IN] | ||
541 | @(WixExtension) - WixExtension item group | ||
542 | |||
543 | [OUT] | ||
544 | @(_ResolvedWixExtensionPaths) - Item group with full paths to extensions | ||
545 | ================================================================================================== | ||
546 | --> | ||
547 | <PropertyGroup> | ||
548 | <ResolveWixExtensionReferencesDependsOn></ResolveWixExtensionReferencesDependsOn> | ||
549 | </PropertyGroup> | ||
550 | <Target | ||
551 | Name="ResolveWixExtensionReferences" | ||
552 | DependsOnTargets="$(ResolveWixExtensionReferencesDependsOn)" | ||
553 | Condition=" '@(WixExtension)' != ''"> | ||
554 | |||
555 | <!-- | ||
556 | The WixExtensionSearchPaths property is set to find assemblies in the following order: | ||
557 | |||
558 | (1) $(ReferencePaths) - the reference paths property, which comes from the .USER file. | ||
559 | (2) The hintpath from the referenced item itself, indicated by {HintPathFromItem}. | ||
560 | (3) Treat the reference's Include as if it were a real file name. | ||
561 | (4) Path specified by the WixExtDir property. | ||
562 | --> | ||
563 | <CreateProperty Condition=" '$(WixExtensionSearchPaths)' == '' " Value=" | ||
564 | $(ReferencePaths); | ||
565 | {HintPathFromItem}; | ||
566 | {RawFileName}; | ||
567 | $(WixExtDir) | ||
568 | "> | ||
569 | <Output TaskParameter="Value" PropertyName="WixExtensionSearchPaths" /> | ||
570 | </CreateProperty> | ||
571 | |||
572 | <ResolveWixReferences | ||
573 | WixReferences="@(WixExtension)" | ||
574 | SearchPaths="$(WixExtensionSearchPaths)" | ||
575 | SearchFilenameExtensions=".dll"> | ||
576 | <Output TaskParameter="ResolvedWixReferences" ItemName="_AllResolvedWixExtensionPaths" /> | ||
577 | </ResolveWixReferences> | ||
578 | |||
579 | <!-- Remove duplicate extension items that would cause build errors --> | ||
580 | <RemoveDuplicates Inputs="@(_AllResolvedWixExtensionPaths)"> | ||
581 | <Output TaskParameter="Filtered" ItemName="_ResolvedWixExtensionPaths" /> | ||
582 | </RemoveDuplicates> | ||
583 | </Target> | ||
584 | |||
585 | <!-- | ||
586 | ================================================================================================ | ||
587 | GetTargetPath - OVERRIDE DependsOn | ||
588 | |||
589 | This stand-alone target returns the name of the build product (i.e. MSI, MSM) that would be | ||
590 | produced if we built this project. | ||
591 | ================================================================================================ | ||
592 | --> | ||
593 | <PropertyGroup> | ||
594 | <GetTargetPathDependsOn>AssignCultures</GetTargetPathDependsOn> | ||
595 | </PropertyGroup> | ||
596 | |||
597 | |||
598 | <!-- | ||
599 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
600 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
601 | DoIt Targets | ||
602 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
603 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
604 | --> | ||
605 | |||
606 | <!-- | ||
607 | ================================================================================================== | ||
608 | DoIt | ||
609 | ================================================================================================== | ||
610 | --> | ||
611 | <PropertyGroup> | ||
612 | <DoItDependsOn> | ||
613 | PrepareForBuild; | ||
614 | ResolveReferences; | ||
615 | BeforeCompile; | ||
616 | _TimeStampBeforeCompile; | ||
617 | Harvest; | ||
618 | |||
619 | CalculateDefineConstants; | ||
620 | GenerateCompileWithObjectPath; | ||
621 | |||
622 | AssignCultures; | ||
623 | ReadPreviousBindInputsAndBuiltOutputs; | ||
624 | |||
625 | ActuallyDoIt; | ||
626 | |||
627 | UpdateLinkFileWrites; | ||
628 | _TimeStampAfterCompile; | ||
629 | AfterCompile | ||
630 | </DoItDependsOn> | ||
631 | </PropertyGroup> | ||
632 | <Target | ||
633 | Name="DoIt" | ||
634 | DependsOnTargets="$(DoItDependsOn)" /> | ||
635 | |||
636 | <Target | ||
637 | Name="ActuallyDoIt" | ||
638 | |||
639 | Inputs="@(Compile); | ||
640 | @(Content); | ||
641 | @(EmbeddedResource); | ||
642 | @(WixObject); | ||
643 | @(_ResolvedProjectReferencePaths); | ||
644 | @(_ResolvedWixLibraryPaths); | ||
645 | @(_ResolvedWixExtensionPaths); | ||
646 | @(_BindInputs); | ||
647 | $(MSBuildAllProjects)" | ||
648 | Outputs="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile);@(_BindBuiltOutputs)" | ||
649 | Condition=" '@(Compile)' != '' and ('$(OutputType)' == 'Bundle' or '$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module')"> | ||
650 | |||
651 | |||
652 | <PropertyGroup> | ||
653 | <PdbOutputFile>$(TargetPdbDir)%(CultureGroup.OutputFolder)$(TargetPdbName)</PdbOutputFile> | ||
654 | </PropertyGroup> | ||
655 | |||
656 | <DoIt | ||
657 | SourceFiles="@(_CompileWithObjectPath)" | ||
658 | LocalizationFiles="@(EmbeddedResource)" | ||
659 | ObjectFiles="@(CompileObjOutput);@(WixObject);@(WixLibProjects);@(_ResolvedWixLibraryPaths)" | ||
660 | |||
661 | Cultures="%(CultureGroup.Identity)" | ||
662 | |||
663 | ExtensionDirectory="$(WixExtDir)" | ||
664 | Extensions="@(_ResolvedWixExtensionPaths)" | ||
665 | |||
666 | IntermediateDirectory="$(IntermediateOutputPath)" | ||
667 | |||
668 | OutputFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(TargetName)$(TargetExt)" | ||
669 | PdbOutputFile="$(PdbOutputFile)" | ||
670 | |||
671 | AdditionalOptions="$(CompilerAdditionalOptions) $(LinkerAdditionalOptions)" | ||
672 | DefineConstants="$(DefineConstants);$(SolutionDefineConstants);$(ProjectDefineConstants);$(ProjectReferenceDefineConstants)" | ||
673 | IncludeSearchPaths="$(IncludeSearchPaths)" | ||
674 | InstallerPlatform="$(InstallerPlatform)" | ||
675 | NoLogo="true" | ||
676 | Pedantic="$(Pedantic)" | ||
677 | ReferencePaths="$(ReferencePaths)" | ||
678 | |||
679 | SuppressSpecificWarnings="$(CompilerSuppressSpecificWarnings);$(LinkerSuppressSpecificWarnings)" | ||
680 | TreatSpecificWarningsAsErrors="$(CompilerTreatSpecificWarningsAsErrors)" | ||
681 | |||
682 | BindInputPaths="@(LinkerBindInputPaths)" | ||
683 | BindFiles="$(LinkerBindFiles)" | ||
684 | BindContentsFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)" | ||
685 | BindOutputsFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)" | ||
686 | BindBuiltOutputsFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)" | ||
687 | |||
688 | CabinetCachePath="$(CabinetCachePath)" | ||
689 | CabinetCreationThreadCount="$(CabinetCreationThreadCount)" | ||
690 | DefaultCompressionLevel="$(DefaultCompressionLevel)" | ||
691 | |||
692 | UnreferencedSymbolsFile="$(UnreferencedSymbolsFile)" | ||
693 | WixProjectFile="$(ProjectPath)" | ||
694 | WixVariables="$(WixVariables)" | ||
695 | |||
696 | SuppressValidation="$(SuppressValidation)" | ||
697 | SuppressIces="$(SuppressIces)" | ||
698 | AdditionalCub="$(AdditionalCub)" /> | ||
699 | |||
700 | <!-- | ||
701 | SuppressAllWarnings="$(CompilerSuppressAllWarnings);$(LinkerSuppressAllWarnings)" | ||
702 | TreatWarningsAsErrors="$(CompilerTreatWarningsAsErrors);$(LinkerTreatWarningsAsErrors)" | ||
703 | VerboseOutput="$(CompilerVerboseOutput);$(LinkerVerboseOutput)" | ||
704 | --> | ||
705 | |||
706 | </Target> | ||
707 | |||
708 | |||
709 | <!-- | ||
710 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
711 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
712 | CompileAndLink Targets | ||
713 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
714 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
715 | --> | ||
716 | |||
717 | <!-- | ||
718 | ================================================================================================== | ||
719 | CompileAndLink | ||
720 | ================================================================================================== | ||
721 | --> | ||
722 | <PropertyGroup> | ||
723 | <CompileAndLinkDependsOn> | ||
724 | ResolveReferences; | ||
725 | BeforeCompile; | ||
726 | _TimeStampBeforeCompile; | ||
727 | Harvest; | ||
728 | Compile; | ||
729 | Lib; | ||
730 | Link; | ||
731 | UpdateLinkFileWrites; | ||
732 | _TimeStampAfterCompile; | ||
733 | AfterCompile | ||
734 | </CompileAndLinkDependsOn> | ||
735 | </PropertyGroup> | ||
736 | <Target | ||
737 | Name="CompileAndLink" | ||
738 | DependsOnTargets="$(CompileAndLinkDependsOn)" /> | ||
739 | |||
740 | <!-- | ||
741 | ================================================================================================== | ||
742 | CalculateDefineConstants | ||
743 | |||
744 | Adds project references to the constants passed into the compiler. | ||
745 | |||
746 | [IN] | ||
747 | @(_ResolvedProjectReferencePaths) - paths to projects' outputs | ||
748 | $(VSProjectConfigurations) - map of project names to configurations, provided by VS when building in the IDE | ||
749 | |||
750 | [OUT] | ||
751 | $(ProjectReferenceDefineConstants) - the list of referenced project variables to be passed into the compiler | ||
752 | ================================================================================================== | ||
753 | --> | ||
754 | <PropertyGroup> | ||
755 | <CalculateDefineConstantsDependsOn>ResolveReferences</CalculateDefineConstantsDependsOn> | ||
756 | </PropertyGroup> | ||
757 | <Target | ||
758 | Name="CalculateDefineConstants" | ||
759 | DependsOnTargets="$(CalculateDefineConstantsDependsOn)" | ||
760 | Condition=" '@(_ResolvedProjectReferencePaths)' != '' "> | ||
761 | |||
762 | <PropertyGroup> | ||
763 | <ProjectDefineConstants> | ||
764 | Configuration=$(ConfigurationName); | ||
765 | OutDir=$(OutDir); | ||
766 | Platform=$(PlatformName); | ||
767 | ProjectDir=$(ProjectDir); | ||
768 | ProjectExt=$(ProjectExt); | ||
769 | ProjectFileName=$(ProjectFileName); | ||
770 | ProjectName=$(ProjectName); | ||
771 | ProjectPath=$(ProjectPath); | ||
772 | TargetDir=$(TargetDir); | ||
773 | TargetExt=$(TargetExt); | ||
774 | TargetFileName=$(TargetFileName); | ||
775 | TargetName=$(TargetName); | ||
776 | TargetPath=$(TargetPath); | ||
777 | </ProjectDefineConstants> | ||
778 | </PropertyGroup> | ||
779 | |||
780 | <PropertyGroup> | ||
781 | <SolutionDefineConstants Condition=" '$(DevEnvDir)'!='*Undefined*' ">$(SolutionDefineConstants);DevEnvDir=$(DevEnvDir)</SolutionDefineConstants> | ||
782 | <SolutionDefineConstants Condition=" '$(SolutionDir)'!='*Undefined*' ">$(SolutionDefineConstants);SolutionDir=$(SolutionDir)</SolutionDefineConstants> | ||
783 | <SolutionDefineConstants Condition=" '$(SolutionExt)'!='*Undefined*' ">$(SolutionDefineConstants);SolutionExt=$(SolutionExt)</SolutionDefineConstants> | ||
784 | <SolutionDefineConstants Condition=" '$(SolutionFileName)'!='*Undefined*' ">$(SolutionDefineConstants);SolutionFileName=$(SolutionFileName)</SolutionDefineConstants> | ||
785 | <SolutionDefineConstants Condition=" '$(SolutionName)'!='*Undefined*' ">$(SolutionDefineConstants);SolutionName=$(SolutionName)</SolutionDefineConstants> | ||
786 | <SolutionDefineConstants Condition=" '$(SolutionPath)'!='*Undefined*' ">$(SolutionDefineConstants);SolutionPath=$(SolutionPath)</SolutionDefineConstants> | ||
787 | </PropertyGroup> | ||
788 | |||
789 | <CreateProjectReferenceDefineConstants | ||
790 | ProjectReferencePaths="@(_ResolvedProjectReferencePaths)" | ||
791 | ProjectConfigurations="$(VSProjectConfigurations)"> | ||
792 | |||
793 | <Output TaskParameter="DefineConstants" PropertyName="ProjectReferenceDefineConstants" /> | ||
794 | </CreateProjectReferenceDefineConstants> | ||
795 | </Target> | ||
796 | |||
797 | <!-- | ||
798 | ================================================================================================ | ||
799 | GenerateCompileWithObjectPath | ||
800 | |||
801 | Generates metadata on the for compile output objects. | ||
802 | |||
803 | ================================================================================================ | ||
804 | --> | ||
805 | <PropertyGroup> | ||
806 | <GenerateCompileWithObjectPathDependsOn></GenerateCompileWithObjectPathDependsOn> | ||
807 | </PropertyGroup> | ||
808 | <Target | ||
809 | Name="GenerateCompileWithObjectPath" | ||
810 | Condition=" '@(Compile)' != '' "> | ||
811 | |||
812 | <GenerateCompileWithObjectPath | ||
813 | Compile="@(Compile)" | ||
814 | IntermediateOutputPath="$(IntermediateOutputPath)"> | ||
815 | <Output TaskParameter="CompileWithObjectPath" ItemName="_CompileWithObjectPath" /> | ||
816 | </GenerateCompileWithObjectPath> | ||
817 | |||
818 | </Target> | ||
819 | |||
820 | <!-- | ||
821 | ================================================================================================ | ||
822 | Compile | ||
823 | |||
824 | Compiles the wxs files into wixobj files using candle.exe. | ||
825 | |||
826 | [IN] | ||
827 | @(Compile) - The list of wxs files to compile. | ||
828 | @(Content) - Files that the project uses in the installer. | ||
829 | @(WixExtension) - The list of wixlib or wix dll extensions. | ||
830 | |||
831 | [OUT] | ||
832 | @(CompileObjOutput) - The compiled .wixobj files. | ||
833 | ================================================================================================ | ||
834 | --> | ||
835 | <PropertyGroup> | ||
836 | <CompileDependsOn> | ||
837 | PrepareForBuild; | ||
838 | ResolveReferences; | ||
839 | CalculateDefineConstants; | ||
840 | GenerateCompileWithObjectPath | ||
841 | </CompileDependsOn> | ||
842 | </PropertyGroup> | ||
843 | <Target | ||
844 | Name="Compile" | ||
845 | Inputs="@(Compile); | ||
846 | @(Content); | ||
847 | @(_ResolvedWixExtensionPaths); | ||
848 | @(_ResolvedProjectReferencePaths); | ||
849 | $(MSBuildAllProjects)" | ||
850 | Outputs="@(_CompileWithObjectPath -> '%(ObjectPath)%(Filename).wixobj')" | ||
851 | DependsOnTargets="$(CompileDependsOn)" | ||
852 | Condition=" '@(Compile)' != '' "> | ||
853 | |||
854 | <Candle | ||
855 | SourceFiles="@(_CompileWithObjectPath)" | ||
856 | AdditionalOptions="$(CompilerAdditionalOptions)" | ||
857 | DefineConstants="$(DefineConstants);$(SolutionDefineConstants);$(ProjectDefineConstants);$(ProjectReferenceDefineConstants)" | ||
858 | ExtensionDirectory="$(WixExtDir)" | ||
859 | Extensions="@(_ResolvedWixExtensionPaths)" | ||
860 | PreprocessToStdOut="$(PreprocessToStdOut)" | ||
861 | PreprocessToFile="$(PreprocessToFile)" | ||
862 | IncludeSearchPaths="$(IncludeSearchPaths)" | ||
863 | InstallerPlatform="$(InstallerPlatform)" | ||
864 | IntermediateDirectory="$(IntermediateOutputPath)" | ||
865 | NoLogo="$(CompilerNoLogo)" | ||
866 | OutputFile="%(_CompileWithObjectPath.ObjectPath)" | ||
867 | Pedantic="$(Pedantic)" | ||
868 | ReferencePaths="$(ReferencePaths)" | ||
869 | RunAsSeparateProcess="$(RunWixToolsOutOfProc)" | ||
870 | SuppressAllWarnings="$(CompilerSuppressAllWarnings)" | ||
871 | SuppressSpecificWarnings="$(CompilerSuppressSpecificWarnings)" | ||
872 | ToolPath="$(WixToolDir)" | ||
873 | TreatWarningsAsErrors="$(CompilerTreatWarningsAsErrors)" | ||
874 | TreatSpecificWarningsAsErrors="$(CompilerTreatSpecificWarningsAsErrors)" | ||
875 | VerboseOutput="$(CompilerVerboseOutput)"> | ||
876 | </Candle> | ||
877 | |||
878 | <!-- These will be still be set even if the Compile target is up to date. --> | ||
879 | <ItemGroup> | ||
880 | <CompileObjOutput Include="@(_CompileWithObjectPath -> '%(ObjectPath)%(Filename).wixobj')" /> | ||
881 | <FileWrites Include="@(CompileObjOutput)" /> | ||
882 | </ItemGroup> | ||
883 | </Target> | ||
884 | |||
885 | <!-- | ||
886 | ================================================================================================ | ||
887 | Lib | ||
888 | |||
889 | Links the .wixobj, .wxl, .wixlib, wix extensions into a .wixlib file using lit.exe. | ||
890 | |||
891 | [IN] | ||
892 | @(CompileObjOutput) - The compiled .wixobj file. | ||
893 | @(EmbeddedResource) - The list of wxl files to use for localization. | ||
894 | @(WixObject) - The list of .wixobj files. | ||
895 | @(WixLibrary) - The list of .wixlib files. | ||
896 | @(WixExtension) - The list of wix dll extension files. | ||
897 | |||
898 | [OUT] | ||
899 | $(TargetPath) - The compiled .wixlib file. | ||
900 | ================================================================================================ | ||
901 | --> | ||
902 | <PropertyGroup> | ||
903 | <LibDependsOn> | ||
904 | PrepareForBuild; | ||
905 | ResolveReferences | ||
906 | </LibDependsOn> | ||
907 | </PropertyGroup> | ||
908 | <Target | ||
909 | Name="Lib" | ||
910 | Inputs="@(CompileObjOutput); | ||
911 | @(EmbeddedResource); | ||
912 | @(WixObject); | ||
913 | @(WixLibrary); | ||
914 | @(_ResolvedWixExtensionPaths); | ||
915 | $(MSBuildAllProjects)" | ||
916 | Outputs="$(TargetPath)" | ||
917 | DependsOnTargets="$(LibDependsOn)" | ||
918 | Condition=" '$(OutputType)' == 'Library' "> | ||
919 | |||
920 | <Lit | ||
921 | ObjectFiles="@(CompileObjOutput);@(WixObject);@(WixLibProjects);@(WixLibrary)" | ||
922 | AdditionalOptions="$(LibAdditionalOptions)" | ||
923 | BindInputPaths="@(LinkerBindInputPaths)" | ||
924 | BindFiles="$(LibBindFiles)" | ||
925 | ExtensionDirectory="$(WixExtDir)" | ||
926 | Extensions="@(_ResolvedWixExtensionPaths)" | ||
927 | LocalizationFiles="@(EmbeddedResource)" | ||
928 | NoLogo="$(LibNoLogo)" | ||
929 | OutputFile="$(TargetPath)" | ||
930 | Pedantic="$(LibPedantic)" | ||
931 | ReferencePaths="$(ReferencePaths)" | ||
932 | RunAsSeparateProcess="$(RunWixToolsOutOfProc)" | ||
933 | SuppressAllWarnings="$(LibSuppressAllWarnings)" | ||
934 | SuppressIntermediateFileVersionMatching="$(LibSuppressIntermediateFileVersionMatching)" | ||
935 | SuppressSchemaValidation="$(LibSuppressSchemaValidation)" | ||
936 | SuppressSpecificWarnings="$(LibSuppressSpecificWarnings)" | ||
937 | ToolPath="$(WixToolDir)" | ||
938 | TreatWarningsAsErrors="$(LibTreatWarningsAsErrors)" | ||
939 | VerboseOutput="$(LibVerboseOutput)" /> | ||
940 | </Target> | ||
941 | |||
942 | <!-- | ||
943 | ================================================================================================ | ||
944 | AssignCultures | ||
945 | |||
946 | Determines the final list of culture groups to build based on either the Cultures property or | ||
947 | those specified in .wxl files. | ||
948 | |||
949 | Culture groups specified in the Cultures property must be specified as a semi-colon | ||
950 | delimited list of groups, with comma-delimited cultures within a group. | ||
951 | For example: | ||
952 | <Cultures>en-US,en;en-GB,en</Cultures> | ||
953 | This will build 2 targets, outputing to en-US and en-GB sub-folders. Light will first look | ||
954 | for strings in the first culture (en-US or en-GB) then the second (en). | ||
955 | |||
956 | Cultures of .wxl files will be used when the Culture property is not set. The culture of a | ||
957 | .wxl file is determined by the Culture attribute in the WixLocalization element in the file | ||
958 | |||
959 | Sets the OutputFolder metadata on each culture group. In most cases this is the same as the | ||
960 | first culture in the culture group. When the Culture's property is unspecified and no .wxl | ||
961 | files are provided this is the same as the output directory. When the Culture's property | ||
962 | specifies a single culture group and no .wxl files are provided this is the same as the output | ||
963 | directory. | ||
964 | |||
965 | Updates the TargetPath and TargetPdbPath properties to be used in subsequent targets. | ||
966 | |||
967 | [IN] | ||
968 | @(EmbeddedResource) - The list of wxl files to use for localization. | ||
969 | $(Cultures) - The list of culture groups to build. | ||
970 | |||
971 | [OUT] | ||
972 | @(CultureGroup) - The list of culture group strings with OutputFolder metadata | ||
973 | $(TargetPath) - Property list of target link output MSIs/MSMs | ||
974 | $(TargetPdbPath) - Property list of target output pdbs | ||
975 | @(SignTargetPath) - The list of target to be signed | ||
976 | |||
977 | ================================================================================================ | ||
978 | --> | ||
979 | <Target | ||
980 | Name="AssignCultures" | ||
981 | Condition=" '$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module' "> | ||
982 | |||
983 | <WixAssignCulture | ||
984 | Cultures="$(Cultures)" | ||
985 | Files="@(EmbeddedResource)"> | ||
986 | |||
987 | <Output TaskParameter="CultureGroups" ItemName="CultureGroup" /> | ||
988 | </WixAssignCulture> | ||
989 | |||
990 | <!-- Build an itemgroup of outputs --> | ||
991 | <ItemGroup> | ||
992 | <_TargetPathItems Include="$(TargetDir)%(CultureGroup.OutputFolder)$(TargetName)$(TargetExt)" /> | ||
993 | <_TargetPdbPathItems Include="$(TargetPdbDir)%(CultureGroup.OutputFolder)$(TargetPdbName)" /> | ||
994 | </ItemGroup> | ||
995 | |||
996 | <!-- Convert the itemgroup to a semicolon-delimited property --> | ||
997 | <PropertyGroup> | ||
998 | <TargetPath>@(_TargetPathItems)</TargetPath> | ||
999 | <TargetPdbPath>@(_TargetPdbPathItems)</TargetPdbPath> | ||
1000 | </PropertyGroup> | ||
1001 | |||
1002 | <!-- Set the sign target items, if we're signing output. --> | ||
1003 | <ItemGroup Condition=" '$(SignOutput)' == 'true' AND '$(SuppressLayout)' != 'true' "> | ||
1004 | <SignTargetPath Include="@(_TargetPathItems)" /> | ||
1005 | </ItemGroup> | ||
1006 | </Target> | ||
1007 | |||
1008 | <!-- | ||
1009 | ================================================================================================ | ||
1010 | ReadPreviousBindInputsAndBuiltOutputs | ||
1011 | |||
1012 | Reads a previous build's Bind contents and built outputs file into @(_BindInputs) and | ||
1013 | @(_BindBuiltOutputs) respectively. | ||
1014 | |||
1015 | Note: Only the *built* outputs are used because using files copied to output folder | ||
1016 | can cause perpetual incremental build. | ||
1017 | |||
1018 | Imagine the case where you have: Msi.wixproj -> Lib.wixproj -> Exe.csproj. The | ||
1019 | Exe.csproj cannot be both an input to Lib.wixproj and an output of Msi.wixproj | ||
1020 | (as an uncompressed file) because the Lib.wixproj will always newer than the | ||
1021 | Exe.csproj. | ||
1022 | |||
1023 | [IN] | ||
1024 | |||
1025 | [OUT] | ||
1026 | @(_BindInputs) - the content files required to bind (i.e. the Binary/@SourceFile and File/@Source files). | ||
1027 | @(_BindBuiltOutputs) - the previously built .msi, .msm, .pcp, .exe .wixpdb, .cabs, etc. | ||
1028 | Does not include content copied to output folder. | ||
1029 | ================================================================================================ | ||
1030 | --> | ||
1031 | <Target | ||
1032 | Name="ReadPreviousBindInputsAndBuiltOutputs" | ||
1033 | Condition=" '$(OutputType)' == 'Bundle' or '$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module' "> | ||
1034 | |||
1035 | <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)"> | ||
1036 | <Output TaskParameter="Lines" ItemName="_BindInputs" /> | ||
1037 | </ReadLinesFromFile> | ||
1038 | |||
1039 | <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)"> | ||
1040 | <Output TaskParameter="Lines" ItemName="_BindBuiltOutputs" /> | ||
1041 | </ReadLinesFromFile> | ||
1042 | |||
1043 | <Message Importance="low" Text="Previous bind inputs: @(_BindInputs)" /> | ||
1044 | <Message Importance="low" Text="Previous bind outputs: @(_BindBuiltOutputs)" /> | ||
1045 | </Target> | ||
1046 | |||
1047 | <!-- | ||
1048 | ================================================================================================ | ||
1049 | Link | ||
1050 | |||
1051 | Links the .wixobj, .wxl, .wixlib, wix extensions into an .msi or .msm file using light.exe, | ||
1052 | once per culture group. All WXL files are passed into light and the culture switch determines | ||
1053 | which are used | ||
1054 | |||
1055 | [IN] | ||
1056 | @(CompileObjOutput) - The compiled .wixobj file. | ||
1057 | @(CultureGroup) - The cultures to build | ||
1058 | @(EmbeddedResource) - The list of wxl files to use for localization. | ||
1059 | @(WixObject) - The list of .wixobj files. | ||
1060 | @(WixLibrary) - The list of .wixlib files. | ||
1061 | @(WixExtension) - The list of wix dll extension files. | ||
1062 | |||
1063 | [OUT] | ||
1064 | $(TargetDir)\%(Culture)\$(TargetName)$(TargetExt) - The compiled .msi, .msm, or .exe files. | ||
1065 | ================================================================================================ | ||
1066 | --> | ||
1067 | <PropertyGroup> | ||
1068 | <LinkDependsOn> | ||
1069 | PrepareForBuild; | ||
1070 | ResolveReferences; | ||
1071 | AssignCultures; | ||
1072 | ReadPreviousBindInputsAndBuiltOutputs; | ||
1073 | </LinkDependsOn> | ||
1074 | </PropertyGroup> | ||
1075 | <Target | ||
1076 | Name="Link" | ||
1077 | Inputs="@(CompileObjOutput); | ||
1078 | @(EmbeddedResource); | ||
1079 | @(WixObject); | ||
1080 | @(_ResolvedProjectReferencePaths); | ||
1081 | @(_ResolvedWixLibraryPaths); | ||
1082 | @(_ResolvedWixExtensionPaths); | ||
1083 | $(MSBuildAllProjects); | ||
1084 | @(_BindInputs)" | ||
1085 | Outputs="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile);@(_BindBuiltOutputs)" | ||
1086 | DependsOnTargets="$(LinkDependsOn)" | ||
1087 | Condition=" '$(OutputType)' == 'Bundle' or '$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module' "> | ||
1088 | |||
1089 | <PropertyGroup> | ||
1090 | <PdbOutputFile>$(TargetPdbDir)%(CultureGroup.OutputFolder)$(TargetPdbName)</PdbOutputFile> | ||
1091 | </PropertyGroup> | ||
1092 | |||
1093 | <!-- Call light using the culture subdirectory for output --> | ||
1094 | <Light | ||
1095 | ObjectFiles="@(CompileObjOutput);@(WixObject);@(WixLibProjects);@(_ResolvedWixLibraryPaths)" | ||
1096 | AdditionalOptions="$(LinkerAdditionalOptions)" | ||
1097 | AllowIdenticalRows="$(AllowIdenticalRows)" | ||
1098 | AllowUnresolvedReferences="$(AllowUnresolvedReferences)" | ||
1099 | AdditionalCub="$(AdditionalCub)" | ||
1100 | BackwardsCompatibleGuidGeneration="$(BackwardsCompatibleGuidGeneration)" | ||
1101 | BindInputPaths="@(LinkerBindInputPaths)" | ||
1102 | BindFiles="$(LinkerBindFiles)" | ||
1103 | BindContentsFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)" | ||
1104 | BindOutputsFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)" | ||
1105 | BindBuiltOutputsFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)" | ||
1106 | CabinetCachePath="$(CabinetCachePath)" | ||
1107 | CabinetCreationThreadCount="$(CabinetCreationThreadCount)" | ||
1108 | Cultures="%(CultureGroup.Identity)" | ||
1109 | CustomBinder="$(CustomBinder)" | ||
1110 | DefaultCompressionLevel="$(DefaultCompressionLevel)" | ||
1111 | DropUnrealTables="$(DropUnrealTables)" | ||
1112 | ExactAssemblyVersions="$(ExactAssemblyVersions)" | ||
1113 | ExtensionDirectory="$(WixExtDir)" | ||
1114 | Extensions="@(_ResolvedWixExtensionPaths)" | ||
1115 | Ices="$(Ices)" | ||
1116 | LeaveTemporaryFiles="$(LeaveTemporaryFiles)" | ||
1117 | LocalizationFiles="@(EmbeddedResource)" | ||
1118 | NoLogo="$(LinkerNoLogo)" | ||
1119 | OutputAsXml="$(OutputAsXml)" | ||
1120 | OutputFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(TargetName)$(TargetExt)" | ||
1121 | PdbOutputFile="$(PdbOutputFile)" | ||
1122 | Pedantic="$(LinkerPedantic)" | ||
1123 | ReferencePaths="$(ReferencePaths)" | ||
1124 | ReuseCabinetCache="$(ReuseCabinetCache)" | ||
1125 | RunAsSeparateProcess="$(RunWixToolsOutOfProc)" | ||
1126 | SuppressAclReset="$(SuppressAclReset)" | ||
1127 | SuppressAllWarnings="$(LinkerSuppressAllWarnings)" | ||
1128 | SuppressAssemblies="$(SuppressAssemblies)" | ||
1129 | SuppressDefaultAdminSequenceActions="$(SuppressDefaultAdminSequenceActions)" | ||
1130 | SuppressDefaultAdvSequenceActions="$(SuppressDefaultAdvSequenceActions)" | ||
1131 | SuppressDefaultUISequenceActions="$(SuppressDefaultUISequenceActions)" | ||
1132 | SuppressFileHashAndInfo="$(SuppressFileHashAndInfo)" | ||
1133 | SuppressFiles="$(SuppressFiles)" | ||
1134 | SuppressIntermediateFileVersionMatching="$(LinkerSuppressIntermediateFileVersionMatching)" | ||
1135 | SuppressIces="$(SuppressIces)" | ||
1136 | SuppressLayout="$(SuppressLayout)" | ||
1137 | SuppressLocalization="$(SuppressLocalization)" | ||
1138 | SuppressMsiAssemblyTableProcessing="$(SuppressMsiAssemblyTableProcessing)" | ||
1139 | SuppressPdbOutput="$(SuppressPdbOutput)" | ||
1140 | SuppressSchemaValidation="$(LinkerSuppressSchemaValidation)" | ||
1141 | SuppressValidation="$(SuppressValidation)" | ||
1142 | SuppressSpecificWarnings="$(LinkerSuppressSpecificWarnings)" | ||
1143 | SuppressTagSectionIdAttributeOnTuples="$(SuppressTagSectionIdAttributeOnTuples)" | ||
1144 | ToolPath="$(WixToolDir)" | ||
1145 | TreatWarningsAsErrors="$(LinkerTreatWarningsAsErrors)" | ||
1146 | UnreferencedSymbolsFile="$(UnreferencedSymbolsFile)" | ||
1147 | VerboseOutput="$(LinkerVerboseOutput)" | ||
1148 | WixProjectFile="$(ProjectPath)" | ||
1149 | WixVariables="$(WixVariables)" /> | ||
1150 | </Target> | ||
1151 | |||
1152 | <!-- | ||
1153 | ================================================================================================ | ||
1154 | UpdateLinkFileWrites | ||
1155 | |||
1156 | Reads the bind outputs file(s) output generated during Link to correctly set the @(FileWrites) | ||
1157 | item. Most targets have it easy because they can do a static mapping from inputs to the outputs. | ||
1158 | However, the Link target outputs are determined after a rather complex calculation we call | ||
1159 | linking and binding! | ||
1160 | |||
1161 | This target runs independently after Link to ensure that @(FileWrites) is updated even if the | ||
1162 | "Light" task fails. | ||
1163 | |||
1164 | [IN] | ||
1165 | Path to bind outputs file(s). | ||
1166 | |||
1167 | [OUT] | ||
1168 | @(FileWrites) updated with outputs from bind. | ||
1169 | ================================================================================================ | ||
1170 | --> | ||
1171 | <Target | ||
1172 | Name="UpdateLinkFileWrites" | ||
1173 | Condition=" '$(OutputType)' == 'Bundle' or '$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module' "> | ||
1174 | |||
1175 | <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)"> | ||
1176 | <Output TaskParameter="Lines" ItemName="FileWrites"/> | ||
1177 | </ReadLinesFromFile> | ||
1178 | |||
1179 | <ItemGroup> | ||
1180 | <FileWrites Include="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)" /> | ||
1181 | <FileWrites Include="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)" /> | ||
1182 | <FileWrites Include="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)" /> | ||
1183 | </ItemGroup> | ||
1184 | |||
1185 | <Message Importance="low" Text="Build files after link: @(FileWrites)" /> | ||
1186 | </Target> | ||
1187 | |||
1188 | <!-- | ||
1189 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
1190 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
1191 | AllProjectOutputGroups Section | ||
1192 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
1193 | ////////////////////////////////////////////////////////////////////////////////////////////////// | ||
1194 | --> | ||
1195 | |||
1196 | <!-- | ||
1197 | ================================================================================================== | ||
1198 | AllProjectOutputGroups - OVERRIDE Target | ||
1199 | |||
1200 | ================================================================================================== | ||
1201 | --> | ||
1202 | <Target | ||
1203 | Name="AllProjectOutputGroups" | ||
1204 | DependsOnTargets=" | ||
1205 | BuiltProjectOutputGroup; | ||
1206 | DebugSymbolsProjectOutputGroup; | ||
1207 | SourceFilesProjectOutputGroup; | ||
1208 | ContentFilesProjectOutputGroup" /> | ||
1209 | |||
1210 | <!-- | ||
1211 | This is the key output for the BuiltProjectOutputGroup and is meant to be read directly from the IDE. | ||
1212 | Reading an item is faster than invoking a target. | ||
1213 | --> | ||
1214 | <ItemGroup> | ||
1215 | <BuiltProjectOutputGroupKeyOutput Include="$(TargetPath)"> | ||
1216 | <IsKeyOutput>true</IsKeyOutput> | ||
1217 | <FinalOutputPath>$(TargetPath)</FinalOutputPath> | ||
1218 | <TargetPath>$(TargetFileName)</TargetPath> | ||
1219 | </BuiltProjectOutputGroupKeyOutput> | ||
1220 | </ItemGroup> | ||
1221 | |||
1222 | <!-- | ||
1223 | ================================================================================================== | ||
1224 | BuiltProjectOutputGroup - OVERRIDE Target | ||
1225 | ================================================================================================== | ||
1226 | --> | ||
1227 | <PropertyGroup> | ||
1228 | <BuiltProjectOutputGroupDependsOn>PrepareForBuild;AssignCultures</BuiltProjectOutputGroupDependsOn> | ||
1229 | </PropertyGroup> | ||
1230 | <Target | ||
1231 | Name="BuiltProjectOutputGroup" | ||
1232 | Outputs="@(BuiltProjectOutputGroupOutput)" | ||
1233 | DependsOnTargets="$(BuiltProjectOutputGroupDependsOn)"> | ||
1234 | |||
1235 | <!-- Don't add BuiltProjectOutputGroupKeyOutput - to avoid duplicates, we only want to get the updated list of TargetPaths from the TargetPath property below --> | ||
1236 | |||
1237 | <!-- Try to read the outputs from the bind outputs text file since that's the output list straight from linker. --> | ||
1238 | <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)"> | ||
1239 | <Output TaskParameter="Lines" ItemName="_BuiltProjectOutputGroupOutputIntermediate"/> | ||
1240 | </ReadLinesFromFile> | ||
1241 | |||
1242 | <!-- If we didn't get anything from the bind outputs text file, default to the target path. --> | ||
1243 | <ItemGroup Condition=" '@(_BuiltProjectOutputGroupOutputIntermediate)'=='' "> | ||
1244 | <_BuiltProjectOutputGroupOutputIntermediate Include="$(TargetPath)" /> | ||
1245 | </ItemGroup> | ||
1246 | |||
1247 | <!-- Convert intermediate items into final items; this way we can get the full path for each item --> | ||
1248 | <ItemGroup> | ||
1249 | <BuiltProjectOutputGroupOutput Include="@(_BuiltProjectOutputGroupOutputIntermediate->'%(FullPath)')"> | ||
1250 | <!-- For compatibility with 2.0 --> | ||
1251 | <OriginalItemSpec Condition="'%(_BuiltProjectOutputGroupOutputIntermediate.OriginalItemSpec)' == ''">%(_BuiltProjectOutputGroupOutputIntermediate.FullPath)</OriginalItemSpec> | ||
1252 | </BuiltProjectOutputGroupOutput> | ||
1253 | </ItemGroup> | ||
1254 | </Target> | ||
1255 | |||
1256 | <!-- | ||
1257 | ================================================================================================== | ||
1258 | DebugSymbolsProjectOutputGroup | ||
1259 | |||
1260 | Populates the Debug Symbols project output group. | ||
1261 | ================================================================================================== | ||
1262 | --> | ||
1263 | <PropertyGroup> | ||
1264 | <DebugSymbolsProjectOutputGroupDependsOn>AssignCultures</DebugSymbolsProjectOutputGroupDependsOn> | ||
1265 | </PropertyGroup> | ||
1266 | <Target | ||
1267 | Name="DebugSymbolsProjectOutputGroup" | ||
1268 | Outputs="@(DebugSymbolsProjectOutputGroupOutput)" | ||
1269 | DependsOnTargets="$(DebugSymbolsProjectOutputGroupDependsOn)"> | ||
1270 | |||
1271 | <!-- Include build output pdb(s). Different than predefined itemgroup since AssignCultures target may change --> | ||
1272 | <ItemGroup> | ||
1273 | <DebugSymbolsProjectOutputGroupOutput Include="$(TargetPdbPath)" Condition=" '$(SuppressPdbOutput)' != 'true' "/> | ||
1274 | </ItemGroup> | ||
1275 | </Target> | ||
1276 | |||
1277 | |||
1278 | <!-- | ||
1279 | ================================================================================================== | ||
1280 | CopyFilesToOutputDirectory - OVERRIDE Target | ||
1281 | |||
1282 | Copy all build outputs, satellites and other necessary files to the final directory. | ||
1283 | ============================================================ | ||
1284 | --> | ||
1285 | <Target | ||
1286 | Name="CopyFilesToOutputDirectory"> | ||
1287 | |||
1288 | <PropertyGroup> | ||
1289 | <!-- By default we're using hard links to copy to the output directory, disabling this could slow the build significantly --> | ||
1290 | <CreateHardLinksForCopyFilesToOutputDirectoryIfPossible Condition=" '$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)' == '' ">true</CreateHardLinksForCopyFilesToOutputDirectoryIfPossible> | ||
1291 | </PropertyGroup> | ||
1292 | |||
1293 | <PropertyGroup> | ||
1294 | <CopyBuildOutputToOutputDirectory Condition="'$(CopyBuildOutputToOutputDirectory)'==''">true</CopyBuildOutputToOutputDirectory> | ||
1295 | <CopyOutputSymbolsToOutputDirectory Condition="'$(CopyOutputSymbolsToOutputDirectory)'==''">true</CopyOutputSymbolsToOutputDirectory> | ||
1296 | <FullIntermediateOutputPath>$([System.IO.Path]::GetFullPath($(IntermediateOutputPath)))</FullIntermediateOutputPath> | ||
1297 | </PropertyGroup> | ||
1298 | |||
1299 | <!-- Copy the bound files. --> | ||
1300 | <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)"> | ||
1301 | <Output TaskParameter="Lines" ItemName="_FullPathToCopy"/> | ||
1302 | </ReadLinesFromFile> | ||
1303 | |||
1304 | <ItemGroup> | ||
1305 | <_FullPathToCopy Include="$(TargetPath)" Condition=" '@(_FullPathToCopy)'=='' " /> | ||
1306 | <_RelativePath Include="$([MSBuild]::MakeRelative($(FullIntermediateOutputPath), %(_FullPathToCopy.Identity)))" /> | ||
1307 | </ItemGroup> | ||
1308 | |||
1309 | <Copy | ||
1310 | SourceFiles="@(_RelativePath->'$(IntermediateOutputPath)%(Identity)')" | ||
1311 | DestinationFiles="@(_RelativePath->'$(OutDir)%(Identity)')" | ||
1312 | SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" | ||
1313 | OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)" | ||
1314 | Retries="$(CopyRetryCount)" | ||
1315 | RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" | ||
1316 | UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)" | ||
1317 | Condition="'$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true'" | ||
1318 | > | ||
1319 | |||
1320 | <Output TaskParameter="DestinationFiles" ItemName="MainAssembly"/> | ||
1321 | <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/> | ||
1322 | |||
1323 | </Copy> | ||
1324 | |||
1325 | <Message Importance="High" Text="$(MSBuildProjectName) -> $(TargetPath)" Condition="'$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)'!='true'" /> | ||
1326 | <!--<Message Importance="High" Text="$(MSBuildProjectName) -> @(MainAssembly->'%(FullPath)')" Condition="'$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)'!='true'" />--> | ||
1327 | |||
1328 | <!-- Copy the debug information file (.pdb), if any | ||
1329 | <Copy | ||
1330 | SourceFiles="@(_DebugSymbolsIntermediatePath)" | ||
1331 | DestinationFiles="@(_DebugSymbolsOutputPath)" | ||
1332 | SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" | ||
1333 | OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)" | ||
1334 | Retries="$(CopyRetryCount)" | ||
1335 | RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" | ||
1336 | UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)" | ||
1337 | Condition="'$(_DebugSymbolsProduced)'=='true' and '$(SkipCopyingSymbolsToOutputDirectory)' != 'true' and '$(CopyOutputSymbolsToOutputDirectory)'=='true'"> | ||
1338 | |||
1339 | <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/> | ||
1340 | |||
1341 | </Copy> | ||
1342 | --> | ||
1343 | </Target> | ||
1344 | |||
1345 | |||
1346 | <Import Project="$(WixHarvestTargetsPath)" Condition=" '$(WixHarvestTargetsPath)' != '' and Exists('$(WixHarvestTargetsPath)')" /> | ||
1347 | <Import Project="$(WixSigningTargetsPath)" Condition=" '$(WixSigningTargetsPath)' != '' and Exists('$(WixSigningTargetsPath)')" /> | ||
1348 | <Import Project="$(LuxTargetsPath)" Condition=" '$(LuxTargetsPath)' != '' and Exists('$(LuxTargetsPath)')" /> | ||
1349 | |||
1350 | <!-- Extension point: Define CustomAfterWixTargets to a .targets file that you want to include after this file. --> | ||
1351 | <Import Project="$(CustomAfterWixTargets)" Condition=" '$(CustomAfterWixTargets)' != '' and Exists('$(CustomAfterWixTargets)')" /> | ||
1352 | |||
1353 | </Project> | ||