Skip to content

Commit

Permalink
Merge pull request #3947 from bclothier/SetUpTheBomb
Browse files Browse the repository at this point in the history
Fixes encoding issues with localized installer messages.
  • Loading branch information
retailcoder committed Apr 20, 2018
2 parents a7475d7 + 4568b9d commit 14743dc
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 33 deletions.
33 changes: 17 additions & 16 deletions Rubberduck.Deployment/BuildRegistryScript.ps1
Expand Up @@ -28,18 +28,18 @@ param (

function Get-ScriptDirectory
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
$Invocation = (Get-Variable MyInvocation -Scope 1).Value;
Split-Path $Invocation.MyCommand.Path;
}

Set-StrictMode -Version latest
Set-StrictMode -Version latest;
$ErrorActionPreference = "Stop";

try
{
# Allow multiple DLL files to be registered if necessary
$separator = "|"
$option = [System.StringSplitOptions]::RemoveEmptyEntries
$separator = "|";
$option = [System.StringSplitOptions]::RemoveEmptyEntries;
$files = $filesToExtract.Split($separator, $option);

foreach($file in $files)
Expand All @@ -50,8 +50,8 @@ try
$targetTlb32 = $targetDir + ($file -replace ".dll", ".x32.tlb");
$sourceTlb64 = $sourceDir + ($file -replace ".dll", ".x64.tlb");
$targetTlb64 = $targetDir + ($file -replace ".dll", ".x64.tlb");
$dllXml = $targetDll + ".xml"
$tlbXml = $targetTlb32 + ".xml"
$dllXml = $targetDll + ".xml";
$tlbXml = $targetTlb32 + ".xml";

# Use for debugging issues with passing parameters to the external programs
# Note that it is not legal to have syntax like `& $cmdIncludingArguments` or `& $cmd $args`
Expand All @@ -67,19 +67,20 @@ try
& $cmd file ""$sourceTlb32"" -out ""$tlbXml"";

[System.Reflection.Assembly]::LoadFrom($builderAssemblyPath);
$builder = New-Object Rubberduck.Deployment.Builders.RegistryEntryBuilder
$builder = New-Object Rubberduck.Deployment.Builders.RegistryEntryBuilder;

$entries = $builder.Parse($tlbXml, $dllXml);

# For debugging
# $entries | Format-Table | Out-String |% {Write-Host $_};

$writer = New-Object Rubberduck.Deployment.Writers.InnoSetupRegistryWriter
$writer = New-Object Rubberduck.Deployment.Writers.InnoSetupRegistryWriter;
$content = $writer.Write($entries);

$regFile = ($includeDir + ($file -replace ".dll", ".reg.iss"))
$encoding = New-Object System.Text.UTF8Encoding $False
[System.IO.File]::WriteAllLines($regFile, $content, $encoding)

# The file must be encoded in UTF-8 BOM
$regFile = ($includeDir + ($file -replace ".dll", ".reg.iss"));
$encoding = New-Object System.Text.UTF8Encoding $true;
[System.IO.File]::WriteAllLines($regFile, $content, $encoding);

# Register the debug build on the local machine
if($config -eq "Debug")
Expand All @@ -105,18 +106,18 @@ try
& reg.exe import $regFile;
}
& reg.exe import ($dir + "\RubberduckAddinRegistry.reg");
Move-Item -Path $regFile -Destination ($regFile + ".imported_" + $datetime.ToUniversalTime().ToString("yyyyMMddHHmmss") + ".txt" )
Move-Item -Path $regFile -Destination ($regFile + ".imported_" + $datetime.ToUniversalTime().ToString("yyyyMMddHHmmss") + ".txt" );
}
}
else
{
New-Item $dir -ItemType Directory
New-Item $dir -ItemType Directory;
}

# NOTE: The local writer will perform the actual registry changes; the return
# is a registry script with deletion instructions for the keys to be deleted
# in the next build.
$writer = New-Object Rubberduck.Deployment.Writers.LocalDebugRegistryWriter
$writer = New-Object Rubberduck.Deployment.Writers.LocalDebugRegistryWriter;
$content = $writer.Write($entries);

$encoding = New-Object System.Text.ASCIIEncoding;
Expand Down
@@ -1,4 +1,4 @@
; English Custom Messages Include
; English Custom Messages Include -- Must be encoded in UTF-8 BOM
English.PerUser=Current User
English.Everyone=All Users
English.RegisterAddin=Repair VBE Addin registration
Expand Down
@@ -1,4 +1,4 @@
; French Custom Messages Include
; French Custom Messages Include -- Must be encoded in UTF-8 BOM
French.PerUser=Utilisateur courant
French.Everyone=Tous les utilisateurs
French.RegisterAddin=Réparer l'enregistrement du complément VBE
Expand All @@ -19,7 +19,7 @@ French.RegisterAddInButtonCaption=Enregistrer Rubberduck
French.WillExecuteAdminInstall=Le complément VBE Rubberduck sera disponible pour tous les utilisateurs.%n%nNOTE: chaque utilisateur devra enregistrer le complément individuellement, puisque : %nUne installation par utilisateur ne peut être déployée à tous les utilisateurs.%n%nAprès l'installation, un raccourci "Réparer l'enregistrement du complément VBE" sera disponible pour tous les utilisateurs dans le dossier %nRubberduck's du menu démarrer/programmes.
French.WillLaunchAdminInstall=L'installateur va demander l'accès administrateur pour procéder à l'installation pour tous les utilisateurs.%nEnsuite le complément sera enregistré, mais seulement pour l'utilisateur courant.
French.WillInstallForCurrentUser=Le complément Rubberduck sera disponible seulement pour l'utilisateur courant et ne requièrera pas de privilèges administrateur.
French.UninstallOldVersionPrompt=Il semble y avoir une version antérieure de Rubberduck installée sur ce système pour %s.There seems to be a previous version of Rubberduck, qui devra d'abord être désinstallée. Procéder à la désinstallation?
French.UninstallOldVersionPrompt=Il semble y avoir une version antérieure de Rubberduck installée sur ce système pour %s, qui devra d'abord être désinstallée. Procéder à la désinstallation?
French.UninstallOldVersionFail=Impossible de désinstaller la version antérieure. Essayez de désinstaller via Ajout/Suppression de Programmes dans le panneau de contrôle, puis recommencer l'installation.
French.WarnInstallPerUserOverEveryone=Il semble y avoir une version de Rubberduck installée pour tous les utilisateurs. Procéder à une installation utilisateur simple modifiera l'enregistrement, sans affecter les autres utilisateurs. Procéder?
French.ElevationRequestFailMessage=Impossible de désinstaller la version précédente de Rubberduck. Vous devrez d'abord désinstaller l'ancienne version avant de procéder à la mise à jour.
@@ -1,4 +1,4 @@
; German Custom Messages Include
; German Custom Messages Include -- Must be encoded in UTF-8 BOM
German.PerUser=Aktueller Benutzer
German.Everyone=Alle Benutzer
German.RegisterAddin=VBE AddIn Registrierung reparieren
Expand Down
28 changes: 15 additions & 13 deletions Rubberduck.Deployment/InnoSetup/Installer Build Script.iss
@@ -1,3 +1,5 @@
;The file must be encoded in UTF-8 BOM

#pragma include __INCLUDE__ + ";" + SourcePath + "\Includes\"

#define protected
Expand Down Expand Up @@ -111,7 +113,7 @@ Source: "{#IncludesDir}Rubberduck.RegisterAddIn.reg"; DestDir: "{app}"; Flags: i

[CustomMessages]
; TODO add additional languages here by adding include files in \Includes folder
; and uncomment or add lines to include the file.
; and uncomment or add lines to include the file.
#include <English.CustomMessages.iss>
#include <French.CustomMessages.iss>
#include <German.CustomMessages.iss>
Expand Down Expand Up @@ -169,7 +171,7 @@ var
///<remarks>
///Custom page to select whether the installer should run for the
///current user only or for all users (requiring elevation).
///Configured in the WizardInitialize event function.
///Configured in the WizardInitialize event function.
///</remarks>
InstallForWhoOptionPage: TInputOptionWizardPage;
Expand All @@ -183,7 +185,7 @@ var
///<remarks>
///Set by the <see cref="RegisterAddInOptionPage" />; should be
///read-only normally. When set to true, it is used to check if
///elevation is needed for the installer.
///elevation is needed for the installer.
///</remarks>
ShouldInstallAllUsers: Boolean;
Expand Down Expand Up @@ -220,7 +222,7 @@ var
///<remarks>
///Win32 API function used to launch a 2nd instance of the installer
///under elevated context, used by <see cref="Elevate" />.
///under elevated context, used by <see cref="Elevate" />.
///</remarks>
function ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string;
lpParameters: string; lpDirectory: string; nShowCmd: Integer): HINSTANCE;
Expand All @@ -232,7 +234,7 @@ function ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string;
///Encapuslate the check whether the installer is running in an
///elevated context or not. This does not indicate whether the
///installer was launched by a non-elevated installer, however.
///<see cref="HasElevateSwitch" />
///<see cref="HasElevateSwitch" />
///</remarks>
function IsElevated: Boolean;
begin
Expand All @@ -259,7 +261,7 @@ end;
///<remarks>
///Used to determine whether a install directory that user
///selected is in fact writable by the user, especially
///for non-elevated installation.
///for non-elevated installation.
///</remarks>
function HaveWriteAccessToApp: Boolean;
var
Expand Down Expand Up @@ -480,7 +482,7 @@ end;
///to do so. This guards against the case of both the non-elevated
///installer and the elevated installer installing same files into
///same place, which will cause problems. This function ensures only
///one or other mode will actually install the files.
///one or other mode will actually install the files.
///</remarks>
function CheckShouldInstallFiles():boolean;
begin
Expand Down Expand Up @@ -730,7 +732,7 @@ begin
begin
Log('Uninstall of previous version (%s) was declined by the user.');
result := false;
end;
end;
end;
// Event functions called by Inno Setup
Expand All @@ -742,7 +744,7 @@ end;
///<remarks>
///This is the first event of the installer, fires prior to the wizard
///being initialized. This is primarily used to validate that the
///pre-requisites are met, in this case, pre-existence of .NET framework.
///pre-requisites are met, in this case, pre-existence of .NET framework.
///</remarks>
function InitializeSetup(): Boolean;
var
Expand Down Expand Up @@ -770,7 +772,7 @@ end;
///set up the <see cref="InstallForWhoOptionPage" /> and
///<see cref="RegisterAddInOptionPage" /> pages. In both cases, their
///behavior differs depending on whether we are elevated, and need to be
///configured accordingly.
///configured accordingly.
///</remarks>
procedure InitializeWizard();
begin
Expand Down Expand Up @@ -859,7 +861,7 @@ begin
begin
Log('Skipping Finished page because we are running with /ELEVATE switch');
Result := true;
end;
end;
end;
///<remarks>
Expand Down Expand Up @@ -1015,7 +1017,7 @@ end;
///The event function is called when wizard reaches the ready to install page.
///Because we may or may not launch an elevated installer which will show similar
///page, we need to help to make clear to the user what the installer(s) will be
///doing by adding the extra custom messages accordingly to the page.
///doing by adding the extra custom messages accordingly to the page.
///</remarks>
function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
var
Expand Down Expand Up @@ -1063,7 +1065,7 @@ end;
///
///As a rule, the addin registration should be always uninstalled; there is no
///purpose in having the addin registered when the DLL gets uninstalled. Note
///this is also unconditional - it will uninstall the related registry keys.
///this is also unconditional - it will uninstall the related registry keys.
///</remarks>
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
Expand Down

0 comments on commit 14743dc

Please sign in to comment.