aboutsummaryrefslogtreecommitdiff
path: root/src/tools/WixToolset.HeatTasks
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/WixToolset.HeatTasks')
-rw-r--r--src/tools/WixToolset.HeatTasks/HeatDirectory.cs48
-rw-r--r--src/tools/WixToolset.HeatTasks/HeatFile.cs45
-rw-r--r--src/tools/WixToolset.HeatTasks/HeatProject.cs73
-rw-r--r--src/tools/WixToolset.HeatTasks/HeatTask.cs52
-rw-r--r--src/tools/WixToolset.HeatTasks/RefreshBundleGeneratedFile.cs104
-rw-r--r--src/tools/WixToolset.HeatTasks/RefreshGeneratedFile.cs91
-rw-r--r--src/tools/WixToolset.HeatTasks/RefreshTask.cs59
-rw-r--r--src/tools/WixToolset.HeatTasks/WixToolset.HeatTasks.csproj17
8 files changed, 0 insertions, 489 deletions
diff --git a/src/tools/WixToolset.HeatTasks/HeatDirectory.cs b/src/tools/WixToolset.HeatTasks/HeatDirectory.cs
deleted file mode 100644
index 14a8acfa..00000000
--- a/src/tools/WixToolset.HeatTasks/HeatDirectory.cs
+++ /dev/null
@@ -1,48 +0,0 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.HeatTasks
4{
5 using Microsoft.Build.Framework;
6 using WixToolset.BaseBuildTasks;
7
8 public sealed class HeatDirectory : HeatTask
9 {
10 public string ComponentGroupName { get; set; }
11
12 [Required]
13 public string Directory { get; set; }
14
15 public string DirectoryRefId { get; set; }
16
17 public bool KeepEmptyDirectories { get; set; }
18
19 public string PreprocessorVariable { get; set; }
20
21 public bool SuppressCom { get; set; }
22
23 public bool SuppressRootDirectory { get; set; }
24
25 public bool SuppressRegistry { get; set; }
26
27 public string Template { get; set; }
28
29 protected override string OperationName => "dir";
30
31 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
32 {
33 commandLineBuilder.AppendSwitch(this.OperationName);
34 commandLineBuilder.AppendFileNameIfNotNull(this.Directory);
35
36 commandLineBuilder.AppendSwitchIfNotNull("-cg ", this.ComponentGroupName);
37 commandLineBuilder.AppendSwitchIfNotNull("-dr ", this.DirectoryRefId);
38 commandLineBuilder.AppendIfTrue("-ke", this.KeepEmptyDirectories);
39 commandLineBuilder.AppendIfTrue("-scom", this.SuppressCom);
40 commandLineBuilder.AppendIfTrue("-sreg", this.SuppressRegistry);
41 commandLineBuilder.AppendIfTrue("-srd", this.SuppressRootDirectory);
42 commandLineBuilder.AppendSwitchIfNotNull("-template ", this.Template);
43 commandLineBuilder.AppendSwitchIfNotNull("-var ", this.PreprocessorVariable);
44
45 base.BuildCommandLine(commandLineBuilder);
46 }
47 }
48}
diff --git a/src/tools/WixToolset.HeatTasks/HeatFile.cs b/src/tools/WixToolset.HeatTasks/HeatFile.cs
deleted file mode 100644
index b39de7da..00000000
--- a/src/tools/WixToolset.HeatTasks/HeatFile.cs
+++ /dev/null
@@ -1,45 +0,0 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.HeatTasks
4{
5 using Microsoft.Build.Framework;
6 using WixToolset.BaseBuildTasks;
7
8 public sealed class HeatFile : HeatTask
9 {
10 public string ComponentGroupName { get; set; }
11
12 public string DirectoryRefId { get; set; }
13
14 [Required]
15 public string File { get; set; }
16
17 public string PreprocessorVariable { get; set; }
18
19 public bool SuppressCom { get; set; }
20
21 public bool SuppressRegistry { get; set; }
22
23 public bool SuppressRootDirectory { get; set; }
24
25 public string Template { get; set; }
26
27 protected override string OperationName => "file";
28
29 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
30 {
31 commandLineBuilder.AppendSwitch(this.OperationName);
32 commandLineBuilder.AppendFileNameIfNotNull(this.File);
33
34 commandLineBuilder.AppendSwitchIfNotNull("-cg ", this.ComponentGroupName);
35 commandLineBuilder.AppendSwitchIfNotNull("-dr ", this.DirectoryRefId);
36 commandLineBuilder.AppendIfTrue("-scom", this.SuppressCom);
37 commandLineBuilder.AppendIfTrue("-srd", this.SuppressRootDirectory);
38 commandLineBuilder.AppendIfTrue("-sreg", this.SuppressRegistry);
39 commandLineBuilder.AppendSwitchIfNotNull("-template ", this.Template);
40 commandLineBuilder.AppendSwitchIfNotNull("-var ", this.PreprocessorVariable);
41
42 base.BuildCommandLine(commandLineBuilder);
43 }
44 }
45}
diff --git a/src/tools/WixToolset.HeatTasks/HeatProject.cs b/src/tools/WixToolset.HeatTasks/HeatProject.cs
deleted file mode 100644
index 998c14ab..00000000
--- a/src/tools/WixToolset.HeatTasks/HeatProject.cs
+++ /dev/null
@@ -1,73 +0,0 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.HeatTasks
4{
5 using Microsoft.Build.Framework;
6 using WixToolset.BaseBuildTasks;
7
8 public sealed class HeatProject : HeatTask
9 {
10 private string[] projectOutputGroups;
11
12 public string Configuration { get; set; }
13
14 public string DirectoryIds { get; set; }
15
16 public bool GenerateWixVariables { get; set; }
17
18 public string GenerateType { get; set; }
19
20 public string MsbuildBinPath { get; set; }
21
22 public string Platform { get; set; }
23
24 [Required]
25 public string Project { get; set; }
26
27 public string ProjectName { get; set; }
28
29 public string[] ProjectOutputGroups
30 {
31 get
32 {
33 return this.projectOutputGroups;
34 }
35 set
36 {
37 this.projectOutputGroups = value;
38
39 // If it's just one string and it contains semicolons, let's
40 // split it into separate items.
41 if (this.projectOutputGroups.Length == 1)
42 {
43 this.projectOutputGroups = this.projectOutputGroups[0].Split(new char[] { ';' });
44 }
45 }
46 }
47
48 public bool UseToolsVersion { get; set; }
49
50 protected override string OperationName => "project";
51
52 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
53 {
54 commandLineBuilder.AppendSwitch(this.OperationName);
55 commandLineBuilder.AppendFileNameIfNotNull(this.Project);
56
57 commandLineBuilder.AppendSwitchIfNotNull("-configuration ", this.Configuration);
58 commandLineBuilder.AppendSwitchIfNotNull("-directoryid ", this.DirectoryIds);
59 commandLineBuilder.AppendSwitchIfNotNull("-generate ", this.GenerateType);
60 commandLineBuilder.AppendSwitchIfNotNull("-msbuildbinpath ", this.MsbuildBinPath);
61 commandLineBuilder.AppendSwitchIfNotNull("-platform ", this.Platform);
62 commandLineBuilder.AppendArrayIfNotNull("-pog ", this.ProjectOutputGroups);
63 commandLineBuilder.AppendSwitchIfNotNull("-projectname ", this.ProjectName);
64 commandLineBuilder.AppendIfTrue("-wixvar", this.GenerateWixVariables);
65
66#if !NETCOREAPP
67 commandLineBuilder.AppendIfTrue("-usetoolsversion", this.UseToolsVersion);
68#endif
69
70 base.BuildCommandLine(commandLineBuilder);
71 }
72 }
73}
diff --git a/src/tools/WixToolset.HeatTasks/HeatTask.cs b/src/tools/WixToolset.HeatTasks/HeatTask.cs
deleted file mode 100644
index cad6635b..00000000
--- a/src/tools/WixToolset.HeatTasks/HeatTask.cs
+++ /dev/null
@@ -1,52 +0,0 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.HeatTasks
4{
5 using Microsoft.Build.Framework;
6 using WixToolset.BaseBuildTasks;
7
8 /// <summary>
9 /// A base MSBuild task to run the WiX harvester.
10 /// Specific harvester tasks should extend this class.
11 /// </summary>
12 public abstract partial class HeatTask : BaseToolsetTask
13 {
14 public bool AutogenerateGuids { get; set; }
15
16 public bool GenerateGuidsNow { get; set; }
17
18 [Required]
19 [Output]
20 public ITaskItem OutputFile { get; set; }
21
22 public bool SuppressFragments { get; set; }
23
24 public bool SuppressUniqueIds { get; set; }
25
26 public string[] Transforms { get; set; }
27
28 /// <summary>
29 /// Gets the name of the heat operation performed by the task.
30 /// </summary>
31 /// <remarks>This is the first parameter passed on the heat.exe command-line.</remarks>
32 /// <value>The name of the heat operation performed by the task.</value>
33 protected abstract string OperationName { get; }
34
35 protected sealed override string ToolName => "heat.exe";
36
37 /// <summary>
38 /// Builds a command line from options in this task.
39 /// </summary>
40 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
41 {
42 base.BuildCommandLine(commandLineBuilder);
43
44 commandLineBuilder.AppendIfTrue("-ag", this.AutogenerateGuids);
45 commandLineBuilder.AppendIfTrue("-gg", this.GenerateGuidsNow);
46 commandLineBuilder.AppendIfTrue("-sfrag", this.SuppressFragments);
47 commandLineBuilder.AppendIfTrue("-suid", this.SuppressUniqueIds);
48 commandLineBuilder.AppendArrayIfNotNull("-t ", this.Transforms);
49 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
50 }
51 }
52}
diff --git a/src/tools/WixToolset.HeatTasks/RefreshBundleGeneratedFile.cs b/src/tools/WixToolset.HeatTasks/RefreshBundleGeneratedFile.cs
deleted file mode 100644
index 8f1ad167..00000000
--- a/src/tools/WixToolset.HeatTasks/RefreshBundleGeneratedFile.cs
+++ /dev/null
@@ -1,104 +0,0 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.HeatTasks
4{
5 using System;
6 using System.Collections;
7 using System.Globalization;
8 using System.IO;
9 using System.Xml;
10 using Microsoft.Build.Framework;
11
12 /// <summary>
13 /// This task refreshes the generated file for bundle projects.
14 /// </summary>
15 public class RefreshBundleGeneratedFile : RefreshTask
16 {
17 /// <summary>
18 /// Gets a complete list of external cabs referenced by the given installer database file.
19 /// </summary>
20 /// <returns>True upon completion of the task execution.</returns>
21 public override bool Execute()
22 {
23 var payloadGroupRefs = new ArrayList();
24 var packageGroupRefs = new ArrayList();
25 for (var i = 0; i < this.ProjectReferencePaths.Length; i++)
26 {
27 var item = this.ProjectReferencePaths[i];
28
29 if (!String.IsNullOrEmpty(item.GetMetadata(DoNotHarvest)))
30 {
31 continue;
32 }
33
34 var projectPath = item.GetMetadata("MSBuildSourceProjectFile");
35 var projectName = Path.GetFileNameWithoutExtension(projectPath);
36 var referenceName = GetIdentifierFromName(GetMetadataOrDefault(item, "Name", projectName));
37
38 var pogs = item.GetMetadata("RefProjectOutputGroups").Split(';');
39 foreach (var pog in pogs)
40 {
41 if (!String.IsNullOrEmpty(pog))
42 {
43 // TODO: Add payload group references and package group references once heat is generating them
44 ////payloadGroupRefs.Add(String.Format(CultureInfo.InvariantCulture, "{0}.{1}", referenceName, pog));
45 packageGroupRefs.Add(String.Format(CultureInfo.InvariantCulture, "{0}.{1}", referenceName, pog));
46 }
47 }
48 }
49
50 var doc = new XmlDocument();
51
52 var head = doc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
53 doc.AppendChild(head);
54
55 var rootElement = doc.CreateElement("Wix");
56 rootElement.SetAttribute("xmlns", "http://wixtoolset.org/schemas/v4/wxs");
57 doc.AppendChild(rootElement);
58
59 var fragment = doc.CreateElement("Fragment");
60 rootElement.AppendChild(fragment);
61
62 var payloadGroup = doc.CreateElement("PayloadGroup");
63 payloadGroup.SetAttribute("Id", "Bundle.Generated.Payloads");
64 fragment.AppendChild(payloadGroup);
65
66 var packageGroup = doc.CreateElement("PackageGroup");
67 packageGroup.SetAttribute("Id", "Bundle.Generated.Packages");
68 fragment.AppendChild(packageGroup);
69
70 foreach (string payloadGroupRef in payloadGroupRefs)
71 {
72 var payloadGroupRefElement = doc.CreateElement("PayloadGroupRef");
73 payloadGroupRefElement.SetAttribute("Id", payloadGroupRef);
74 payloadGroup.AppendChild(payloadGroupRefElement);
75 }
76
77 foreach (string packageGroupRef in packageGroupRefs)
78 {
79 var packageGroupRefElement = doc.CreateElement("PackageGroupRef");
80 packageGroupRefElement.SetAttribute("Id", packageGroupRef);
81 packageGroup.AppendChild(packageGroupRefElement);
82 }
83
84 foreach (var item in this.GeneratedFiles)
85 {
86 var fullPath = item.GetMetadata("FullPath");
87
88 payloadGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath) + ".Payloads");
89 packageGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath) + ".Packages");
90 try
91 {
92 doc.Save(fullPath);
93 }
94 catch (Exception e)
95 {
96 // e.Message will be something like: "Access to the path 'fullPath' is denied."
97 this.Log.LogMessage(MessageImportance.High, "Unable to save generated file to '{0}'. {1}", fullPath, e.Message);
98 }
99 }
100
101 return true;
102 }
103 }
104}
diff --git a/src/tools/WixToolset.HeatTasks/RefreshGeneratedFile.cs b/src/tools/WixToolset.HeatTasks/RefreshGeneratedFile.cs
deleted file mode 100644
index 1e43cc1f..00000000
--- a/src/tools/WixToolset.HeatTasks/RefreshGeneratedFile.cs
+++ /dev/null
@@ -1,91 +0,0 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.HeatTasks
4{
5 using System;
6 using System.Collections;
7 using System.Globalization;
8 using System.IO;
9 using System.Xml;
10 using Microsoft.Build.Framework;
11
12 /// <summary>
13 /// This task refreshes the generated file that contains ComponentGroupRefs
14 /// to harvested output.
15 /// </summary>
16 public class RefreshGeneratedFile : RefreshTask
17 {
18 /// <summary>
19 /// Gets a complete list of external cabs referenced by the given installer database file.
20 /// </summary>
21 /// <returns>True upon completion of the task execution.</returns>
22 public override bool Execute()
23 {
24 var componentGroupRefs = new ArrayList();
25
26 for (var i = 0; i < this.ProjectReferencePaths.Length; i++)
27 {
28 var item = this.ProjectReferencePaths[i];
29
30 if (!String.IsNullOrEmpty(item.GetMetadata(DoNotHarvest)))
31 {
32 continue;
33 }
34
35 var projectPath = item.GetMetadata("MSBuildSourceProjectFile");
36 var projectName = Path.GetFileNameWithoutExtension(projectPath);
37 var referenceName = GetIdentifierFromName(GetMetadataOrDefault(item, "Name", projectName));
38
39 var pogs = item.GetMetadata("RefProjectOutputGroups").Split(';');
40 foreach (var pog in pogs)
41 {
42 if (!String.IsNullOrEmpty(pog))
43 {
44 componentGroupRefs.Add(String.Format(CultureInfo.InvariantCulture, "{0}.{1}", referenceName, pog));
45 }
46 }
47 }
48
49 var doc = new XmlDocument();
50
51 var head = doc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
52 doc.AppendChild(head);
53
54 var rootElement = doc.CreateElement("Wix");
55 rootElement.SetAttribute("xmlns", "http://wixtoolset.org/schemas/v4/wxs");
56 doc.AppendChild(rootElement);
57
58 var fragment = doc.CreateElement("Fragment");
59 rootElement.AppendChild(fragment);
60
61 var componentGroup = doc.CreateElement("ComponentGroup");
62 componentGroup.SetAttribute("Id", "Product.Generated");
63 fragment.AppendChild(componentGroup);
64
65 foreach (string componentGroupRef in componentGroupRefs)
66 {
67 var componentGroupRefElement = doc.CreateElement("ComponentGroupRef");
68 componentGroupRefElement.SetAttribute("Id", componentGroupRef);
69 componentGroup.AppendChild(componentGroupRefElement);
70 }
71
72 foreach (var item in this.GeneratedFiles)
73 {
74 var fullPath = item.GetMetadata("FullPath");
75
76 componentGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath));
77 try
78 {
79 doc.Save(fullPath);
80 }
81 catch (Exception e)
82 {
83 // e.Message will be something like: "Access to the path 'fullPath' is denied."
84 this.Log.LogMessage(MessageImportance.High, "Unable to save generated file to '{0}'. {1}", fullPath, e.Message);
85 }
86 }
87
88 return true;
89 }
90 }
91}
diff --git a/src/tools/WixToolset.HeatTasks/RefreshTask.cs b/src/tools/WixToolset.HeatTasks/RefreshTask.cs
deleted file mode 100644
index 0b378272..00000000
--- a/src/tools/WixToolset.HeatTasks/RefreshTask.cs
+++ /dev/null
@@ -1,59 +0,0 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.HeatTasks
4{
5 using System;
6 using System.Text.RegularExpressions;
7 using Microsoft.Build.Framework;
8 using Microsoft.Build.Utilities;
9
10 /// <summary>
11 /// A base MSBuild task to refresh generated files.
12 /// </summary>
13 public abstract class RefreshTask : Task
14 {
15 private static readonly Regex AddPrefix = new Regex(@"^[^a-zA-Z_]");
16 private static readonly Regex IllegalIdentifierCharacters = new Regex(@"[^A-Za-z0-9_\.]|\.{2,}"); // non 'words' and assorted valid characters
17
18 /// <summary>Metadata key name to turn off harvesting of project references.</summary>
19 protected const string DoNotHarvest = "DoNotHarvest";
20
21 /// <summary>
22 /// The list of files to generate.
23 /// </summary>
24 [Required]
25 public ITaskItem[] GeneratedFiles { get; set; }
26
27 /// <summary>
28 /// All the project references in the project.
29 /// </summary>
30 [Required]
31 public ITaskItem[] ProjectReferencePaths { get; set; }
32
33 /// <summary>
34 /// Return an identifier based on passed file/directory name
35 /// </summary>
36 /// <param name="name">File/directory name to generate identifer from</param>
37 /// <returns>A version of the name that is a legal identifier.</returns>
38 /// <remarks>This is duplicated from WiX's Common class.</remarks>
39 protected static string GetIdentifierFromName(string name)
40 {
41 var result = IllegalIdentifierCharacters.Replace(name, "_"); // replace illegal characters with "_".
42
43 // MSI identifiers must begin with an alphabetic character or an
44 // underscore. Prefix all other values with an underscore.
45 if (AddPrefix.IsMatch(name))
46 {
47 result = String.Concat("_", result);
48 }
49
50 return result;
51 }
52
53 protected static string GetMetadataOrDefault(ITaskItem item, string metadataName, string defaultValue)
54 {
55 var value = item.GetMetadata(metadataName);
56 return String.IsNullOrWhiteSpace(value) ? defaultValue : value;
57 }
58 }
59}
diff --git a/src/tools/WixToolset.HeatTasks/WixToolset.HeatTasks.csproj b/src/tools/WixToolset.HeatTasks/WixToolset.HeatTasks.csproj
deleted file mode 100644
index 21460810..00000000
--- a/src/tools/WixToolset.HeatTasks/WixToolset.HeatTasks.csproj
+++ /dev/null
@@ -1,17 +0,0 @@
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 <TargetFrameworks>net6.0;net472</TargetFrameworks>
7 <Title>WiX Toolset Heat MSBuild Tasks</Title>
8 <DebugType>embedded</DebugType>
9 <PublishRepositoryUrl>true</PublishRepositoryUrl>
10 <PlatformTarget>AnyCPU</PlatformTarget>
11 </PropertyGroup>
12
13 <ItemGroup>
14 <PackageReference Include="Microsoft.Build.Tasks.Core" />
15 <PackageReference Include="WixInternal.BaseBuildTasks.Sources" />
16 </ItemGroup>
17</Project>