aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/Bind
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/Bind')
-rw-r--r--src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs15
-rw-r--r--src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs78
-rw-r--r--src/WixToolset.Core/Bind/ResolvedDirectory.cs18
3 files changed, 53 insertions, 58 deletions
diff --git a/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs b/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs
index 7de40fb8..7e7c21b1 100644
--- a/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs
+++ b/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs
@@ -11,7 +11,12 @@ namespace WixToolset.Core.Bind
11 11
12 public class ExtractEmbeddedFilesCommand 12 public class ExtractEmbeddedFilesCommand
13 { 13 {
14 public IEnumerable<IExpectedExtractFile> FilesWithEmbeddedFiles { private get; set; } 14 public ExtractEmbeddedFilesCommand(IEnumerable<IExpectedExtractFile> embeddedFiles)
15 {
16 this.FilesWithEmbeddedFiles = embeddedFiles;
17 }
18
19 private IEnumerable<IExpectedExtractFile> FilesWithEmbeddedFiles { get; }
15 20
16 public void Execute() 21 public void Execute()
17 { 22 {
@@ -28,10 +33,10 @@ namespace WixToolset.Core.Bind
28 // a .wixlib embedded in a WixExtension). 33 // a .wixlib embedded in a WixExtension).
29 if ("embeddedresource" == baseUri.Scheme) 34 if ("embeddedresource" == baseUri.Scheme)
30 { 35 {
31 string assemblyPath = Path.GetFullPath(baseUri.LocalPath); 36 var assemblyPath = Path.GetFullPath(baseUri.LocalPath);
32 string resourceName = baseUri.Fragment.TrimStart('#'); 37 var resourceName = baseUri.Fragment.TrimStart('#');
33 38
34 Assembly assembly = Assembly.LoadFile(assemblyPath); 39 var assembly = Assembly.LoadFile(assemblyPath);
35 stream = assembly.GetManifestResourceStream(resourceName); 40 stream = assembly.GetManifestResourceStream(resourceName);
36 } 41 }
37 else // normal file (usually a binary .wixlib on disk). 42 else // normal file (usually a binary .wixlib on disk).
@@ -39,7 +44,7 @@ namespace WixToolset.Core.Bind
39 stream = File.OpenRead(baseUri.LocalPath); 44 stream = File.OpenRead(baseUri.LocalPath);
40 } 45 }
41 46
42 using (FileStructure fs = FileStructure.Read(stream)) 47 using (var fs = FileStructure.Read(stream))
43 { 48 {
44 var uniqueIndicies = new SortedSet<int>(); 49 var uniqueIndicies = new SortedSet<int>();
45 50
diff --git a/src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs b/src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs
index d05135cf..4585b71a 100644
--- a/src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs
+++ b/src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs
@@ -12,25 +12,28 @@ namespace WixToolset.Core.Bind
12 /// Resolves the fields which had variables that needed to be resolved after the file information 12 /// Resolves the fields which had variables that needed to be resolved after the file information
13 /// was loaded. 13 /// was loaded.
14 /// </summary> 14 /// </summary>
15 public class ResolveDelayedFieldsCommand : ICommand 15 public class ResolveDelayedFieldsCommand
16 { 16 {
17 public OutputType OutputType { private get; set;} 17 /// <summary>
18 18 /// Resolve delayed fields.
19 public IEnumerable<IDelayedField> DelayedFields { private get; set;} 19 /// </summary>
20 /// <param name="delayedFields">The fields which had resolution delayed.</param>
21 /// <param name="variableCache">The file information to use when resolving variables.</param>
22 public ResolveDelayedFieldsCommand(IEnumerable<IDelayedField> delayedFields, Dictionary<string, string> variableCache)
23 {
24 this.DelayedFields = delayedFields;
25 this.VariableCache = variableCache;
26 }
20 27
21 public IDictionary<string, string> VariableCache { private get; set; } 28 private IEnumerable<IDelayedField> DelayedFields { get;}
22 29
23 public string ModularizationGuid { private get; set; } 30 private IDictionary<string, string> VariableCache { get; }
24 31
25 /// <param name="output">Internal representation of the msi database to operate upon.</param>
26 /// <param name="delayedFields">The fields which had resolution delayed.</param>
27 /// <param name="variableCache">The file information to use when resolving variables.</param>
28 /// <param name="modularizationGuid">The modularization guid (used in case of a merge module).</param>
29 public void Execute() 32 public void Execute()
30 { 33 {
31 var deferredFields = new List<IDelayedField>(); 34 var deferredFields = new List<IDelayedField>();
32 35
33 foreach (IDelayedField delayedField in this.DelayedFields) 36 foreach (var delayedField in this.DelayedFields)
34 { 37 {
35 try 38 try
36 { 39 {
@@ -42,7 +45,7 @@ namespace WixToolset.Core.Bind
42 var value = WixVariableResolver.ResolveDelayedVariables(propertyRow.SourceLineNumbers, delayedField.Field.AsString(), this.VariableCache); 45 var value = WixVariableResolver.ResolveDelayedVariables(propertyRow.SourceLineNumbers, delayedField.Field.AsString(), this.VariableCache);
43 46
44 // update the variable cache with the new value 47 // update the variable cache with the new value
45 var key = String.Concat("property.", Common.Demodularize(this.OutputType, this.ModularizationGuid, (string)propertyRow[0])); 48 var key = String.Concat("property.", propertyRow.AsString(0));
46 this.VariableCache[key] = value; 49 this.VariableCache[key] = value;
47 50
48 // update the field data 51 // update the field data
@@ -62,43 +65,31 @@ namespace WixToolset.Core.Bind
62 65
63 // add specialization for ProductVersion fields 66 // add specialization for ProductVersion fields
64 string keyProductVersion = "property.ProductVersion"; 67 string keyProductVersion = "property.ProductVersion";
65 if (this.VariableCache.ContainsKey(keyProductVersion)) 68 if (this.VariableCache.TryGetValue(keyProductVersion, out var versionValue) && Version.TryParse(versionValue, out Version productVersion))
66 { 69 {
67 string value = this.VariableCache[keyProductVersion]; 70 // Don't add the variable if it already exists (developer defined a property with the same name).
68 Version productVersion = null; 71 string fieldKey = String.Concat(keyProductVersion, ".Major");
69 72 if (!this.VariableCache.ContainsKey(fieldKey))
70 try
71 { 73 {
72 productVersion = new Version(value); 74 this.VariableCache[fieldKey] = productVersion.Major.ToString(CultureInfo.InvariantCulture);
73 75 }
74 // Don't add the variable if it already exists (developer defined a property with the same name).
75 string fieldKey = String.Concat(keyProductVersion, ".Major");
76 if (!this.VariableCache.ContainsKey(fieldKey))
77 {
78 this.VariableCache[fieldKey] = productVersion.Major.ToString(CultureInfo.InvariantCulture);
79 }
80
81 fieldKey = String.Concat(keyProductVersion, ".Minor");
82 if (!this.VariableCache.ContainsKey(fieldKey))
83 {
84 this.VariableCache[fieldKey] = productVersion.Minor.ToString(CultureInfo.InvariantCulture);
85 }
86 76
87 fieldKey = String.Concat(keyProductVersion, ".Build"); 77 fieldKey = String.Concat(keyProductVersion, ".Minor");
88 if (!this.VariableCache.ContainsKey(fieldKey)) 78 if (!this.VariableCache.ContainsKey(fieldKey))
89 { 79 {
90 this.VariableCache[fieldKey] = productVersion.Build.ToString(CultureInfo.InvariantCulture); 80 this.VariableCache[fieldKey] = productVersion.Minor.ToString(CultureInfo.InvariantCulture);
91 } 81 }
92 82
93 fieldKey = String.Concat(keyProductVersion, ".Revision"); 83 fieldKey = String.Concat(keyProductVersion, ".Build");
94 if (!this.VariableCache.ContainsKey(fieldKey)) 84 if (!this.VariableCache.ContainsKey(fieldKey))
95 { 85 {
96 this.VariableCache[fieldKey] = productVersion.Revision.ToString(CultureInfo.InvariantCulture); 86 this.VariableCache[fieldKey] = productVersion.Build.ToString(CultureInfo.InvariantCulture);
97 }
98 } 87 }
99 catch 88
89 fieldKey = String.Concat(keyProductVersion, ".Revision");
90 if (!this.VariableCache.ContainsKey(fieldKey))
100 { 91 {
101 // Ignore the error introduced by new behavior. 92 this.VariableCache[fieldKey] = productVersion.Revision.ToString(CultureInfo.InvariantCulture);
102 } 93 }
103 } 94 }
104 95
@@ -113,7 +104,6 @@ namespace WixToolset.Core.Bind
113 catch (WixException we) 104 catch (WixException we)
114 { 105 {
115 Messaging.Instance.OnMessage(we.Error); 106 Messaging.Instance.OnMessage(we.Error);
116 continue;
117 } 107 }
118 } 108 }
119 } 109 }
diff --git a/src/WixToolset.Core/Bind/ResolvedDirectory.cs b/src/WixToolset.Core/Bind/ResolvedDirectory.cs
index fca706d8..9d07fc93 100644
--- a/src/WixToolset.Core/Bind/ResolvedDirectory.cs
+++ b/src/WixToolset.Core/Bind/ResolvedDirectory.cs
@@ -7,15 +7,6 @@ namespace WixToolset.Bind
7 /// </summary> 7 /// </summary>
8 public struct ResolvedDirectory 8 public struct ResolvedDirectory
9 { 9 {
10 /// <summary>The directory parent.</summary>
11 public string DirectoryParent;
12
13 /// <summary>The name of this directory.</summary>
14 public string Name;
15
16 /// <summary>The path of this directory.</summary>
17 public string Path;
18
19 /// <summary> 10 /// <summary>
20 /// Constructor for ResolvedDirectory. 11 /// Constructor for ResolvedDirectory.
21 /// </summary> 12 /// </summary>
@@ -27,5 +18,14 @@ namespace WixToolset.Bind
27 this.Name = name; 18 this.Name = name;
28 this.Path = null; 19 this.Path = null;
29 } 20 }
21
22 /// <summary>The directory parent.</summary>
23 public string DirectoryParent { get; set; }
24
25 /// <summary>The name of this directory.</summary>
26 public string Name { get; set; }
27
28 /// <summary>The path of this directory.</summary>
29 public string Path { get; set; }
30 } 30 }
31} 31}