aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.BuildTasks
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2018-09-02 16:12:29 -0500
committerSean Hall <r.sean.hall@gmail.com>2018-09-13 12:05:57 -0500
commit244b46cf7f3252d6dc3884ce184be901d1d173e5 (patch)
treebd6fb4349b926001138d1a3415f93370d64e538f /src/WixToolset.BuildTasks
parent026d0af96fac5cd2d3d84ade657949ddc7144b99 (diff)
downloadwix-244b46cf7f3252d6dc3884ce184be901d1d173e5.tar.gz
wix-244b46cf7f3252d6dc3884ce184be901d1d173e5.tar.bz2
wix-244b46cf7f3252d6dc3884ce184be901d1d173e5.zip
Migrate WixCop into Tools from wix4.
Diffstat (limited to 'src/WixToolset.BuildTasks')
-rw-r--r--src/WixToolset.BuildTasks/Common.cs41
-rw-r--r--src/WixToolset.BuildTasks/ConvertReferences.cs7
-rw-r--r--src/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs9
-rw-r--r--src/WixToolset.BuildTasks/RefreshGeneratedFile.cs9
-rw-r--r--src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj4
5 files changed, 12 insertions, 58 deletions
diff --git a/src/WixToolset.BuildTasks/Common.cs b/src/WixToolset.BuildTasks/Common.cs
deleted file mode 100644
index 803e9d14..00000000
--- a/src/WixToolset.BuildTasks/Common.cs
+++ /dev/null
@@ -1,41 +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
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
index fe137633..ef50c918 100644
--- a/src/WixToolset.BuildTasks/ConvertReferences.cs
+++ b/src/WixToolset.BuildTasks/ConvertReferences.cs
@@ -3,13 +3,10 @@
3namespace WixToolset.BuildTasks 3namespace WixToolset.BuildTasks
4{ 4{
5 using System; 5 using System;
6 using System.Collections;
7 using System.Collections.Generic; 6 using System.Collections.Generic;
8 using System.Globalization;
9 using System.IO;
10 using System.Xml;
11 using Microsoft.Build.Framework; 7 using Microsoft.Build.Framework;
12 using Microsoft.Build.Utilities; 8 using Microsoft.Build.Utilities;
9 using WixToolset.Tools.Core;
13 10
14 /// <summary> 11 /// <summary>
15 /// This task assigns Culture metadata to files based on the value of the Culture attribute on the 12 /// This task assigns Culture metadata to files based on the value of the Culture attribute on the
@@ -62,7 +59,7 @@ namespace WixToolset.BuildTasks
62 { 59 {
63 Dictionary<string, string> newItemMetadeta = new Dictionary<string, string>(); 60 Dictionary<string, string> newItemMetadeta = new Dictionary<string, string>();
64 61
65 if (!String.IsNullOrEmpty(item.GetMetadata(Common.DoNotHarvest))) 62 if (!String.IsNullOrEmpty(item.GetMetadata(ToolsCommon.DoNotHarvest)))
66 { 63 {
67 continue; 64 continue;
68 } 65 }
diff --git a/src/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs b/src/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs
index 5445e0cd..80305f59 100644
--- a/src/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs
+++ b/src/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs
@@ -6,19 +6,16 @@ namespace WixToolset.BuildTasks
6 using System.Collections; 6 using System.Collections;
7 using System.Globalization; 7 using System.Globalization;
8 using System.IO; 8 using System.IO;
9 using System.Text.RegularExpressions;
10 using System.Xml; 9 using System.Xml;
11 using Microsoft.Build.Framework; 10 using Microsoft.Build.Framework;
12 using Microsoft.Build.Utilities; 11 using Microsoft.Build.Utilities;
12 using WixToolset.Tools.Core;
13 13
14 /// <summary> 14 /// <summary>
15 /// This task refreshes the generated file for bundle projects. 15 /// This task refreshes the generated file for bundle projects.
16 /// </summary> 16 /// </summary>
17 public class RefreshBundleGeneratedFile : Task 17 public class RefreshBundleGeneratedFile : Task
18 { 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; 19 private ITaskItem[] generatedFiles;
23 private ITaskItem[] projectReferencePaths; 20 private ITaskItem[] projectReferencePaths;
24 21
@@ -54,14 +51,14 @@ namespace WixToolset.BuildTasks
54 { 51 {
55 ITaskItem item = this.ProjectReferencePaths[i]; 52 ITaskItem item = this.ProjectReferencePaths[i];
56 53
57 if (!String.IsNullOrEmpty(item.GetMetadata(Common.DoNotHarvest))) 54 if (!String.IsNullOrEmpty(item.GetMetadata(ToolsCommon.DoNotHarvest)))
58 { 55 {
59 continue; 56 continue;
60 } 57 }
61 58
62 string projectPath = CreateProjectReferenceDefineConstants.GetProjectPath(this.ProjectReferencePaths, i); 59 string projectPath = CreateProjectReferenceDefineConstants.GetProjectPath(this.ProjectReferencePaths, i);
63 string projectName = Path.GetFileNameWithoutExtension(projectPath); 60 string projectName = Path.GetFileNameWithoutExtension(projectPath);
64 string referenceName = Common.GetIdentifierFromName(CreateProjectReferenceDefineConstants.GetReferenceName(item, projectName)); 61 string referenceName = ToolsCommon.GetIdentifierFromName(CreateProjectReferenceDefineConstants.GetReferenceName(item, projectName));
65 62
66 string[] pogs = item.GetMetadata("RefProjectOutputGroups").Split(';'); 63 string[] pogs = item.GetMetadata("RefProjectOutputGroups").Split(';');
67 foreach (string pog in pogs) 64 foreach (string pog in pogs)
diff --git a/src/WixToolset.BuildTasks/RefreshGeneratedFile.cs b/src/WixToolset.BuildTasks/RefreshGeneratedFile.cs
index fdfc4774..101b5363 100644
--- a/src/WixToolset.BuildTasks/RefreshGeneratedFile.cs
+++ b/src/WixToolset.BuildTasks/RefreshGeneratedFile.cs
@@ -6,10 +6,10 @@ namespace WixToolset.BuildTasks
6 using System.Collections; 6 using System.Collections;
7 using System.Globalization; 7 using System.Globalization;
8 using System.IO; 8 using System.IO;
9 using System.Text.RegularExpressions;
10 using System.Xml; 9 using System.Xml;
11 using Microsoft.Build.Framework; 10 using Microsoft.Build.Framework;
12 using Microsoft.Build.Utilities; 11 using Microsoft.Build.Utilities;
12 using WixToolset.Tools.Core;
13 13
14 /// <summary> 14 /// <summary>
15 /// This task refreshes the generated file that contains ComponentGroupRefs 15 /// This task refreshes the generated file that contains ComponentGroupRefs
@@ -17,9 +17,6 @@ namespace WixToolset.BuildTasks
17 /// </summary> 17 /// </summary>
18 public class RefreshGeneratedFile : Task 18 public class RefreshGeneratedFile : Task
19 { 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; 20 private ITaskItem[] generatedFiles;
24 private ITaskItem[] projectReferencePaths; 21 private ITaskItem[] projectReferencePaths;
25 22
@@ -54,14 +51,14 @@ namespace WixToolset.BuildTasks
54 { 51 {
55 ITaskItem item = this.ProjectReferencePaths[i]; 52 ITaskItem item = this.ProjectReferencePaths[i];
56 53
57 if (!String.IsNullOrEmpty(item.GetMetadata(Common.DoNotHarvest))) 54 if (!String.IsNullOrEmpty(item.GetMetadata(ToolsCommon.DoNotHarvest)))
58 { 55 {
59 continue; 56 continue;
60 } 57 }
61 58
62 string projectPath = CreateProjectReferenceDefineConstants.GetProjectPath(this.ProjectReferencePaths, i); 59 string projectPath = CreateProjectReferenceDefineConstants.GetProjectPath(this.ProjectReferencePaths, i);
63 string projectName = Path.GetFileNameWithoutExtension(projectPath); 60 string projectName = Path.GetFileNameWithoutExtension(projectPath);
64 string referenceName = Common.GetIdentifierFromName(CreateProjectReferenceDefineConstants.GetReferenceName(item, projectName)); 61 string referenceName = ToolsCommon.GetIdentifierFromName(CreateProjectReferenceDefineConstants.GetReferenceName(item, projectName));
65 62
66 string[] pogs = item.GetMetadata("RefProjectOutputGroups").Split(';'); 63 string[] pogs = item.GetMetadata("RefProjectOutputGroups").Split(';');
67 foreach (string pog in pogs) 64 foreach (string pog in pogs)
diff --git a/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj b/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj
index 8a5c388d..39c8824c 100644
--- a/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj
+++ b/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj
@@ -28,6 +28,10 @@
28 </ItemGroup> 28 </ItemGroup>
29 29
30 <ItemGroup> 30 <ItemGroup>
31 <ProjectReference Include="..\WixToolset.Tools.Core\WixToolset.Tools.Core.csproj" />
32 </ItemGroup>
33
34 <ItemGroup>
31 <ProjectReference Include="$(WixToolsetRootFolder)\Core\src\WixToolset.Core\WixToolset.Core.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Core\README.md') " /> 35 <ProjectReference Include="$(WixToolsetRootFolder)\Core\src\WixToolset.Core\WixToolset.Core.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Core\README.md') " />
32 <PackageReference Include="WixToolset.Core" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Core\README.md') " /> 36 <PackageReference Include="WixToolset.Core" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Core\README.md') " />
33 37