summaryrefslogtreecommitdiff
path: root/src/tools/WixToolset.HeatTasks/RefreshTask.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2022-07-26 17:20:39 -0700
committerRob Mensching <rob@firegiant.com>2022-08-01 20:25:19 -0700
commita627ca9b720047e633a8fe72003ab9bee31006c5 (patch)
tree2bc8a924bb4141ab718e74d08f6459a0ffe8d573 /src/tools/WixToolset.HeatTasks/RefreshTask.cs
parent521eb3c9cf38823a2c4019abb85dc0b3200b92cb (diff)
downloadwix-a627ca9b720047e633a8fe72003ab9bee31006c5.tar.gz
wix-a627ca9b720047e633a8fe72003ab9bee31006c5.tar.bz2
wix-a627ca9b720047e633a8fe72003ab9bee31006c5.zip
Create WixToolset.Heat.nupkg to distribute heat.exe and Heat targets
Moves Heat functionality to the "tools" layer and packages it all up in WixToolset.Heat.nupkg for distribution in WiX v4. Completes 6838
Diffstat (limited to 'src/tools/WixToolset.HeatTasks/RefreshTask.cs')
-rw-r--r--src/tools/WixToolset.HeatTasks/RefreshTask.cs59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/tools/WixToolset.HeatTasks/RefreshTask.cs b/src/tools/WixToolset.HeatTasks/RefreshTask.cs
new file mode 100644
index 00000000..0b378272
--- /dev/null
+++ b/src/tools/WixToolset.HeatTasks/RefreshTask.cs
@@ -0,0 +1,59 @@
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}