diff options
Diffstat (limited to 'src/wix/WixToolset.Core/Compile/CompilerPayload.cs')
-rw-r--r-- | src/wix/WixToolset.Core/Compile/CompilerPayload.cs | 89 |
1 files changed, 67 insertions, 22 deletions
diff --git a/src/wix/WixToolset.Core/Compile/CompilerPayload.cs b/src/wix/WixToolset.Core/Compile/CompilerPayload.cs index ea63ee8c..cee9b377 100644 --- a/src/wix/WixToolset.Core/Compile/CompilerPayload.cs +++ b/src/wix/WixToolset.Core/Compile/CompilerPayload.cs | |||
@@ -11,12 +11,31 @@ namespace WixToolset.Core | |||
11 | 11 | ||
12 | internal class CompilerPayload | 12 | internal class CompilerPayload |
13 | { | 13 | { |
14 | public string Version { get; set; } | ||
15 | |||
16 | public CompilerPayload(CompilerCore core, SourceLineNumber sourceLineNumbers, XElement element) | ||
17 | { | ||
18 | this.Core = core; | ||
19 | this.Element = element; | ||
20 | this.SourceLineNumbers = sourceLineNumbers; | ||
21 | } | ||
22 | |||
23 | private CompilerCore Core { get; } | ||
24 | |||
25 | private XElement Element { get; } | ||
26 | |||
27 | private SourceLineNumber SourceLineNumbers { get; } | ||
28 | |||
14 | public YesNoDefaultType Compressed { get; set; } = YesNoDefaultType.Default; | 29 | public YesNoDefaultType Compressed { get; set; } = YesNoDefaultType.Default; |
15 | 30 | ||
16 | public string Description { get; set; } | 31 | public string Description { get; set; } |
17 | 32 | ||
18 | public string DownloadUrl { get; set; } | 33 | public string DownloadUrl { get; set; } |
19 | 34 | ||
35 | public string CertificatePublicKey { get; set; } | ||
36 | |||
37 | public string CertificateThumbprint { get; set; } | ||
38 | |||
20 | public string Hash { get; set; } | 39 | public string Hash { get; set; } |
21 | 40 | ||
22 | public Identifier Id { get; set; } | 41 | public Identifier Id { get; set; } |
@@ -33,24 +52,9 @@ namespace WixToolset.Core | |||
33 | 52 | ||
34 | public string SourceFile { get; set; } | 53 | public string SourceFile { get; set; } |
35 | 54 | ||
36 | public string Version { get; set; } | ||
37 | |||
38 | public CompilerPayload(CompilerCore core, SourceLineNumber sourceLineNumbers, XElement element) | ||
39 | { | ||
40 | this.Core = core; | ||
41 | this.Element = element; | ||
42 | this.SourceLineNumbers = sourceLineNumbers; | ||
43 | } | ||
44 | |||
45 | private CompilerCore Core { get; } | ||
46 | |||
47 | private XElement Element { get; } | ||
48 | |||
49 | private SourceLineNumber SourceLineNumbers { get; } | ||
50 | |||
51 | private void CalculateAndVerifyFields() | 55 | private void CalculateAndVerifyFields() |
52 | { | 56 | { |
53 | var isRemote = this.IsRemoteAllowed && !String.IsNullOrEmpty(this.Hash); | 57 | var isRemote = this.IsRemoteAllowed && (!String.IsNullOrEmpty(this.CertificatePublicKey) || !String.IsNullOrEmpty(this.CertificateThumbprint) || !String.IsNullOrEmpty(this.Hash)); |
54 | 58 | ||
55 | if (String.IsNullOrEmpty(this.SourceFile)) | 59 | if (String.IsNullOrEmpty(this.SourceFile)) |
56 | { | 60 | { |
@@ -81,7 +85,7 @@ namespace WixToolset.Core | |||
81 | } | 85 | } |
82 | else | 86 | else |
83 | { | 87 | { |
84 | this.Core.Write(ErrorMessages.ExpectedAttributes(this.SourceLineNumbers, this.Element.Name.LocalName, "SourceFile", "Hash")); | 88 | this.Core.Write(ErrorMessages.ExpectedAttributes(this.SourceLineNumbers, this.Element.Name.LocalName, "SourceFile", "CertificatePublicKey", "Hash")); |
85 | } | 89 | } |
86 | } | 90 | } |
87 | } | 91 | } |
@@ -93,7 +97,20 @@ namespace WixToolset.Core | |||
93 | { | 97 | { |
94 | if (isRemote) | 98 | if (isRemote) |
95 | { | 99 | { |
96 | this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Hash", "SourceFile")); | 100 | if (!String.IsNullOrEmpty(this.Hash)) |
101 | { | ||
102 | this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Hash", "SourceFile")); | ||
103 | } | ||
104 | |||
105 | if (!String.IsNullOrEmpty(this.CertificatePublicKey)) | ||
106 | { | ||
107 | this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "CertificatePublicKey", "SourceFile")); | ||
108 | } | ||
109 | |||
110 | if (!String.IsNullOrEmpty(this.CertificateThumbprint)) | ||
111 | { | ||
112 | this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "CertificateThumbprint", "SourceFile")); | ||
113 | } | ||
97 | } | 114 | } |
98 | 115 | ||
99 | if (!String.IsNullOrEmpty(this.Description)) | 116 | if (!String.IsNullOrEmpty(this.Description)) |
@@ -120,17 +137,34 @@ namespace WixToolset.Core | |||
120 | { | 137 | { |
121 | if (String.IsNullOrEmpty(this.DownloadUrl)) | 138 | if (String.IsNullOrEmpty(this.DownloadUrl)) |
122 | { | 139 | { |
123 | this.Core.Write(ErrorMessages.ExpectedAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "DownloadUrl", "Hash")); | 140 | this.Core.Write(ErrorMessages.ExpectedAttributeWithoutOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "DownloadUrl", "SourceFile")); |
124 | } | 141 | } |
125 | 142 | ||
126 | if (String.IsNullOrEmpty(this.Name)) | 143 | if (String.IsNullOrEmpty(this.Name)) |
127 | { | 144 | { |
128 | this.Core.Write(ErrorMessages.ExpectedAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Name", "Hash")); | 145 | this.Core.Write(ErrorMessages.ExpectedAttributeWithoutOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Name", "SourceFile")); |
129 | } | 146 | } |
130 | 147 | ||
131 | if (!this.Size.HasValue) | 148 | if (!this.Size.HasValue) |
132 | { | 149 | { |
133 | this.Core.Write(ErrorMessages.ExpectedAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Size", "Hash")); | 150 | this.Core.Write(ErrorMessages.ExpectedAttributeWithoutOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Size", "SourceFile")); |
151 | } | ||
152 | |||
153 | if (String.IsNullOrEmpty(this.Hash)) | ||
154 | { | ||
155 | this.Core.Write(ErrorMessages.ExpectedAttributeWithoutOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Hash", "SourceFile")); | ||
156 | } | ||
157 | |||
158 | if (!String.IsNullOrEmpty(this.CertificatePublicKey) || !String.IsNullOrEmpty(this.CertificateThumbprint)) | ||
159 | { | ||
160 | if (String.IsNullOrEmpty(this.CertificateThumbprint)) | ||
161 | { | ||
162 | this.Core.Write(ErrorMessages.ExpectedAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "CertificateThumbprint", "CertificatePublicKey")); | ||
163 | } | ||
164 | else if (String.IsNullOrEmpty(this.CertificatePublicKey)) | ||
165 | { | ||
166 | this.Core.Write(ErrorMessages.ExpectedAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "CertificatePublicKey", "CertificateThumbprint")); | ||
167 | } | ||
134 | } | 168 | } |
135 | 169 | ||
136 | if (YesNoDefaultType.Yes == this.Compressed) | 170 | if (YesNoDefaultType.Yes == this.Compressed) |
@@ -177,6 +211,8 @@ namespace WixToolset.Core | |||
177 | Hash = this.Hash, | 211 | Hash = this.Hash, |
178 | FileSize = this.Size, | 212 | FileSize = this.Size, |
179 | Version = this.Version, | 213 | Version = this.Version, |
214 | CertificatePublicKey = this.CertificatePublicKey, | ||
215 | CertificateThumbprint = this.CertificateThumbprint | ||
180 | }); | 216 | }); |
181 | 217 | ||
182 | this.Core.CreateGroupAndOrderingRows(this.SourceLineNumbers, parentType, parentId, ComplexReferenceChildType.Payload, symbol.Id.Id, ComplexReferenceChildType.Unknown, null); | 218 | this.Core.CreateGroupAndOrderingRows(this.SourceLineNumbers, parentType, parentId, ComplexReferenceChildType.Payload, symbol.Id.Id, ComplexReferenceChildType.Unknown, null); |
@@ -248,6 +284,16 @@ namespace WixToolset.Core | |||
248 | this.DownloadUrl = this.Core.GetAttributeValue(this.SourceLineNumbers, attrib); | 284 | this.DownloadUrl = this.Core.GetAttributeValue(this.SourceLineNumbers, attrib); |
249 | } | 285 | } |
250 | 286 | ||
287 | public void ParseCertificatePublicKey(XAttribute attrib) | ||
288 | { | ||
289 | this.CertificatePublicKey = this.Core.GetAttributeValue(this.SourceLineNumbers, attrib); | ||
290 | } | ||
291 | |||
292 | public void ParseCertificateThumbprint(XAttribute attrib) | ||
293 | { | ||
294 | this.CertificateThumbprint = this.Core.GetAttributeValue(this.SourceLineNumbers, attrib); | ||
295 | } | ||
296 | |||
251 | public void ParseHash(XAttribute attrib) | 297 | public void ParseHash(XAttribute attrib) |
252 | { | 298 | { |
253 | this.Hash = this.Core.GetAttributeValue(this.SourceLineNumbers, attrib); | 299 | this.Hash = this.Core.GetAttributeValue(this.SourceLineNumbers, attrib); |
@@ -286,6 +332,5 @@ namespace WixToolset.Core | |||
286 | { | 332 | { |
287 | this.Version = this.Core.GetAttributeValue(this.SourceLineNumbers, attrib); | 333 | this.Version = this.Core.GetAttributeValue(this.SourceLineNumbers, attrib); |
288 | } | 334 | } |
289 | |||
290 | } | 335 | } |
291 | } | 336 | } |