diff options
Diffstat (limited to 'src/WixToolset.Core/Bind/ResolveFieldsCommand.cs')
-rw-r--r-- | src/WixToolset.Core/Bind/ResolveFieldsCommand.cs | 67 |
1 files changed, 46 insertions, 21 deletions
diff --git a/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs b/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs index f4f4f9e8..9253f352 100644 --- a/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs +++ b/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | namespace WixToolset.Core.Bind | 3 | namespace WixToolset.Core.Bind |
4 | { | 4 | { |
5 | using System; | ||
5 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
6 | using WixToolset.Data; | 7 | using WixToolset.Data; |
7 | using WixToolset.Data.Bind; | 8 | using WixToolset.Data.Bind; |
@@ -24,7 +25,7 @@ namespace WixToolset.Core.Bind | |||
24 | 25 | ||
25 | public string IntermediateFolder { private get; set; } | 26 | public string IntermediateFolder { private get; set; } |
26 | 27 | ||
27 | public TableIndexedCollection Tables { private get; set; } | 28 | public Intermediate Intermediate { private get; set; } |
28 | 29 | ||
29 | public bool SupportDelayedResolution { private get; set; } | 30 | public bool SupportDelayedResolution { private get; set; } |
30 | 31 | ||
@@ -36,25 +37,39 @@ namespace WixToolset.Core.Bind | |||
36 | 37 | ||
37 | var fileResolver = new FileResolver(this.BindPaths, this.Extensions); | 38 | var fileResolver = new FileResolver(this.BindPaths, this.Extensions); |
38 | 39 | ||
39 | foreach (Table table in this.Tables) | 40 | foreach (var sections in this.Intermediate.Sections) |
40 | { | 41 | { |
41 | foreach (Row row in table.Rows) | 42 | foreach (var row in sections.Tuples) |
42 | { | 43 | { |
43 | foreach (Field field in row.Fields) | 44 | foreach (var field in row.Fields) |
44 | { | 45 | { |
45 | bool isDefault = true; | 46 | if (field == null) |
46 | bool delayedResolve = false; | 47 | { |
48 | continue; | ||
49 | } | ||
50 | |||
51 | var isDefault = true; | ||
52 | var delayedResolve = false; | ||
47 | 53 | ||
48 | // Check to make sure we're in a scenario where we can handle variable resolution. | 54 | // Check to make sure we're in a scenario where we can handle variable resolution. |
49 | if (null != delayedFields) | 55 | if (null != delayedFields) |
50 | { | 56 | { |
51 | // resolve localization and wix variables | 57 | // resolve localization and wix variables |
52 | if (field.Data is string) | 58 | if (field.Type == IntermediateFieldType.String) |
53 | { | 59 | { |
54 | field.Data = this.BindVariableResolver.ResolveVariables(row.SourceLineNumbers, field.AsString(), false, out isDefault, out delayedResolve); | 60 | var original = field.AsString(); |
55 | if (delayedResolve) | 61 | if (!String.IsNullOrEmpty(original)) |
56 | { | 62 | { |
57 | delayedFields.Add(new DelayedField(row, field)); | 63 | var value = this.BindVariableResolver.ResolveVariables(row.SourceLineNumbers, original, false, out isDefault, out delayedResolve); |
64 | if (original != value) | ||
65 | { | ||
66 | field.Set(value); | ||
67 | } | ||
68 | |||
69 | if (delayedResolve) | ||
70 | { | ||
71 | delayedFields.Add(new DelayedField(row, field)); | ||
72 | } | ||
58 | } | 73 | } |
59 | } | 74 | } |
60 | } | 75 | } |
@@ -66,44 +81,51 @@ namespace WixToolset.Core.Bind | |||
66 | } | 81 | } |
67 | 82 | ||
68 | // Resolve file paths | 83 | // Resolve file paths |
69 | if (ColumnType.Object == field.Column.Type) | 84 | if (field.Type == IntermediateFieldType.Path) |
70 | { | 85 | { |
71 | ObjectField objectField = (ObjectField)field; | 86 | var objectField = field.AsPath(); |
72 | 87 | ||
88 | #if REVISIT_FOR_PATCHING | ||
73 | // Skip file resolution if the file is to be deleted. | 89 | // Skip file resolution if the file is to be deleted. |
74 | if (RowOperation.Delete == row.Operation) | 90 | if (RowOperation.Delete == row.Operation) |
75 | { | 91 | { |
76 | continue; | 92 | continue; |
77 | } | 93 | } |
94 | #endif | ||
78 | 95 | ||
79 | // File is embedded and path to it was not modified above. | 96 | // File is embedded and path to it was not modified above. |
80 | if (objectField.EmbeddedFileIndex.HasValue && isDefault) | 97 | if (objectField.EmbeddedFileIndex.HasValue && isDefault) |
81 | { | 98 | { |
82 | string extractPath = this.FilesWithEmbeddedFiles.AddEmbeddedFileIndex(objectField.BaseUri, objectField.EmbeddedFileIndex.Value, this.IntermediateFolder); | 99 | var extractPath = this.FilesWithEmbeddedFiles.AddEmbeddedFileIndex(objectField.BaseUri, objectField.EmbeddedFileIndex.Value, this.IntermediateFolder); |
83 | 100 | ||
84 | // Set the path to the embedded file once where it will be extracted. | 101 | // Set the path to the embedded file once where it will be extracted. |
85 | objectField.Data = extractPath; | 102 | field.Set(extractPath); |
86 | } | 103 | } |
87 | else if (null != objectField.Data) // non-compressed file (or localized value) | 104 | else if (null != objectField.Path) // non-compressed file (or localized value) |
88 | { | 105 | { |
89 | try | 106 | try |
90 | { | 107 | { |
91 | if (!this.BuildingPatch) // Normal binding for non-Patch scenario such as link (light.exe) | 108 | if (!this.BuildingPatch) // Normal binding for non-Patch scenario such as link (light.exe) |
92 | { | 109 | { |
110 | #if REVISIT_FOR_PATCHING | ||
93 | // keep a copy of the un-resolved data for future replay. This will be saved into wixpdb file | 111 | // keep a copy of the un-resolved data for future replay. This will be saved into wixpdb file |
94 | if (null == objectField.UnresolvedData) | 112 | if (null == objectField.UnresolvedData) |
95 | { | 113 | { |
96 | objectField.UnresolvedData = (string)objectField.Data; | 114 | objectField.UnresolvedData = (string)objectField.Data; |
97 | } | 115 | } |
116 | #endif | ||
98 | 117 | ||
99 | // resolve the path to the file | 118 | // resolve the path to the file |
100 | objectField.Data = fileResolver.ResolveFile((string)objectField.Data, table.Name, row.SourceLineNumbers, BindStage.Normal); | 119 | var value = fileResolver.ResolveFile(objectField.Path, row.Definition.Name, row.SourceLineNumbers, BindStage.Normal); |
120 | field.Set(value); | ||
101 | } | 121 | } |
102 | else if (!fileResolver.RebaseTarget && !fileResolver.RebaseUpdated) // Normal binding for Patch Scenario (normal patch, no re-basing logic) | 122 | else if (!fileResolver.RebaseTarget && !fileResolver.RebaseUpdated) // Normal binding for Patch Scenario (normal patch, no re-basing logic) |
103 | { | 123 | { |
104 | // resolve the path to the file | 124 | // resolve the path to the file |
105 | objectField.Data = fileResolver.ResolveFile((string)objectField.Data, table.Name, row.SourceLineNumbers, BindStage.Normal); | 125 | var value = fileResolver.ResolveFile(objectField.Path, row.Definition.Name, row.SourceLineNumbers, BindStage.Normal); |
126 | field.Set(value); | ||
106 | } | 127 | } |
128 | #if REVISIT_FOR_PATCHING | ||
107 | else // Re-base binding path scenario caused by pyro.exe -bt -bu | 129 | else // Re-base binding path scenario caused by pyro.exe -bt -bu |
108 | { | 130 | { |
109 | // by default, use the resolved Data for file lookup | 131 | // by default, use the resolved Data for file lookup |
@@ -122,16 +144,18 @@ namespace WixToolset.Core.Bind | |||
122 | } | 144 | } |
123 | } | 145 | } |
124 | 146 | ||
125 | objectField.Data = fileResolver.ResolveFile(filePathToResolve, table.Name, row.SourceLineNumbers, BindStage.Updated); | 147 | objectField.Data = fileResolver.ResolveFile(filePathToResolve, row.Definition.Name, row.SourceLineNumbers, BindStage.Updated); |
126 | } | 148 | } |
149 | #endif | ||
127 | } | 150 | } |
128 | catch (WixFileNotFoundException) | 151 | catch (WixFileNotFoundException) |
129 | { | 152 | { |
130 | // display the error with source line information | 153 | // display the error with source line information |
131 | Messaging.Instance.OnMessage(WixErrors.FileNotFound(row.SourceLineNumbers, (string)objectField.Data)); | 154 | Messaging.Instance.OnMessage(WixErrors.FileNotFound(row.SourceLineNumbers, objectField.Path)); |
132 | } | 155 | } |
133 | } | 156 | } |
134 | 157 | ||
158 | #if REVISIT_FOR_PATCHING | ||
135 | if (null != objectField.PreviousData) | 159 | if (null != objectField.PreviousData) |
136 | { | 160 | { |
137 | objectField.PreviousData = this.BindVariableResolver.ResolveVariables(row.SourceLineNumbers, objectField.PreviousData, false, out isDefault); | 161 | objectField.PreviousData = this.BindVariableResolver.ResolveVariables(row.SourceLineNumbers, objectField.PreviousData, false, out isDefault); |
@@ -159,7 +183,7 @@ namespace WixToolset.Core.Bind | |||
159 | if (!fileResolver.RebaseTarget && !fileResolver.RebaseUpdated) | 183 | if (!fileResolver.RebaseTarget && !fileResolver.RebaseUpdated) |
160 | { | 184 | { |
161 | // resolve the path to the file | 185 | // resolve the path to the file |
162 | objectField.PreviousData = fileResolver.ResolveFile((string)objectField.PreviousData, table.Name, row.SourceLineNumbers, BindStage.Normal); | 186 | objectField.PreviousData = fileResolver.ResolveFile((string)objectField.PreviousData, row.Definition.Name, row.SourceLineNumbers, BindStage.Normal); |
163 | } | 187 | } |
164 | else | 188 | else |
165 | { | 189 | { |
@@ -177,7 +201,7 @@ namespace WixToolset.Core.Bind | |||
177 | } | 201 | } |
178 | 202 | ||
179 | // resolve the path to the file | 203 | // resolve the path to the file |
180 | objectField.PreviousData = fileResolver.ResolveFile((string)objectField.PreviousData, table.Name, row.SourceLineNumbers, BindStage.Target); | 204 | objectField.PreviousData = fileResolver.ResolveFile((string)objectField.PreviousData, row.Definition.Name, row.SourceLineNumbers, BindStage.Target); |
181 | 205 | ||
182 | } | 206 | } |
183 | } | 207 | } |
@@ -189,6 +213,7 @@ namespace WixToolset.Core.Bind | |||
189 | } | 213 | } |
190 | } | 214 | } |
191 | } | 215 | } |
216 | #endif | ||
192 | } | 217 | } |
193 | } | 218 | } |
194 | } | 219 | } |