diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-02-28 21:05:49 -0600 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-03-02 15:50:47 -0600 |
| commit | 8b3488c8c77959f425d0e5f70d27c5b2b1c86125 (patch) | |
| tree | 827dfa7caba09d7fa032c317505a590bb834c4e6 /src/WixToolset.Core/Compile | |
| parent | a6013a643208a8d1fc2d1136ef8d3a6c3e909522 (diff) | |
| download | wix-8b3488c8c77959f425d0e5f70d27c5b2b1c86125.tar.gz wix-8b3488c8c77959f425d0e5f70d27c5b2b1c86125.tar.bz2 wix-8b3488c8c77959f425d0e5f70d27c5b2b1c86125.zip | |
Use new PackagePayload symbols for the package's payload.
#4183
Diffstat (limited to 'src/WixToolset.Core/Compile')
| -rw-r--r-- | src/WixToolset.Core/Compile/CompilerPayload.cs | 93 |
1 files changed, 68 insertions, 25 deletions
diff --git a/src/WixToolset.Core/Compile/CompilerPayload.cs b/src/WixToolset.Core/Compile/CompilerPayload.cs index 4eda56f8..7a5fd1b2 100644 --- a/src/WixToolset.Core/Compile/CompilerPayload.cs +++ b/src/WixToolset.Core/Compile/CompilerPayload.cs | |||
| @@ -23,6 +23,8 @@ namespace WixToolset.Core | |||
| 23 | 23 | ||
| 24 | public Identifier Id { get; set; } | 24 | public Identifier Id { get; set; } |
| 25 | 25 | ||
| 26 | public bool IsRemoteAllowed { get; set; } | ||
| 27 | |||
| 26 | public bool IsRequired { get; set; } = true; | 28 | public bool IsRequired { get; set; } = true; |
| 27 | 29 | ||
| 28 | public string Name { get; set; } | 30 | public string Name { get; set; } |
| @@ -48,26 +50,17 @@ namespace WixToolset.Core | |||
| 48 | 50 | ||
| 49 | private SourceLineNumber SourceLineNumbers { get; } | 51 | private SourceLineNumber SourceLineNumbers { get; } |
| 50 | 52 | ||
| 51 | private void CalculateAndVerifyFields(CompilerPayload remotePayload = null) | 53 | private void CalculateAndVerifyFields() |
| 52 | { | 54 | { |
| 55 | var isRemote = this.IsRemoteAllowed && !String.IsNullOrEmpty(this.Hash); | ||
| 56 | |||
| 53 | if (String.IsNullOrEmpty(this.SourceFile)) | 57 | if (String.IsNullOrEmpty(this.SourceFile)) |
| 54 | { | 58 | { |
| 55 | if (String.IsNullOrEmpty(this.Name)) | 59 | if (!String.IsNullOrEmpty(this.Name) && !isRemote) |
| 56 | { | ||
| 57 | if (this.IsRequired) | ||
| 58 | { | ||
| 59 | this.Core.Write(ErrorMessages.ExpectedAttributesWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Name", "SourceFile")); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | else if (remotePayload == null) | ||
| 63 | { | 60 | { |
| 64 | this.SourceFile = Path.Combine("SourceDir", this.Name); | 61 | this.SourceFile = Path.Combine("SourceDir", this.Name); |
| 65 | } | 62 | } |
| 66 | } | 63 | } |
| 67 | else if (remotePayload != null) | ||
| 68 | { | ||
| 69 | this.Core.Write(ErrorMessages.UnexpectedElementWithAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "RemotePayload", "SourceFile")); | ||
| 70 | } | ||
| 71 | else if (this.SourceFile.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) | 64 | else if (this.SourceFile.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) |
| 72 | { | 65 | { |
| 73 | if (String.IsNullOrEmpty(this.Name)) | 66 | if (String.IsNullOrEmpty(this.Name)) |
| @@ -80,24 +73,67 @@ namespace WixToolset.Core | |||
| 80 | } | 73 | } |
| 81 | } | 74 | } |
| 82 | 75 | ||
| 83 | if (remotePayload != null) | 76 | if (String.IsNullOrEmpty(this.SourceFile) && !isRemote) |
| 84 | { | 77 | { |
| 85 | if (this.DownloadUrl == null) | 78 | if (this.IsRequired) |
| 86 | { | 79 | { |
| 87 | this.Core.Write(ErrorMessages.ExpectedAttributeWithElement(this.SourceLineNumbers, this.Element.Name.LocalName, "DownloadUrl", "RemotePayload")); | 80 | if (!this.IsRemoteAllowed) |
| 81 | { | ||
| 82 | this.Core.Write(ErrorMessages.ExpectedAttributes(this.SourceLineNumbers, this.Element.Name.LocalName, "Name", "SourceFile")); | ||
| 83 | } | ||
| 84 | else | ||
| 85 | { | ||
| 86 | this.Core.Write(ErrorMessages.ExpectedAttributes(this.SourceLineNumbers, this.Element.Name.LocalName, "SourceFile", "Hash")); | ||
| 87 | } | ||
| 88 | } | 88 | } |
| 89 | } | ||
| 90 | else if (this.IsRemoteAllowed) | ||
| 91 | { | ||
| 92 | var isLocal = !String.IsNullOrEmpty(this.SourceFile); | ||
| 89 | 93 | ||
| 90 | if (YesNoDefaultType.No != this.Compressed) | 94 | if (isLocal) |
| 95 | { | ||
| 96 | if (isRemote) | ||
| 97 | { | ||
| 98 | this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Hash", "SourceFile")); | ||
| 99 | } | ||
| 100 | } | ||
| 101 | else | ||
| 91 | { | 102 | { |
| 103 | if (String.IsNullOrEmpty(this.DownloadUrl)) | ||
| 104 | { | ||
| 105 | this.Core.Write(ErrorMessages.ExpectedAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "DownloadUrl", "Hash")); | ||
| 106 | } | ||
| 107 | |||
| 108 | if (String.IsNullOrEmpty(this.Name)) | ||
| 109 | { | ||
| 110 | this.Core.Write(ErrorMessages.ExpectedAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Name", "Hash")); | ||
| 111 | } | ||
| 112 | |||
| 113 | if (YesNoDefaultType.Yes == this.Compressed) | ||
| 114 | { | ||
| 115 | this.Core.Write(WarningMessages.RemotePayloadsMustNotAlsoBeCompressed(this.SourceLineNumbers, this.Element.Name.LocalName)); | ||
| 116 | } | ||
| 117 | |||
| 92 | this.Compressed = YesNoDefaultType.No; | 118 | this.Compressed = YesNoDefaultType.No; |
| 93 | this.Core.Write(WarningMessages.RemotePayloadsMustNotAlsoBeCompressed(this.SourceLineNumbers, this.Element.Name.LocalName)); | ||
| 94 | } | 119 | } |
| 95 | 120 | ||
| 96 | this.Description = remotePayload.Description; | 121 | VerifyValidValue("Description", !String.IsNullOrEmpty(this.Description)); |
| 97 | this.DisplayName = remotePayload.DisplayName; | 122 | VerifyValidValue("ProductName", !String.IsNullOrEmpty(this.ProductName)); |
| 98 | this.Hash = remotePayload.Hash; | 123 | VerifyValidValue("Size", this.Size.HasValue); |
| 99 | this.Size = remotePayload.Size; | 124 | VerifyValidValue("Version", !String.IsNullOrEmpty(this.Version)); |
| 100 | this.Version = remotePayload.Version; | 125 | |
| 126 | void VerifyValidValue(string attributeName, bool isSpecified) | ||
| 127 | { | ||
| 128 | if (isLocal && isSpecified) | ||
| 129 | { | ||
| 130 | this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, attributeName, "SourceFile")); | ||
| 131 | } | ||
| 132 | else if (!isLocal && !isSpecified) | ||
| 133 | { | ||
| 134 | this.Core.Write(ErrorMessages.ExpectedAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, attributeName, "Hash")); | ||
| 135 | } | ||
| 136 | } | ||
| 101 | } | 137 | } |
| 102 | } | 138 | } |
| 103 | 139 | ||
| @@ -143,9 +179,9 @@ namespace WixToolset.Core | |||
| 143 | return symbol; | 179 | return symbol; |
| 144 | } | 180 | } |
| 145 | 181 | ||
| 146 | public void FinishCompilingPackage(CompilerPayload remotePayload) | 182 | public void FinishCompilingPackage() |
| 147 | { | 183 | { |
| 148 | this.CalculateAndVerifyFields(remotePayload); | 184 | this.CalculateAndVerifyFields(); |
| 149 | this.GenerateIdFromFilename(); | 185 | this.GenerateIdFromFilename(); |
| 150 | 186 | ||
| 151 | if (this.Id == null) | 187 | if (this.Id == null) |
| @@ -155,6 +191,13 @@ namespace WixToolset.Core | |||
| 155 | } | 191 | } |
| 156 | } | 192 | } |
| 157 | 193 | ||
| 194 | public void FinishCompilingPackagePayload() | ||
| 195 | { | ||
| 196 | this.CalculateAndVerifyFields(); | ||
| 197 | this.GenerateIdFromFilename(); | ||
| 198 | this.GenerateIdFromPrefix("ppy"); | ||
| 199 | } | ||
| 200 | |||
| 158 | public void FinishCompilingPayload() | 201 | public void FinishCompilingPayload() |
| 159 | { | 202 | { |
| 160 | this.CalculateAndVerifyFields(); | 203 | this.CalculateAndVerifyFields(); |
