Skip to content

Commit c08670b

Browse files
committed
fix: Improve installer custom actions and add manifest files
Fix null reference errors in VerifyDataPath custom action and add missing manifest files to installer packaging. - Add null checks for REGISTRYDATAKEY/REGISTRYDATAVALUENAME properties - Add null-safe registry value access to prevent NullReferenceException - Move CloseApplications to InstallUISequence (UI-only, immediate mode) - Add FieldWorks.exe.manifest, FwKernel.X.manifest, Views.X.manifest - Set LaunchUnicodeCharEditor Return="check" to catch manifest errors - Suppress light.exe ICE warnings 1055/1056 for cleaner builds
1 parent fd4b3e3 commit c08670b

5 files changed

Lines changed: 33 additions & 7 deletions

File tree

BaseInstallerBuild/Framework.wxs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868

6969
<CustomAction Id="CloseApplications"
7070
Return="check"
71+
Execute="immediate"
72+
Impersonate="yes"
7173
BinaryKey="MyCustomActionsDll"
7274
DllEntry="ClosePrompt" />
7375
<!-- The following two properties can be comma separted lists, but they must have the same number of items. -->
@@ -101,6 +103,8 @@
101103
<SetProperty Id='APPFOLDERREGSZNAME' Value='Program_Files_Directory_$(var.SafeApplicationName)' Before="AppSearch">not APPFOLDERREGSZNAME</SetProperty>
102104
<SetProperty Id='DATAFOLDERREGSZNAME' Value='Settings_Directory' Before="AppSearch">not DATAFOLDERREGSZNAME</SetProperty>
103105
<SetProperty Id='HARVESTDATAFOLDERREGSZNAME' Value='Data_Directory' Before="AppSearch">not HARVESTDATAFOLDERREGSZNAME</SetProperty>
106+
<SetProperty Id='REGISTRYDATAKEY' Value='[REGISTRYKEY]' Before="AppSearch">not REGISTRYDATAKEY</SetProperty>
107+
<SetProperty Id='REGISTRYDATAVALUENAME' Value='[DATAFOLDERREGSZNAME]' Before="AppSearch">not REGISTRYDATAVALUENAME</SetProperty>
104108
<CustomAction Id='UseDefDataFolder' Property='DATAFOLDER' Value='[DEFDATAFOLDER]' />
105109
<CustomAction Id='UseOvrDataFolder' Property='DATAFOLDER' Value='[OVRDATAFOLDER]' /> <!-- from Overrides.wxi -->
106110
<CustomAction Id='UseRegDataFolder' Property='DATAFOLDER' Value='[REGDATAFOLDER]' />
@@ -115,7 +119,6 @@
115119
<CustomAction Id='CheckPatchValue' Property='ISPATCH' Value='True' />
116120

117121
<InstallExecuteSequence>
118-
<Custom Action="CloseApplications" Before="AppSearch"></Custom>
119122
<!--<Custom Action="SetFontValues" After="AppSearch"></Custom>-->
120123
<Custom Action="DeleteRegistryVersionNumber" Before="RemoveRegistryValues">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
121124
<RemoveExistingProducts Before="InstallInitialize" />
@@ -127,8 +130,9 @@
127130
</InstallExecuteSequence>
128131

129132
<InstallUISequence>
133+
<Custom Action="CloseApplications" Before="AppSearch">UILevel &gt;= 3</Custom>
130134
<Custom Action="SetDefDataFolder" After="FindRelatedProducts"></Custom>
131-
<Custom Action="VerifyDataPath" After="SetDefDataFolder"></Custom>
135+
<Custom Action="VerifyDataPath" After="AppSearch"></Custom>
132136
<Custom Action="UseDefAppFolder" After="AppSearch">(NOT REGAPPFOLDER) and (NOT OVRAPPFOLDER)</Custom>
133137
<Custom Action="UseOvrAppFolder" After="AppSearch">(NOT REGAPPFOLDER) and (OVRAPPFOLDER)</Custom>
134138
<Custom Action="UseRegAppFolder" After="AppSearch">REGAPPFOLDER</Custom>

BaseInstallerBuild/buildMsi.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ call setVars.bat %*
1515
@REM Compile (candle) and Link (light) the MSI file.
1616
candle.exe -arch %Arch% -dBuildArch=%Arch% -dApplicationName=%AppName% -dSafeApplicationName=%SafeAppName% -dManufacturer=%Manufacturer% -dSafeManufacturer=%SafeManufacturer% -dVersionNumber=%Version% -dMajorVersion=%Major% -dMinorVersion=%Minor% -dMASTERBUILDDIR=%MASTERBUILDDIR% -dMASTERDATADIR=%MASTERDATADIR% -dUpgradeCode=%UPGRADECODEGUID% -dProductCode=%PRODUCTIDGUID% Framework.wxs AppHarvest.wxs DataHarvest.wxs WixUI_DialogFlow.wxs GIInstallDirDlg.wxs GIProgressDlg.wxs GIWelcomeDlg.wxs GICustomizeDlg.wxs GISetupTypeDlg.wxs -ext WixFirewallExtension -ext WixUtilExtension
1717
) && (
18-
light.exe Framework.wixobj AppHarvest.wixobj DataHarvest.wixobj WixUI_DialogFlow.wixobj GIInstallDirDlg.wixobj GIProgressDlg.wixobj GIWelcomeDlg.wixobj GICustomizeDlg.wixobj GISetupTypeDlg.wixobj -ext WixFirewallExtension -ext WixUIExtension -ext WixUtilExtension -cultures:en-us -loc WixUI_en-us.wxl %SuppressICE% -sw1076 -out %SafeAppName%_%Version%.msi
18+
light.exe Framework.wixobj AppHarvest.wixobj DataHarvest.wixobj WixUI_DialogFlow.wixobj GIInstallDirDlg.wixobj GIProgressDlg.wixobj GIWelcomeDlg.wixobj GICustomizeDlg.wixobj GISetupTypeDlg.wixobj -ext WixFirewallExtension -ext WixUIExtension -ext WixUtilExtension -cultures:en-us -loc WixUI_en-us.wxl %SuppressICE% -sw1076 -sw1055 -sw1056 -out %SafeAppName%_%Version%.msi
1919
) && (
2020
call signingProxy %CD%\%SafeAppName%_%Version%.msi
2121
)

Common/CustomComponents.wxi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@
126126
<File Id="FieldWorks.exe" Name="FieldWorks.exe" Source="!(wix.RootObjectsDir)\FieldWorks.exe" ReadOnly="yes" Checksum="yes" KeyPath="yes" Assembly=".net" AssemblyApplication="FieldWorks.exe" AssemblyManifest="FieldWorks.exe">
127127
<fire:FirewallException Id="FieldWorks.exe" Name="FieldWorks" IgnoreFailure="yes" Scope="any" xmlns:fire="http://schemas.microsoft.com/wix/FirewallExtension"/>
128128
</File>
129+
<File Id="FieldWorks.exe.manifest" Name="FieldWorks.exe.manifest" Source="!(wix.RootObjectsDir)\FieldWorks.exe.manifest" ReadOnly="yes" Checksum="yes" />
130+
<File Id="FwKernel.X.manifest" Name="FwKernel.X.manifest" Source="!(wix.RootObjectsDir)\FwKernel.X.manifest" ReadOnly="yes" Checksum="yes" />
131+
<File Id="Views.X.manifest" Name="Views.X.manifest" Source="!(wix.RootObjectsDir)\Views.X.manifest" ReadOnly="yes" Checksum="yes" />
129132
<ProgId Id="FwBackupFile" Icon="FieldWorks.exe" Description="FieldWorks Backup">
130133
<Extension Id="fwbackup" >
131134
<Verb Id="open" Command="&amp;Restore" Argument="&quot;%1&quot;" TargetFile="FieldWorks.exe" />

Common/Overrides.wxi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<SetProperty Id="OVRHARVESTDATAFOLDER" Value="[CommonAppDataFolder]SIL" Before="AppSearch"/>
1515
<SetProperty Id="OVRDATAFOLDER" Value="[CommonAppDataFolder]SIL\FieldWorks\Projects" Before="AppSearch"/>
1616
<SetProperty Id="QtExecCmdLine" Value="&quot;cmd&quot; /c (set ICU_DATA=[OVRHARVESTDATAFOLDER]\Icu70) &amp; &quot;[APPFOLDER]\UnicodeCharEditor.exe&quot; -i" Before="InstallFinalize" Sequence="execute"/>
17+
<!-- Return="check" fails the installation if UnicodeCharEditor fails, ensuring we catch manifest issues before release -->
1718
<CustomAction Id="LaunchUnicodeCharEditor" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="immediate" Return="check"/>
1819
</Include>

CustomActions/CustomActions/CustomAction.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static ActionResult CheckAppPath(Session session)
2626
//return failure if the app path is the program files directory
2727
string progFilesDir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
2828
string progFiles86Dir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
29-
29+
3030
//On 32bit XP machines ProgramFilesX86 will return an empty string.
3131
if (String.IsNullOrEmpty(progFiles86Dir))
3232
progFiles86Dir = progFilesDir;
@@ -86,6 +86,13 @@ public static ActionResult VerifyDataDirPath(Session session)
8686
session.Log("Begin VerifyDataPath in custom action dll");
8787
string registryKey = session["REGISTRYDATAKEY"];
8888
string valueName = session["REGISTRYDATAVALUENAME"];
89+
if (string.IsNullOrWhiteSpace(registryKey) || string.IsNullOrWhiteSpace(valueName))
90+
{
91+
session.Log("VerifyDataPath: REGISTRYDATAKEY or REGISTRYDATAVALUENAME is missing.");
92+
session["REGDATAFOLDER"] = null;
93+
session["DATAFOLDERFOUND"] = "NotFound";
94+
return ActionResult.Success;
95+
}
8996
string regDataPath = GetDataDirFromRegistry(registryKey, valueName, session);
9097
if (string.IsNullOrEmpty(regDataPath))
9198
{
@@ -95,7 +102,7 @@ public static ActionResult VerifyDataDirPath(Session session)
95102
}
96103

97104
session["REGDATAFOLDER"] = regDataPath;
98-
105+
99106
if (Directory.Exists(regDataPath) && Directory.GetFiles(regDataPath).Length > 0)
100107
session["DATAFOLDERFOUND"] = "AlreadyExisting";
101108
else
@@ -213,16 +220,27 @@ public static ActionResult LookForInstalledFonts(Session session)
213220

214221
private static string GetDataDirFromRegistry(string path, string valueName, Session session)
215222
{
223+
if (string.IsNullOrWhiteSpace(path) || string.IsNullOrWhiteSpace(valueName))
224+
return null;
225+
216226
string dataPathKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\" + path;
217227
string dataPathKeyWow = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\" + path;
218228

219229
string projPath = "";
220230
try
221231
{
222232
if (RegistryU.KeyExists(dataPathKey))
223-
projPath = RegistryU.GetKey("HKLM", "SOFTWARE\\" + path).GetValue(valueName).ToString();
233+
{
234+
var value = RegistryU.GetKey("HKLM", "SOFTWARE\\" + path)?.GetValue(valueName);
235+
if (value != null)
236+
projPath = value.ToString();
237+
}
224238
if (RegistryU.KeyExists(dataPathKeyWow))
225-
projPath = RegistryU.GetKey("HKLM", "SOFTWARE\\Wow6432Node\\" + path).GetValue(valueName).ToString();
239+
{
240+
var value = RegistryU.GetKey("HKLM", "SOFTWARE\\Wow6432Node\\" + path)?.GetValue(valueName);
241+
if (value != null)
242+
projPath = value.ToString();
243+
}
226244
}
227245
catch (Exception ex)
228246
{

0 commit comments

Comments
 (0)