Wixsharp: Localization

Created on 25 Feb 2020  路  9Comments  路  Source: oleg-shilo/wixsharp

In the localization section of the wiki, there's a part where project.BuildLanguageTransform is invoked, but I get a compiler error saying that the method does not exists. Is the wiki not updated? Or am I using the wrong version (the latest one)?

Done / Released enhancement

All 9 comments

Can you please provide the error message exact text. The method does not exists error implies wrong assembly version but BuildLanguageTransform does not invoke any assembly and runs torch.exe instead. So I am puzzled...

BTW your post made me to check the project templates and I found that the latest VS Project template for Bootstrapper has csproj file corrupted. Though it's not related to your problem but... you may still want to update your templates.

Hello.
I am getting this error too. Attached archive with a test project.
TestLocalization.zip

Will work on it

I had a look at your project sample and... it's not expected to work.

You are trying to use API that is not exposed. The method BuildLanguageTransform is just not available.

If you replace
```C#
project.Language = "en-US";
string productMsi = project.BuildMsi();

project.Language = "ru-RU";
string mstFile = project.BuildLanguageTransform(productMsi, "ru-RU");

productMsi.EmbedTransform(mstFile);
productMsi.SetPackageLanguages("en-US,ru-RU".ToLcidList());

```C#
project.Language = "en-US,ru-RU";
project.BuildMultilanguageMsi();

It will fix the problem.

Though if you are building it on RU windows then it needs to be:
C# project.Language = "ru-RU,en-US"; project.BuildMultilanguageMsi();
The reasons for swoping the language are described here: https://github.com/oleg-shilo/wixsharp/wiki/Localization.

Also have a look at the MultiLanguageSupport sample.

===============

But to give you more control I have made the API you are trying to use into public so it will be available in the next release.

Hey @oleg-shilo, the BuildMultilanguageMsi method is very useful when no custom UI localization is needed, but not very helpful otherwise (such as FirewallException mentioned in issue #748).

The key problem is when for some specific languages, the project's LocalizationFile property needs to be provided. However, the BuildMultilanguageMsi method internally calls BuildLanguageTransform method without third parameter (the localizationFile).

For those who are in same situation, here is an code snippet that helps me out: https://gist.github.com/yurislav/cd1f85bb801723ce0c2c1fb0adaa08b7

Would it be possible to either pass localizationFile to BuildMultilanguageMsi method, or to pass some callback to be invoked, before localized msi is built?

Absolutely.
I just elevated the issue to enhancement. Will be available in the next release.

And... done.

If digital signature was used in project, after calling the method BuildMultilanguageMsi, MSI has unknown publisher in windows UAC dialog.

It would be better to add following block at the end of the BuildMultilanguageMsi method:

if (project.DigitalSignature != null)
{
    // sign the MSI after embedding transforms again (as it won't contain publisher info in UAC dialog)
    var signingReturnCode = project.DigitalSignature.Apply(msiFilePath);
    if (signingReturnCode != 0)
        throw new InvalidOperationException($"Signing the file '{msiFilePath}' failed. Return code: {signingReturnCode}");
}

Sorry, Missed your last post.

Done now. d956c95

Was this page helpful?
0 / 5 - 0 ratings