diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-04-02 14:41:49 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-04-02 14:58:00 -0700 |
| commit | 4449fcc5b8d104817c67135229682c66c3d892ca (patch) | |
| tree | 327f617de2e296ddb4e62c50bf07ec8b5dcf0a3e /src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs | |
| parent | 9cca339473d77c7036035f949239f5231c325968 (diff) | |
| download | wix-4449fcc5b8d104817c67135229682c66c3d892ca.tar.gz wix-4449fcc5b8d104817c67135229682c66c3d892ca.tar.bz2 wix-4449fcc5b8d104817c67135229682c66c3d892ca.zip | |
Enable codepages and languages to be set via .wxl files
Fixes wixtoolset/issues#5801
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs index babe0c1b..41da2a13 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs | |||
| @@ -14,15 +14,21 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 14 | /// </summary> | 14 | /// </summary> |
| 15 | internal class BindSummaryInfoCommand | 15 | internal class BindSummaryInfoCommand |
| 16 | { | 16 | { |
| 17 | public BindSummaryInfoCommand(IntermediateSection section, IBackendHelper backendHelper, IWixBranding branding) | 17 | public BindSummaryInfoCommand(IntermediateSection section, int? summaryInformationCodepage, string productLanguage, IBackendHelper backendHelper, IWixBranding branding) |
| 18 | { | 18 | { |
| 19 | this.Section = section; | 19 | this.Section = section; |
| 20 | this.SummaryInformationCodepage = summaryInformationCodepage; | ||
| 21 | this.ProductLanguage = productLanguage; | ||
| 20 | this.BackendHelper = backendHelper; | 22 | this.BackendHelper = backendHelper; |
| 21 | this.Branding = branding; | 23 | this.Branding = branding; |
| 22 | } | 24 | } |
| 23 | 25 | ||
| 24 | private IntermediateSection Section { get; } | 26 | private IntermediateSection Section { get; } |
| 25 | 27 | ||
| 28 | private int? SummaryInformationCodepage { get; } | ||
| 29 | |||
| 30 | private string ProductLanguage { get; } | ||
| 31 | |||
| 26 | private IBackendHelper BackendHelper { get; } | 32 | private IBackendHelper BackendHelper { get; } |
| 27 | 33 | ||
| 28 | private IWixBranding Branding { get; } | 34 | private IWixBranding Branding { get; } |
| @@ -53,6 +59,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 53 | this.InstallerVersion = 0; | 59 | this.InstallerVersion = 0; |
| 54 | this.ModularizationSuffix = null; | 60 | this.ModularizationSuffix = null; |
| 55 | 61 | ||
| 62 | SummaryInformationSymbol summaryInformationCodepageSymbol = null; | ||
| 63 | SummaryInformationSymbol platformAndLanguageSymbol = null; | ||
| 56 | var foundCreateDateTime = false; | 64 | var foundCreateDateTime = false; |
| 57 | var foundLastSaveDataTime = false; | 65 | var foundLastSaveDataTime = false; |
| 58 | var foundCreatingApplication = false; | 66 | var foundCreatingApplication = false; |
| @@ -64,20 +72,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 64 | switch (summaryInformationSymbol.PropertyId) | 72 | switch (summaryInformationSymbol.PropertyId) |
| 65 | { | 73 | { |
| 66 | case SummaryInformationType.Codepage: // PID_CODEPAGE | 74 | case SummaryInformationType.Codepage: // PID_CODEPAGE |
| 67 | // make sure the code page is an int and not a web name or null | 75 | summaryInformationCodepageSymbol = summaryInformationSymbol; |
| 68 | var codepage = summaryInformationSymbol.Value; | ||
| 69 | |||
| 70 | if (String.IsNullOrEmpty(codepage)) | ||
| 71 | { | ||
| 72 | codepage = "0"; | ||
| 73 | } | ||
| 74 | else | ||
| 75 | { | ||
| 76 | summaryInformationSymbol.Value = this.BackendHelper.GetValidCodePage(codepage, false, false, summaryInformationSymbol.SourceLineNumbers).ToString(CultureInfo.InvariantCulture); | ||
| 77 | } | ||
| 78 | break; | 76 | break; |
| 77 | |||
| 79 | case SummaryInformationType.PlatformAndLanguage: | 78 | case SummaryInformationType.PlatformAndLanguage: |
| 80 | this.Platform = GetPlatformFromSummaryInformation(summaryInformationSymbol.Value); | 79 | platformAndLanguageSymbol = summaryInformationSymbol; |
| 81 | break; | 80 | break; |
| 82 | 81 | ||
| 83 | case SummaryInformationType.PackageCode: // PID_REVNUMBER | 82 | case SummaryInformationType.PackageCode: // PID_REVNUMBER |
| @@ -117,7 +116,31 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 117 | } | 116 | } |
| 118 | } | 117 | } |
| 119 | 118 | ||
| 120 | // set the revision number (package/patch code) if it should be automatically generated | 119 | // Ensure the codepage is set properly. |
| 120 | if (summaryInformationCodepageSymbol == null) | ||
| 121 | { | ||
| 122 | summaryInformationCodepageSymbol = this.Section.AddSymbol(new SummaryInformationSymbol(null) | ||
| 123 | { | ||
| 124 | PropertyId = SummaryInformationType.Codepage | ||
| 125 | }); | ||
| 126 | } | ||
| 127 | |||
| 128 | var codepage = summaryInformationCodepageSymbol.Value; | ||
| 129 | |||
| 130 | if (String.IsNullOrEmpty(codepage)) | ||
| 131 | { | ||
| 132 | codepage = this.SummaryInformationCodepage?.ToString(CultureInfo.InvariantCulture) ?? "1252"; | ||
| 133 | } | ||
| 134 | |||
| 135 | summaryInformationCodepageSymbol.Value = this.BackendHelper.GetValidCodePage(codepage, onlyAnsi: true).ToString(CultureInfo.InvariantCulture); | ||
| 136 | |||
| 137 | // Ensure the language is set properly and figure out what platform we are targeting. | ||
| 138 | if (platformAndLanguageSymbol != null) | ||
| 139 | { | ||
| 140 | this.Platform = EnsureLanguageAndGetPlatformFromSummaryInformation(platformAndLanguageSymbol, this.ProductLanguage); | ||
| 141 | } | ||
| 142 | |||
| 143 | // Set the revision number (package/patch code) if it should be automatically generated. | ||
| 121 | if (!foundPackageCode) | 144 | if (!foundPackageCode) |
| 122 | { | 145 | { |
| 123 | this.Section.AddSymbol(new SummaryInformationSymbol(null) | 146 | this.Section.AddSymbol(new SummaryInformationSymbol(null) |
| @@ -158,11 +181,19 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 158 | } | 181 | } |
| 159 | } | 182 | } |
| 160 | 183 | ||
| 161 | private static Platform GetPlatformFromSummaryInformation(string value) | 184 | private static Platform EnsureLanguageAndGetPlatformFromSummaryInformation(SummaryInformationSymbol symbol, string language) |
| 162 | { | 185 | { |
| 186 | var value = symbol.Value; | ||
| 163 | var separatorIndex = value.IndexOf(';'); | 187 | var separatorIndex = value.IndexOf(';'); |
| 164 | var platformValue = separatorIndex > 0 ? value.Substring(0, separatorIndex) : value; | 188 | var platformValue = separatorIndex > 0 ? value.Substring(0, separatorIndex) : value; |
| 165 | 189 | ||
| 190 | // If the language was provided and there was language value after the separator | ||
| 191 | // (or the separator was absent) then use the provided language. | ||
| 192 | if (!String.IsNullOrEmpty(language) && (separatorIndex < 0 || separatorIndex + 1 == value.Length)) | ||
| 193 | { | ||
| 194 | symbol.Value = platformValue + ';' + language; | ||
| 195 | } | ||
| 196 | |||
| 166 | switch (platformValue) | 197 | switch (platformValue) |
| 167 | { | 198 | { |
| 168 | case "x64": | 199 | case "x64": |
