sbt-native-packager icon indicating copy to clipboard operation
sbt-native-packager copied to clipboard

WindowsPlugin: support changing codepage

Open nigredo-tori opened this issue 7 years ago • 7 comments

I'm trying to build a Windows installer for my application using WindowsPlugin and JavaPackaging. However, cyrillic letters in some fields lead to WiX error messages like this one:

[info] C:\dev\tmp\snp-test\target\windows\snp-test.wix(3) : error LGHT0311 : A string was provided with characters that are not available in the specified database code page '1252'. Either change these characters to ones that exist in the database's code page, or update the database's code page by modifying one of the following attributes: Product/@Codepage, Module/@Codepage, Patch/@Codepage, PatchCreation/@Codepage, or WixLocalization/@Codepage.

As far as I understand, MSI packages have to specify the encoding for the text they use in case it uses a charset other then the default one (Windows-1252). WiX seems to support this, but the corresponding knob is not available in this project. Relevant WiX manual page: http://wixtoolset.org/documentation/manual/v3/overview/codepage.html .

Expected behaviour

SNP supports changing codepage in generated WiX scripts, allowing fields to contain corresponding characters.

Actual behaviour

SNP does not support changing codepage in generated WiX scripts, cyrillic letters lead to failing build.

Information

To reproduce the issue, run Windows/packageBin in the following project (SBT 1.2.1, SNP 1.3.14):

version in ThisBuild := "1.2.3"

enablePlugins(
  JavaAppPackaging,
  WindowsPlugin
)

Compile / mainClass := Some("Main")

maintainer := "Проверка1"
packageSummary := "Проверка2"
packageDescription := "Проверка3"

UPD:

Looking past this, it seems that the autogenerated WiX script is lacking in a few other aspects. I'll probably just roll my own wixFile, so this issue is not really urgent.

nigredo-tori avatar Nov 26 '18 09:11 nigredo-tori

Thanks for the detailed and well written feature request @nigredo-tori :smiley:

Windows support was always very community driven as this is rather a rare use case. What you can try is the JdkPackagerPlugin: https://sbt-native-packager.readthedocs.io/en/stable/formats/jdkpackager.html This may solve your issues as it relies on the JDK8 packager tool.

We are happy to merge pull requests fixing or enhancing the windows support :heart:

muuki88 avatar Nov 26 '18 13:11 muuki88

@muuki88 , thank you for your reply. I've considered using JdkPackagerPlugin, but it looks far too rigid for my use case - so I would have to write a custom WiX script anyway. Also, since javapackager is no longer in JDK (since Java 11), making it (and Ant) a part of my build is probably not the best long-term solution. There's also jlink (which, as I understand, is the Archetype-shaped half of javapackager), but I am stuck with Java 8 at the moment, and jlink is not supported by SNP anyway.

nigredo-tori avatar Nov 26 '18 14:11 nigredo-tori

I've poked around some more, and it seems that at least in my case setting -cultures:ru-ru in lightOptions would have been a better solution. Specifying -cultures is much easier and much more robust than setting Codepage in the .wsx - and, since the plugin uses -cultures:en-us by default, I'd still have to change lightOptions.

nigredo-tori avatar Nov 27 '18 05:11 nigredo-tori

Also, since javapackager is no longer in JDK (since Java 11), making it (and Ant) a part of my build is probably not the best long-term solution

That is totally correct! I missed that. Oh man. This means we can deprecate that feature

muuki88 avatar Nov 27 '18 09:11 muuki88

Can you shed some light on the lightOptions thing :smile: Is it an sbt or wix setting?

muuki88 avatar Nov 27 '18 09:11 muuki88

Can you shed some light on the lightOptions thing :smile: Is it an sbt or wix setting?

I see what you did there :smile:. lightOptions is a WindowsPlugin setting that allows passing arbitrary options to the light utility in WiX (the linker).

Passing -cultures:ru-ru using lightOptions allowed my WiX build to complete without errors, but I later found out that some of the strings were not displayed correctly in the file properties dialog for the generated MSI. Ultimately, for a non-English MSI one has to specify -cultures as well as Product/@Codepage and Package/@SummaryCodepage. So maybe I was too hasty to close this.

nigredo-tori avatar Nov 27 '18 11:11 nigredo-tori

Then let's reopen :smiley:

If you have time and passion to do this, feel free to ask about anything :)

muuki88 avatar Nov 27 '18 12:11 muuki88