diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2020-05-06 13:42:03 +1000 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2020-05-08 22:05:22 +1000 |
commit | db3c7998c80523d8a059f7a9c3214dbc5c8c1e23 (patch) | |
tree | 7fdeb1e91c3bcfd93c9cb379afcaf45732abe04c /src | |
parent | 2d23530fde970972c927680ee3df6466538ae8ca (diff) | |
download | wix-db3c7998c80523d8a059f7a9c3214dbc5c8c1e23.tar.gz wix-db3c7998c80523d8a059f7a9c3214dbc5c8c1e23.tar.bz2 wix-db3c7998c80523d8a059f7a9c3214dbc5c8c1e23.zip |
Remove Heat files from Core.
Diffstat (limited to 'src')
-rw-r--r-- | src/WixToolset.Core.Burn/WixToolset.Core.Burn.csproj | 2 | ||||
-rw-r--r-- | src/WixToolset.Core.TestPackage/WixToolset.Core.TestPackage.csproj | 4 | ||||
-rw-r--r-- | src/WixToolset.Core.WindowsInstaller/WixToolset.Core.WindowsInstaller.csproj | 2 | ||||
-rw-r--r-- | src/WixToolset.Core/Extensibility/AssemblyDefaultHeatExtensionAttribute.cs | 33 | ||||
-rw-r--r-- | src/WixToolset.Core/Extensibility/HarvesterExtension.cs | 26 | ||||
-rw-r--r-- | src/WixToolset.Core/Extensibility/HeatExtension.cs | 200 | ||||
-rw-r--r-- | src/WixToolset.Core/Extensibility/IHarvesterCore.cs | 48 | ||||
-rw-r--r-- | src/WixToolset.Core/Extensibility/IHeatCore.cs | 22 | ||||
-rw-r--r-- | src/WixToolset.Core/Extensibility/MutatorExtension.cs | 198 | ||||
-rw-r--r-- | src/WixToolset.Core/Harvester.cs | 79 | ||||
-rw-r--r-- | src/WixToolset.Core/HarvesterCore.cs | 75 | ||||
-rw-r--r-- | src/WixToolset.Core/HeatCore.cs | 43 | ||||
-rw-r--r-- | src/WixToolset.Core/Mutator.cs | 115 | ||||
-rw-r--r-- | src/WixToolset.Core/WixToolset.Core.csproj | 2 |
14 files changed, 5 insertions, 844 deletions
diff --git a/src/WixToolset.Core.Burn/WixToolset.Core.Burn.csproj b/src/WixToolset.Core.Burn/WixToolset.Core.Burn.csproj index ae0e7023..786db9be 100644 --- a/src/WixToolset.Core.Burn/WixToolset.Core.Burn.csproj +++ b/src/WixToolset.Core.Burn/WixToolset.Core.Burn.csproj | |||
@@ -28,7 +28,7 @@ | |||
28 | </ItemGroup> | 28 | </ItemGroup> |
29 | 29 | ||
30 | <ItemGroup> | 30 | <ItemGroup> |
31 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All"/> | 31 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" /> |
32 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="all" /> | 32 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="all" /> |
33 | </ItemGroup> | 33 | </ItemGroup> |
34 | </Project> | 34 | </Project> |
diff --git a/src/WixToolset.Core.TestPackage/WixToolset.Core.TestPackage.csproj b/src/WixToolset.Core.TestPackage/WixToolset.Core.TestPackage.csproj index e5a550f3..b58c38e8 100644 --- a/src/WixToolset.Core.TestPackage/WixToolset.Core.TestPackage.csproj +++ b/src/WixToolset.Core.TestPackage/WixToolset.Core.TestPackage.csproj | |||
@@ -1,4 +1,4 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | 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. --> | 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 | 3 | ||
4 | <Project Sdk="Microsoft.NET.Sdk"> | 4 | <Project Sdk="Microsoft.NET.Sdk"> |
@@ -22,7 +22,7 @@ | |||
22 | </ItemGroup> | 22 | </ItemGroup> |
23 | 23 | ||
24 | <ItemGroup> | 24 | <ItemGroup> |
25 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All"/> | 25 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" /> |
26 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" /> | 26 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" /> |
27 | </ItemGroup> | 27 | </ItemGroup> |
28 | 28 | ||
diff --git a/src/WixToolset.Core.WindowsInstaller/WixToolset.Core.WindowsInstaller.csproj b/src/WixToolset.Core.WindowsInstaller/WixToolset.Core.WindowsInstaller.csproj index 5d68bfe4..c631b53b 100644 --- a/src/WixToolset.Core.WindowsInstaller/WixToolset.Core.WindowsInstaller.csproj +++ b/src/WixToolset.Core.WindowsInstaller/WixToolset.Core.WindowsInstaller.csproj | |||
@@ -24,7 +24,7 @@ | |||
24 | </ItemGroup> | 24 | </ItemGroup> |
25 | 25 | ||
26 | <ItemGroup> | 26 | <ItemGroup> |
27 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All" /> | 27 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" /> |
28 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="all" /> | 28 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="all" /> |
29 | </ItemGroup> | 29 | </ItemGroup> |
30 | </Project> | 30 | </Project> |
diff --git a/src/WixToolset.Core/Extensibility/AssemblyDefaultHeatExtensionAttribute.cs b/src/WixToolset.Core/Extensibility/AssemblyDefaultHeatExtensionAttribute.cs deleted file mode 100644 index bb53e30c..00000000 --- a/src/WixToolset.Core/Extensibility/AssemblyDefaultHeatExtensionAttribute.cs +++ /dev/null | |||
@@ -1,33 +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 | |||
3 | namespace WixToolset.Tools | ||
4 | { | ||
5 | using System; | ||
6 | |||
7 | /// <summary> | ||
8 | /// Represents a custom attribute for declaring the type to use | ||
9 | /// as the default heat extension in an assembly. | ||
10 | /// </summary> | ||
11 | public class AssemblyDefaultHeatExtensionAttribute : Attribute | ||
12 | { | ||
13 | private readonly Type extensionType; | ||
14 | |||
15 | /// <summary> | ||
16 | /// Instantiate a new AssemblyDefaultHeatExtensionAttribute. | ||
17 | /// </summary> | ||
18 | /// <param name="extensionType">The type of the default heat extension in an assembly.</param> | ||
19 | public AssemblyDefaultHeatExtensionAttribute(Type extensionType) | ||
20 | { | ||
21 | this.extensionType = extensionType; | ||
22 | } | ||
23 | |||
24 | /// <summary> | ||
25 | /// Gets the type of the default heat extension in an assembly. | ||
26 | /// </summary> | ||
27 | /// <value>The type of the default heat extension in an assembly.</value> | ||
28 | public Type ExtensionType | ||
29 | { | ||
30 | get { return this.extensionType; } | ||
31 | } | ||
32 | } | ||
33 | } | ||
diff --git a/src/WixToolset.Core/Extensibility/HarvesterExtension.cs b/src/WixToolset.Core/Extensibility/HarvesterExtension.cs deleted file mode 100644 index d8d0ab34..00000000 --- a/src/WixToolset.Core/Extensibility/HarvesterExtension.cs +++ /dev/null | |||
@@ -1,26 +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 | |||
3 | namespace WixToolset | ||
4 | { | ||
5 | using Wix = WixToolset.Data.Serialize; | ||
6 | |||
7 | /// <summary> | ||
8 | /// The base harvester extension. Any of these methods can be overridden to change | ||
9 | /// the behavior of the harvester. | ||
10 | /// </summary> | ||
11 | public abstract class HarvesterExtension | ||
12 | { | ||
13 | /// <summary> | ||
14 | /// Gets or sets the harvester core for the extension. | ||
15 | /// </summary> | ||
16 | /// <value>The harvester core for the extension.</value> | ||
17 | public IHarvesterCore Core { get; set; } | ||
18 | |||
19 | /// <summary> | ||
20 | /// Harvest a WiX document. | ||
21 | /// </summary> | ||
22 | /// <param name="argument">The argument for harvesting.</param> | ||
23 | /// <returns>The harvested Fragments.</returns> | ||
24 | public abstract Wix.Fragment[] Harvest(string argument); | ||
25 | } | ||
26 | } | ||
diff --git a/src/WixToolset.Core/Extensibility/HeatExtension.cs b/src/WixToolset.Core/Extensibility/HeatExtension.cs deleted file mode 100644 index b0da75f1..00000000 --- a/src/WixToolset.Core/Extensibility/HeatExtension.cs +++ /dev/null | |||
@@ -1,200 +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 | |||
3 | namespace WixToolset.Core.Extensibility | ||
4 | { | ||
5 | using System; | ||
6 | using System.IO; | ||
7 | using System.Reflection; | ||
8 | using WixToolset.Data; | ||
9 | using WixToolset.Tools; | ||
10 | |||
11 | /// <summary> | ||
12 | /// A command line option. | ||
13 | /// </summary> | ||
14 | public struct HeatCommandLineOption | ||
15 | { | ||
16 | public string Option; | ||
17 | |||
18 | public string Description; | ||
19 | |||
20 | /// <summary> | ||
21 | /// Instantiates a new CommandLineOption. | ||
22 | /// </summary> | ||
23 | /// <param name="option">The option name.</param> | ||
24 | /// <param name="description">The description of the option.</param> | ||
25 | public HeatCommandLineOption(string option, string description) | ||
26 | { | ||
27 | this.Option = option; | ||
28 | this.Description = description; | ||
29 | } | ||
30 | } | ||
31 | |||
32 | /// <summary> | ||
33 | /// An extension for the WiX Toolset Harvester application. | ||
34 | /// </summary> | ||
35 | public abstract class HeatExtension | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Gets or sets the heat core for the extension. | ||
39 | /// </summary> | ||
40 | /// <value>The heat core for the extension.</value> | ||
41 | public IHeatCore Core { get; set; } | ||
42 | |||
43 | /// <summary> | ||
44 | /// Gets the supported command line types for this extension. | ||
45 | /// </summary> | ||
46 | /// <value>The supported command line types for this extension.</value> | ||
47 | public virtual HeatCommandLineOption[] CommandLineTypes | ||
48 | { | ||
49 | get { return null; } | ||
50 | } | ||
51 | |||
52 | /// <summary> | ||
53 | /// Loads a HeatExtension from a type description string. | ||
54 | /// </summary> | ||
55 | /// <param name="extension">The extension type description string.</param> | ||
56 | /// <returns>The loaded HeatExtension.</returns> | ||
57 | /// <remarks> | ||
58 | /// <paramref name="extension"/> can be in several different forms: | ||
59 | /// <list type="number"> | ||
60 | /// <item><term>AssemblyQualifiedName (TopNamespace.SubNameSpace.ContainingClass+NestedClass, MyAssembly, Version=1.3.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089)</term></item> | ||
61 | /// <item><term>AssemblyName (MyAssembly, Version=1.3.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089)</term></item> | ||
62 | /// <item><term>Absolute path to an assembly (C:\MyExtensions\ExtensionAssembly.dll)</term></item> | ||
63 | /// <item><term>Filename of an assembly in the application directory (ExtensionAssembly.dll)</term></item> | ||
64 | /// <item><term>Relative path to an assembly (..\..\MyExtensions\ExtensionAssembly.dll)</term></item> | ||
65 | /// </list> | ||
66 | /// To specify a particular class to use, prefix the fully qualified class name to the assembly and separate them with a comma. | ||
67 | /// For example: "TopNamespace.SubNameSpace.ContainingClass+NestedClass, C:\MyExtensions\ExtensionAssembly.dll" | ||
68 | /// </remarks> | ||
69 | public static HeatExtension Load(string extension) | ||
70 | { | ||
71 | Type extensionType = null; | ||
72 | int commaIndex = extension.IndexOf(','); | ||
73 | string className = String.Empty; | ||
74 | string assemblyName = extension; | ||
75 | |||
76 | if (0 <= commaIndex) | ||
77 | { | ||
78 | className = extension.Substring(0, commaIndex); | ||
79 | assemblyName = (extension.Length <= commaIndex + 1 ? String.Empty : extension.Substring(commaIndex + 1)); | ||
80 | } | ||
81 | |||
82 | className = className.Trim(); | ||
83 | assemblyName = assemblyName.Trim(); | ||
84 | |||
85 | if (null == extensionType && 0 < assemblyName.Length) | ||
86 | { | ||
87 | |||
88 | Assembly extensionAssembly; | ||
89 | |||
90 | // case 3: Absolute path to an assembly | ||
91 | if (Path.IsPathRooted(assemblyName)) | ||
92 | { | ||
93 | extensionAssembly = ExtensionLoadFrom(assemblyName); | ||
94 | } | ||
95 | else | ||
96 | { | ||
97 | try | ||
98 | { | ||
99 | // case 2: AssemblyName | ||
100 | extensionAssembly = Assembly.Load(assemblyName); | ||
101 | } | ||
102 | catch (IOException e) | ||
103 | { | ||
104 | if (e is FileLoadException || e is FileNotFoundException) | ||
105 | { | ||
106 | try | ||
107 | { | ||
108 | // case 4: Filename of an assembly in the application directory | ||
109 | extensionAssembly = Assembly.Load(Path.GetFileNameWithoutExtension(assemblyName)); | ||
110 | } | ||
111 | catch (IOException innerE) | ||
112 | { | ||
113 | if (innerE is FileLoadException || innerE is FileNotFoundException) | ||
114 | { | ||
115 | // case 5: Relative path to an assembly | ||
116 | |||
117 | // we want to use Assembly.Load when we can because it has some benefits over Assembly.LoadFrom | ||
118 | // (see the documentation for Assembly.LoadFrom). However, it may fail when the path is a relative | ||
119 | // path, so we should try Assembly.LoadFrom one last time. We could have detected a directory | ||
120 | // separator character and used Assembly.LoadFrom directly, but dealing with path canonicalization | ||
121 | // issues is something we don't want to deal with if we don't have to. | ||
122 | extensionAssembly = ExtensionLoadFrom(assemblyName); | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | throw new WixException(ErrorMessages.InvalidExtension(assemblyName, innerE.Message)); | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | else | ||
131 | { | ||
132 | throw new WixException(ErrorMessages.InvalidExtension(assemblyName, e.Message)); | ||
133 | } | ||
134 | } | ||
135 | } | ||
136 | |||
137 | if (0 < className.Length) | ||
138 | { | ||
139 | try | ||
140 | { | ||
141 | // case 1: AssemblyQualifiedName | ||
142 | extensionType = extensionAssembly.GetType(className, true /* throwOnError */, true /* ignoreCase */); | ||
143 | } | ||
144 | catch (Exception e) | ||
145 | { | ||
146 | throw new WixException(ErrorMessages.InvalidExtensionType(assemblyName, className, e.GetType().ToString(), e.Message)); | ||
147 | } | ||
148 | } | ||
149 | else | ||
150 | { | ||
151 | // if no class name was specified, then let's hope the assembly defined a default WixExtension | ||
152 | AssemblyDefaultHeatExtensionAttribute extensionAttribute = (AssemblyDefaultHeatExtensionAttribute)Attribute.GetCustomAttribute(extensionAssembly, typeof(AssemblyDefaultHeatExtensionAttribute)); | ||
153 | |||
154 | if (null != extensionAttribute) | ||
155 | { | ||
156 | extensionType = extensionAttribute.ExtensionType; | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | throw new WixException(ErrorMessages.InvalidExtensionType(assemblyName, typeof(AssemblyDefaultHeatExtensionAttribute).ToString())); | ||
161 | } | ||
162 | } | ||
163 | } | ||
164 | |||
165 | if (extensionType.IsSubclassOf(typeof(HeatExtension))) | ||
166 | { | ||
167 | return Activator.CreateInstance(extensionType) as HeatExtension; | ||
168 | } | ||
169 | else | ||
170 | { | ||
171 | throw new WixException(ErrorMessages.InvalidExtensionType(extension, extensionType.ToString(), typeof(HeatExtension).ToString())); | ||
172 | } | ||
173 | } | ||
174 | |||
175 | /// <summary> | ||
176 | /// Parse the command line options for this extension. | ||
177 | /// </summary> | ||
178 | /// <param name="type">The active harvester type.</param> | ||
179 | /// <param name="args">The option arguments.</param> | ||
180 | public virtual void ParseOptions(string type, string[] args) | ||
181 | { | ||
182 | } | ||
183 | |||
184 | private static Assembly ExtensionLoadFrom(string assemblyName) | ||
185 | { | ||
186 | Assembly extensionAssembly = null; | ||
187 | |||
188 | try | ||
189 | { | ||
190 | extensionAssembly = Assembly.LoadFrom(assemblyName); | ||
191 | } | ||
192 | catch (Exception e) | ||
193 | { | ||
194 | throw new WixException(ErrorMessages.InvalidExtension(assemblyName, e.Message)); | ||
195 | } | ||
196 | |||
197 | return extensionAssembly; | ||
198 | } | ||
199 | } | ||
200 | } | ||
diff --git a/src/WixToolset.Core/Extensibility/IHarvesterCore.cs b/src/WixToolset.Core/Extensibility/IHarvesterCore.cs deleted file mode 100644 index a9001b46..00000000 --- a/src/WixToolset.Core/Extensibility/IHarvesterCore.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 | |||
3 | namespace WixToolset | ||
4 | { | ||
5 | using WixToolset.Extensibility.Services; | ||
6 | |||
7 | /// <summary> | ||
8 | /// The WiX Toolset harvester core. | ||
9 | /// </summary> | ||
10 | public interface IHarvesterCore | ||
11 | { | ||
12 | IMessaging Messaging { get; set; } | ||
13 | |||
14 | /// <summary> | ||
15 | /// Gets or sets the value of the extension argument passed to heat. | ||
16 | /// </summary> | ||
17 | /// <value>The extension argument.</value> | ||
18 | string ExtensionArgument { get; set; } | ||
19 | |||
20 | /// <summary> | ||
21 | /// Gets or sets the value of the root directory that is being harvested. | ||
22 | /// </summary> | ||
23 | /// <value>The root directory being harvested.</value> | ||
24 | string RootDirectory { get; set; } | ||
25 | |||
26 | /// <summary> | ||
27 | /// Create an identifier based on passed file name | ||
28 | /// </summary> | ||
29 | /// <param name="name">File name to generate identifer from</param> | ||
30 | /// <returns></returns> | ||
31 | string CreateIdentifierFromFilename(string filename); | ||
32 | |||
33 | /// <summary> | ||
34 | /// Generate an identifier by hashing data from the row. | ||
35 | /// </summary> | ||
36 | /// <param name="prefix">Three letter or less prefix for generated row identifier.</param> | ||
37 | /// <param name="args">Information to hash.</param> | ||
38 | /// <returns>The generated identifier.</returns> | ||
39 | string GenerateIdentifier(string prefix, params string[] args); | ||
40 | |||
41 | /// <summary> | ||
42 | /// Resolves a file's path if the Wix.File.Source value starts with "SourceDir\". | ||
43 | /// </summary> | ||
44 | /// <param name="fileSource">The Wix.File.Source value with "SourceDir\".</param> | ||
45 | /// <returns>The full path of the file.</returns> | ||
46 | string ResolveFilePath(string fileSource); | ||
47 | } | ||
48 | } | ||
diff --git a/src/WixToolset.Core/Extensibility/IHeatCore.cs b/src/WixToolset.Core/Extensibility/IHeatCore.cs deleted file mode 100644 index 1365dfaf..00000000 --- a/src/WixToolset.Core/Extensibility/IHeatCore.cs +++ /dev/null | |||
@@ -1,22 +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 | |||
3 | namespace WixToolset.Core.Extensibility | ||
4 | { | ||
5 | /// <summary> | ||
6 | /// The WiX Toolset Harvester application core. | ||
7 | /// </summary> | ||
8 | public interface IHeatCore | ||
9 | { | ||
10 | /// <summary> | ||
11 | /// Gets the harvester. | ||
12 | /// </summary> | ||
13 | /// <value>The harvester.</value> | ||
14 | Harvester Harvester { get; } | ||
15 | |||
16 | /// <summary> | ||
17 | /// Gets the mutator. | ||
18 | /// </summary> | ||
19 | /// <value>The mutator.</value> | ||
20 | Mutator Mutator { get; } | ||
21 | } | ||
22 | } | ||
diff --git a/src/WixToolset.Core/Extensibility/MutatorExtension.cs b/src/WixToolset.Core/Extensibility/MutatorExtension.cs deleted file mode 100644 index afc76b79..00000000 --- a/src/WixToolset.Core/Extensibility/MutatorExtension.cs +++ /dev/null | |||
@@ -1,198 +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 | |||
3 | namespace WixToolset.Core.Extensibility | ||
4 | { | ||
5 | using System; | ||
6 | using System.Collections.Generic; | ||
7 | using System.Diagnostics.CodeAnalysis; | ||
8 | using System.Text; | ||
9 | |||
10 | using Wix = WixToolset.Data.Serialize; | ||
11 | |||
12 | /// <summary> | ||
13 | /// The base mutator extension. Any of these methods can be overridden to change | ||
14 | /// the behavior of the mutator. | ||
15 | /// </summary> | ||
16 | public abstract class MutatorExtension | ||
17 | { | ||
18 | /// <summary> | ||
19 | /// Gets or sets the mutator core for the extension. | ||
20 | /// </summary> | ||
21 | /// <value>The mutator core for the extension.</value> | ||
22 | public IHarvesterCore Core { get; set; } | ||
23 | |||
24 | /// <summary> | ||
25 | /// Gets the sequence of the extension. | ||
26 | /// </summary> | ||
27 | /// <value>The sequence of the extension.</value> | ||
28 | public abstract int Sequence | ||
29 | { | ||
30 | get; | ||
31 | } | ||
32 | |||
33 | /// <summary> | ||
34 | /// Mutate a WiX document. | ||
35 | /// </summary> | ||
36 | /// <param name="wix">The Wix document element.</param> | ||
37 | public virtual void Mutate(Wix.Wix wix) | ||
38 | { | ||
39 | } | ||
40 | |||
41 | /// <summary> | ||
42 | /// Mutate a WiX document as a string. | ||
43 | /// </summary> | ||
44 | /// <param name="wix">The Wix document element as a string.</param> | ||
45 | /// <returns>The mutated Wix document as a string.</returns> | ||
46 | public virtual string Mutate(string wixString) | ||
47 | { | ||
48 | return wixString; | ||
49 | } | ||
50 | |||
51 | /// <summary> | ||
52 | /// Generate unique MSI identifiers. | ||
53 | /// </summary> | ||
54 | protected class IdentifierGenerator | ||
55 | { | ||
56 | public const int MaxProductIdentifierLength = 72; | ||
57 | public const int MaxModuleIdentifierLength = 35; | ||
58 | |||
59 | private string baseName; | ||
60 | private int maxLength; | ||
61 | private Dictionary<string, object> existingIdentifiers; | ||
62 | private Dictionary<string, object> possibleIdentifiers; | ||
63 | |||
64 | /// <summary> | ||
65 | /// Instantiate a new IdentifierGenerator. | ||
66 | /// </summary> | ||
67 | /// <param name="baseName">The base resource name to use if a resource name contains no usable characters.</param> | ||
68 | public IdentifierGenerator(string baseName) | ||
69 | { | ||
70 | this.baseName = baseName; | ||
71 | this.maxLength = IdentifierGenerator.MaxProductIdentifierLength; | ||
72 | this.existingIdentifiers = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); | ||
73 | this.possibleIdentifiers = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); | ||
74 | } | ||
75 | |||
76 | /// <summary> | ||
77 | /// Gets or sets the maximum length for generated identifiers. | ||
78 | /// </summary> | ||
79 | /// <value>Maximum length for generated identifiers. (Default is 72.)</value> | ||
80 | public int MaxIdentifierLength | ||
81 | { | ||
82 | get { return this.maxLength; } | ||
83 | set { this.maxLength = value; } | ||
84 | } | ||
85 | |||
86 | /// <summary> | ||
87 | /// Index an existing identifier for collision detection. | ||
88 | /// </summary> | ||
89 | /// <param name="identifier">The identifier.</param> | ||
90 | public void IndexExistingIdentifier(string identifier) | ||
91 | { | ||
92 | if (null == identifier) | ||
93 | { | ||
94 | throw new ArgumentNullException("identifier"); | ||
95 | } | ||
96 | |||
97 | this.existingIdentifiers[identifier] = null; | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
101 | /// Index a resource name for collision detection. | ||
102 | /// </summary> | ||
103 | /// <param name="name">The resource name.</param> | ||
104 | public void IndexName(string name) | ||
105 | { | ||
106 | if (null == name) | ||
107 | { | ||
108 | throw new ArgumentNullException("name"); | ||
109 | } | ||
110 | |||
111 | string identifier = this.CreateIdentifier(name, 0); | ||
112 | |||
113 | if (this.possibleIdentifiers.ContainsKey(identifier)) | ||
114 | { | ||
115 | this.possibleIdentifiers[identifier] = String.Empty; | ||
116 | } | ||
117 | else | ||
118 | { | ||
119 | this.possibleIdentifiers.Add(identifier, null); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | /// <summary> | ||
124 | /// Get the identifier for the given resource name. | ||
125 | /// </summary> | ||
126 | /// <param name="name">The resource name.</param> | ||
127 | /// <returns>A legal MSI identifier.</returns> | ||
128 | [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.InvalidOperationException.#ctor(System.String)")] | ||
129 | public string GetIdentifier(string name) | ||
130 | { | ||
131 | if (null == name) | ||
132 | { | ||
133 | throw new ArgumentNullException("name"); | ||
134 | } | ||
135 | |||
136 | for (int i = 0; i <= Int32.MaxValue; i++) | ||
137 | { | ||
138 | string identifier = this.CreateIdentifier(name, i); | ||
139 | |||
140 | if (this.existingIdentifiers.ContainsKey(identifier) || // already used | ||
141 | (0 == i && 0 != this.possibleIdentifiers.Count && null != this.possibleIdentifiers[identifier]) || // needs an index because its duplicated | ||
142 | (0 != i && this.possibleIdentifiers.ContainsKey(identifier))) // collides with another possible identifier | ||
143 | { | ||
144 | continue; | ||
145 | } | ||
146 | else // use this identifier | ||
147 | { | ||
148 | this.existingIdentifiers.Add(identifier, null); | ||
149 | |||
150 | return identifier; | ||
151 | } | ||
152 | } | ||
153 | |||
154 | throw new InvalidOperationException("Could not find a unique identifier for the given resource name."); | ||
155 | } | ||
156 | |||
157 | /// <summary> | ||
158 | /// Create a legal MSI identifier from a resource name and an index. | ||
159 | /// </summary> | ||
160 | /// <param name="name">The name of the resource for which an identifier should be created.</param> | ||
161 | /// <param name="index">An index to append to the end of the identifier to make it unique.</param> | ||
162 | /// <returns>A legal MSI identifier.</returns> | ||
163 | public string CreateIdentifier(string name, int index) | ||
164 | { | ||
165 | if (null == name) | ||
166 | { | ||
167 | throw new ArgumentNullException("name"); | ||
168 | } | ||
169 | |||
170 | StringBuilder identifier = new StringBuilder(); | ||
171 | |||
172 | // Convert the name to a standard MSI identifier | ||
173 | identifier.Append(Common.GetIdentifierFromName(name)); | ||
174 | |||
175 | // no legal identifier characters were found, use the base id instead | ||
176 | if (0 == identifier.Length) | ||
177 | { | ||
178 | identifier.Append(this.baseName); | ||
179 | } | ||
180 | |||
181 | // truncate the identifier if it's too long (reserve 3 characters for up to 99 collisions) | ||
182 | int adjustedMaxLength = this.MaxIdentifierLength - (index != 0 ? 3 : 0); | ||
183 | if (adjustedMaxLength < identifier.Length) | ||
184 | { | ||
185 | identifier.Length = adjustedMaxLength; | ||
186 | } | ||
187 | |||
188 | // if the index is not zero, then append it to the identifier name | ||
189 | if (0 != index) | ||
190 | { | ||
191 | identifier.AppendFormat("_{0}", index); | ||
192 | } | ||
193 | |||
194 | return identifier.ToString(); | ||
195 | } | ||
196 | } | ||
197 | } | ||
198 | } | ||
diff --git a/src/WixToolset.Core/Harvester.cs b/src/WixToolset.Core/Harvester.cs deleted file mode 100644 index 3399420c..00000000 --- a/src/WixToolset.Core/Harvester.cs +++ /dev/null | |||
@@ -1,79 +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 | |||
3 | namespace WixToolset.Core | ||
4 | { | ||
5 | using System; | ||
6 | using System.Diagnostics.CodeAnalysis; | ||
7 | using WixToolset.Data; | ||
8 | using Wix = WixToolset.Data.Serialize; | ||
9 | |||
10 | /// <summary> | ||
11 | /// The WiX Toolset harvester. | ||
12 | /// </summary> | ||
13 | public class Harvester | ||
14 | { | ||
15 | private HarvesterExtension harvesterExtension; | ||
16 | |||
17 | /// <summary> | ||
18 | /// Gets or sets the harvester core for the extension. | ||
19 | /// </summary> | ||
20 | /// <value>The harvester core for the extension.</value> | ||
21 | public IHarvesterCore Core { get; set; } | ||
22 | |||
23 | /// <summary> | ||
24 | /// Gets or sets the extension. | ||
25 | /// </summary> | ||
26 | /// <value>The extension.</value> | ||
27 | [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.InvalidOperationException.#ctor(System.String)")] | ||
28 | public HarvesterExtension Extension | ||
29 | { | ||
30 | get | ||
31 | { | ||
32 | return this.harvesterExtension; | ||
33 | } | ||
34 | set | ||
35 | { | ||
36 | if (null != this.harvesterExtension) | ||
37 | { | ||
38 | throw new InvalidOperationException("Multiple harvester extensions specified."); | ||
39 | } | ||
40 | |||
41 | this.harvesterExtension = value; | ||
42 | } | ||
43 | } | ||
44 | |||
45 | /// <summary> | ||
46 | /// Harvest wix authoring. | ||
47 | /// </summary> | ||
48 | /// <param name="argument">The argument for harvesting.</param> | ||
49 | /// <returns>The harvested wix authoring.</returns> | ||
50 | public Wix.Wix Harvest(string argument) | ||
51 | { | ||
52 | if (null == argument) | ||
53 | { | ||
54 | throw new ArgumentNullException("argument"); | ||
55 | } | ||
56 | |||
57 | if (null == this.harvesterExtension) | ||
58 | { | ||
59 | throw new WixException(ErrorMessages.HarvestTypeNotFound()); | ||
60 | } | ||
61 | |||
62 | this.harvesterExtension.Core = this.Core; | ||
63 | |||
64 | Wix.Fragment[] fragments = this.harvesterExtension.Harvest(argument); | ||
65 | if (null == fragments || 0 == fragments.Length) | ||
66 | { | ||
67 | return null; | ||
68 | } | ||
69 | |||
70 | Wix.Wix wix = new Wix.Wix(); | ||
71 | foreach (Wix.Fragment fragment in fragments) | ||
72 | { | ||
73 | wix.AddChild(fragment); | ||
74 | } | ||
75 | |||
76 | return wix; | ||
77 | } | ||
78 | } | ||
79 | } | ||
diff --git a/src/WixToolset.Core/HarvesterCore.cs b/src/WixToolset.Core/HarvesterCore.cs deleted file mode 100644 index 70991979..00000000 --- a/src/WixToolset.Core/HarvesterCore.cs +++ /dev/null | |||
@@ -1,75 +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 | |||
3 | namespace WixToolset.Core | ||
4 | { | ||
5 | using System; | ||
6 | using System.Diagnostics.CodeAnalysis; | ||
7 | using System.IO; | ||
8 | using WixToolset.Extensibility.Services; | ||
9 | |||
10 | /// <summary> | ||
11 | /// The WiX Toolset harvester core. | ||
12 | /// </summary> | ||
13 | public class HarvesterCore : IHarvesterCore | ||
14 | { | ||
15 | public IMessaging Messaging { get; set; } | ||
16 | |||
17 | /// <summary> | ||
18 | /// Gets or sets the value of the extension argument passed to heat. | ||
19 | /// </summary> | ||
20 | /// <value>The extension argument.</value> | ||
21 | public string ExtensionArgument { get; set; } | ||
22 | |||
23 | /// <summary> | ||
24 | /// Gets or sets the value of the root directory that is being harvested. | ||
25 | /// </summary> | ||
26 | /// <value>The root directory being harvested.</value> | ||
27 | public string RootDirectory { get; set; } | ||
28 | |||
29 | /// <summary> | ||
30 | /// Create an identifier based on passed file name | ||
31 | /// </summary> | ||
32 | /// <param name="name">File name to generate identifer from</param> | ||
33 | /// <returns></returns> | ||
34 | public string CreateIdentifierFromFilename(string filename) | ||
35 | { | ||
36 | return Common.GetIdentifierFromName(filename); | ||
37 | } | ||
38 | |||
39 | /// <summary> | ||
40 | /// Generate an identifier by hashing data from the row. | ||
41 | /// </summary> | ||
42 | /// <param name="prefix">Three letter or less prefix for generated row identifier.</param> | ||
43 | /// <param name="args">Information to hash.</param> | ||
44 | /// <returns>The generated identifier.</returns> | ||
45 | [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.InvalidOperationException.#ctor(System.String)")] | ||
46 | public string GenerateIdentifier(string prefix, params string[] args) | ||
47 | { | ||
48 | return Common.GenerateIdentifier(prefix, args); | ||
49 | } | ||
50 | |||
51 | /// <summary> | ||
52 | /// Resolves a file's path if the Wix.File.Source value starts with "SourceDir\". | ||
53 | /// </summary> | ||
54 | /// <param name="fileSource">The Wix.File.Source value with "SourceDir\".</param> | ||
55 | /// <returns>The full path of the file.</returns> | ||
56 | public string ResolveFilePath(string fileSource) | ||
57 | { | ||
58 | if (fileSource.StartsWith("SourceDir\\", StringComparison.Ordinal)) | ||
59 | { | ||
60 | string file = Path.GetFullPath(this.RootDirectory); | ||
61 | if (File.Exists(file)) | ||
62 | { | ||
63 | return file; | ||
64 | } | ||
65 | else | ||
66 | { | ||
67 | fileSource = fileSource.Substring(10); | ||
68 | fileSource = Path.Combine(Path.GetFullPath(this.RootDirectory), fileSource); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | return fileSource; | ||
73 | } | ||
74 | } | ||
75 | } | ||
diff --git a/src/WixToolset.Core/HeatCore.cs b/src/WixToolset.Core/HeatCore.cs deleted file mode 100644 index d43b5f3d..00000000 --- a/src/WixToolset.Core/HeatCore.cs +++ /dev/null | |||
@@ -1,43 +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 | |||
3 | namespace WixToolset.Core | ||
4 | { | ||
5 | using WixToolset.Core.Extensibility; | ||
6 | |||
7 | /// <summary> | ||
8 | /// The WiX Toolset Harvester application core. | ||
9 | /// </summary> | ||
10 | public class HeatCore : IHeatCore | ||
11 | { | ||
12 | private Harvester harvester; | ||
13 | private Mutator mutator; | ||
14 | |||
15 | /// <summary> | ||
16 | /// Instantiates a new HeatCore. | ||
17 | /// </summary> | ||
18 | /// <param name="messageHandler">The message handler for the core.</param> | ||
19 | public HeatCore() | ||
20 | { | ||
21 | this.harvester = new Harvester(); | ||
22 | this.mutator = new Mutator(); | ||
23 | } | ||
24 | |||
25 | /// <summary> | ||
26 | /// Gets the harvester. | ||
27 | /// </summary> | ||
28 | /// <value>The harvester.</value> | ||
29 | public Harvester Harvester | ||
30 | { | ||
31 | get { return this.harvester; } | ||
32 | } | ||
33 | |||
34 | /// <summary> | ||
35 | /// Gets the mutator. | ||
36 | /// </summary> | ||
37 | /// <value>The mutator.</value> | ||
38 | public Mutator Mutator | ||
39 | { | ||
40 | get { return this.mutator; } | ||
41 | } | ||
42 | } | ||
43 | } | ||
diff --git a/src/WixToolset.Core/Mutator.cs b/src/WixToolset.Core/Mutator.cs deleted file mode 100644 index cee17736..00000000 --- a/src/WixToolset.Core/Mutator.cs +++ /dev/null | |||
@@ -1,115 +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 | |||
3 | namespace WixToolset.Core | ||
4 | { | ||
5 | using System; | ||
6 | using System.Collections; | ||
7 | using WixToolset.Core.Extensibility; | ||
8 | using Wix = WixToolset.Data.Serialize; | ||
9 | |||
10 | /// <summary> | ||
11 | /// The WiX Toolset mutator. | ||
12 | /// </summary> | ||
13 | public class Mutator | ||
14 | { | ||
15 | private SortedList extensions; | ||
16 | private string extensionArgument; | ||
17 | |||
18 | /// <summary> | ||
19 | /// Instantiate a new mutator. | ||
20 | /// </summary> | ||
21 | public Mutator() | ||
22 | { | ||
23 | this.extensions = new SortedList(); | ||
24 | } | ||
25 | |||
26 | /// <summary> | ||
27 | /// Gets or sets the harvester core for the extension. | ||
28 | /// </summary> | ||
29 | /// <value>The harvester core for the extension.</value> | ||
30 | public IHarvesterCore Core { get; set; } | ||
31 | |||
32 | /// <summary> | ||
33 | /// Gets or sets the value of the extension argument passed to heat. | ||
34 | /// </summary> | ||
35 | /// <value>The extension argument.</value> | ||
36 | public string ExtensionArgument | ||
37 | { | ||
38 | get { return this.extensionArgument; } | ||
39 | set { this.extensionArgument = value; } | ||
40 | } | ||
41 | |||
42 | /// <summary> | ||
43 | /// Adds a mutator extension. | ||
44 | /// </summary> | ||
45 | /// <param name="mutatorExtension">The mutator extension to add.</param> | ||
46 | public void AddExtension(MutatorExtension mutatorExtension) | ||
47 | { | ||
48 | this.extensions.Add(mutatorExtension.Sequence, mutatorExtension); | ||
49 | } | ||
50 | |||
51 | /// <summary> | ||
52 | /// Mutate a WiX document. | ||
53 | /// </summary> | ||
54 | /// <param name="wix">The Wix document element.</param> | ||
55 | /// <returns>true if mutation was successful</returns> | ||
56 | public bool Mutate(Wix.Wix wix) | ||
57 | { | ||
58 | bool encounteredError = false; | ||
59 | |||
60 | try | ||
61 | { | ||
62 | foreach (MutatorExtension mutatorExtension in this.extensions.Values) | ||
63 | { | ||
64 | if (null == mutatorExtension.Core) | ||
65 | { | ||
66 | mutatorExtension.Core = this.Core; | ||
67 | } | ||
68 | |||
69 | mutatorExtension.Mutate(wix); | ||
70 | } | ||
71 | } | ||
72 | finally | ||
73 | { | ||
74 | encounteredError = this.Core.Messaging.EncounteredError; | ||
75 | } | ||
76 | |||
77 | // return the Wix document element only if mutation completed successfully | ||
78 | return !encounteredError; | ||
79 | } | ||
80 | |||
81 | /// <summary> | ||
82 | /// Mutate a WiX document. | ||
83 | /// </summary> | ||
84 | /// <param name="wixString">The Wix document as a string.</param> | ||
85 | /// <returns>The mutated Wix document as a string if mutation was successful, else null.</returns> | ||
86 | public string Mutate(string wixString) | ||
87 | { | ||
88 | bool encounteredError = false; | ||
89 | |||
90 | try | ||
91 | { | ||
92 | foreach (MutatorExtension mutatorExtension in this.extensions.Values) | ||
93 | { | ||
94 | if (null == mutatorExtension.Core) | ||
95 | { | ||
96 | mutatorExtension.Core = this.Core; | ||
97 | } | ||
98 | |||
99 | wixString = mutatorExtension.Mutate(wixString); | ||
100 | |||
101 | if (String.IsNullOrEmpty(wixString) || this.Core.Messaging.EncounteredError) | ||
102 | { | ||
103 | break; | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | finally | ||
108 | { | ||
109 | encounteredError = this.Core.Messaging.EncounteredError; | ||
110 | } | ||
111 | |||
112 | return encounteredError ? null : wixString; | ||
113 | } | ||
114 | } | ||
115 | } | ||
diff --git a/src/WixToolset.Core/WixToolset.Core.csproj b/src/WixToolset.Core/WixToolset.Core.csproj index 4e205641..3e7bea3b 100644 --- a/src/WixToolset.Core/WixToolset.Core.csproj +++ b/src/WixToolset.Core/WixToolset.Core.csproj | |||
@@ -25,7 +25,7 @@ | |||
25 | </ItemGroup> | 25 | </ItemGroup> |
26 | 26 | ||
27 | <ItemGroup> | 27 | <ItemGroup> |
28 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All" /> | 28 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" /> |
29 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" /> | 29 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" /> |
30 | </ItemGroup> | 30 | </ItemGroup> |
31 | </Project> | 31 | </Project> |