diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-06-03 12:28:49 +1000 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-06-03 14:24:34 +1000 |
| commit | d5d5e87acf7eadacd757083a4d0272a04962ae9b (patch) | |
| tree | 550aad2409958b684fe0621bd82c60ebeb54ca8d /src/WixToolset.BuildTasks/Common.cs | |
| parent | a04ddca42b2070124c63a61c661e2b96a5bddac2 (diff) | |
| download | wix-d5d5e87acf7eadacd757083a4d0272a04962ae9b.tar.gz wix-d5d5e87acf7eadacd757083a4d0272a04962ae9b.tar.bz2 wix-d5d5e87acf7eadacd757083a4d0272a04962ae9b.zip | |
Delete WixToolset.Tools.Core project.
Diffstat (limited to 'src/WixToolset.BuildTasks/Common.cs')
| -rw-r--r-- | src/WixToolset.BuildTasks/Common.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/WixToolset.BuildTasks/Common.cs b/src/WixToolset.BuildTasks/Common.cs new file mode 100644 index 00000000..c5b709c2 --- /dev/null +++ b/src/WixToolset.BuildTasks/Common.cs | |||
| @@ -0,0 +1,39 @@ | |||
| 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.Text.RegularExpressions; | ||
| 7 | |||
| 8 | /// <summary> | ||
| 9 | /// Common WixTasks utility methods and types. | ||
| 10 | /// </summary> | ||
| 11 | public static class ToolsCommon | ||
| 12 | { | ||
| 13 | /// <summary>Metadata key name to turn off harvesting of project references.</summary> | ||
| 14 | public const string DoNotHarvest = "DoNotHarvest"; | ||
| 15 | |||
| 16 | private static readonly Regex AddPrefix = new Regex(@"^[^a-zA-Z_]", RegexOptions.Compiled); | ||
| 17 | private static readonly Regex IllegalIdentifierCharacters = new Regex(@"[^A-Za-z0-9_\.]|\.{2,}", RegexOptions.Compiled); // non 'words' and assorted valid characters | ||
| 18 | |||
| 19 | /// <summary> | ||
| 20 | /// Return an identifier based on passed file/directory name | ||
| 21 | /// </summary> | ||
| 22 | /// <param name="name">File/directory name to generate identifer from</param> | ||
| 23 | /// <returns>A version of the name that is a legal identifier.</returns> | ||
| 24 | /// <remarks>This is duplicated from WiX's Common class.</remarks> | ||
| 25 | public static string GetIdentifierFromName(string name) | ||
| 26 | { | ||
| 27 | string result = IllegalIdentifierCharacters.Replace(name, "_"); // replace illegal characters with "_". | ||
| 28 | |||
| 29 | // MSI identifiers must begin with an alphabetic character or an | ||
| 30 | // underscore. Prefix all other values with an underscore. | ||
| 31 | if (AddPrefix.IsMatch(name)) | ||
| 32 | { | ||
| 33 | result = String.Concat("_", result); | ||
| 34 | } | ||
| 35 | |||
| 36 | return result; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | } | ||
