5

I am using Eclipse 4.5.2 to deploy JavaFX application (JDK 1.8). I want to change an IniFile during the installation. Ant task or JavaFX deploy is generating a dynamic wxi file which will be included in wxs file. When I customize my wxs file it is doing nothing during installation.

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
    <Product Id="ca010b32-9fce-45aa-83f3-3a38f0903b26" Name="test"
             Language="1033" Version="1.00"
             Manufacturer="Test GmbH"
             UpgradeCode="ab0ba5d0-6760-4c00-991d-75816e2409a7">
        <Package Description="test" Comments="None"
                 InstallerVersion="200" Compressed="yes"
                 InstallScope="perUser" Platform="x86"/>
        <Media Id="1" Cabinet="simple.cab" EmbedCab="yes" />
<!-- Check some requirements ONLY on "install", but not on modify or uninstall. -->
<Property Id="JAVA_CURRENT_VERSION">
  <RegistrySearch Id="JRE_CURRENT_VERSION_REGSEARCH" Root="HKLM" Key="SOFTWARE\JavaSoft\Java Runtime Environment" Name="CurrentVersion" Type="raw" Win64="no" />
</Property>
<Condition Message="Java Runtime Environment (32 Bit) is not installed. Please install Oracle JRE."><![CDATA[(Installed OR JAVA_CURRENT_VERSION)]]></Condition>

        <!-- We use RemoveFolderEx to ensure application folder is fully
             removed on uninstall. Including files created outside of MSI
             after application had been installed (e.g. on AU or user state).

             Hovewer, RemoveFolderEx is only available in WiX 3.6,
             we will comment it out if we running older WiX.

             RemoveFolderEx requires that we "remember" the path for uninstall.
             Read the path value and set the APPLICATIONFOLDER property with the value.
        -->
        <Property Id="APPLICATIONFOLDER">
            <RegistrySearch Key="SOFTWARE\test GmbH\test"
                            Root="HKCU" Type="raw"
                            Id="APPLICATIONFOLDER_REGSEARCH" Name="Path" />
        </Property>
        <DirectoryRef Id="APPLICATIONFOLDER">
            <Component Id="CleanupMainApplicationFolder" Guid="*" Win64="no">
                <RemoveRegistryKey Id="RemoveValidationRegistryKeys" Action="removeOnUninstall" Root="HKCU" Key="Software\test GmbH"/>
                <RegistryValue Root="HKCU"
                                   Key="SOFTWARE\test GmbH\test"
                                   Name="Path" Type="string" Value="[APPLICATIONFOLDER]"
                                   KeyPath="yes" />
                <!-- We need to use APPLICATIONFOLDER variable here or RemoveFolderEx
                     will not remove on "install". But only if WiX 3.6 is used. -->

                  <util:RemoveFolderEx On="uninstall" Property="APPLICATIONFOLDER" />
            </Component>
        </DirectoryRef>
        <?include bundle.wxi ?>
        <UI/>
        <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Name="AppData" Id="LocalAppDataFolder">
           <Directory Id="APPLICATIONFOLDER" Name="test">
             <Directory Id="dirid6" Name="app">
              <Component Id="comp1" DiskId="1" Guid="ec2f648f-05ec-4deb-bf65-b938e40209f4">
               <IniFile Id="ConfigFile" Action="removeLine" Directory="INSTALLDIR" Name="test.cfg" Section="Application" Key="app.runtime" />
              </Component>
             </Directory>
           </Directory>
          </Directory>
         </Directory>
        <Icon Id="DesktopIcon.exe" SourceFile="test.ico" />
        <Icon Id="StartMenuIcon.exe" SourceFile="test.ico" />

    </Product>
</Wix>

As you can see there is a part <?include bundle.wxi ?>. Here the dynamically created bundle.wxi file will be used.

I tried to do this with wix inifile => <IniFile Id="ConfigFile" Action="removeLine" Directory="INSTALLDIR" Name="test.cfg" Section="Application" Key="app.runtime" /> My Problem is, how can I change the IniFile?

When I look in the MSI file, it does not contain any IniFile settings.

And at installation there is nothing changed. In the msi log file there is no indication that there is any inifile changed.

What am I doing wrong?

Is there a way to do this with custom action?

Is there any description how to customize setup deployed with JavaFX Packager?


EDIT

The wxi file gets included and all files defined in wxi file are installed correct. But I cannot change the wxi file as it is generated by the compiler. So I have to change the wxs file, but I don't know how.

Here is the wxi file generated during compiling:

<?xml version="1.0" encoding="UTF-8" ?>
<Include>
 <Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Name="AppData" Id="LocalAppDataFolder">
   <Directory Id="APPLICATIONFOLDER" Name="test">
     <Component Id="comp0" DiskId="1" Guid="39ba98fa-6285-4336-8bd0-47ba5e16f622">
      <CreateFolder/>
      <RemoveFolder Id="RemoveDir0" On="uninstall" />
        <RegistryKey Root="HKCU"  Key="Software\test GmbH\test" Action="createAndRemoveOnUninstall">
         <RegistryValue Name="Version" Value="1.6" Type="string" KeyPath="yes"/>
       </RegistryKey>
       <File Id="FileId1" Name="msvcp120.dll"  Source="msvcp120.dll">
       </File>
       <File Id="FileId2" Name="msvcr100.dll"  Source="msvcr100.dll">
       </File>
       <File Id="FileId3" Name="msvcr120.dll"  Source="msvcr120.dll">
       </File>
       <File Id="LauncherId" Name="test.exe"  Source="test.exe">
      <Shortcut Id="desktopShortcut" Directory="DesktopFolder" Name="test" WorkingDirectory="INSTALLDIR" Advertise="no" Icon="DesktopIcon.exe" IconIndex="0" />
         <Shortcut Id="ExeShortcut" Directory="ProgramMenuDir" Name="test" Advertise="no" Icon="StartMenuIcon.exe" IconIndex="0" />
       </File>
       <File Id="FileId4" Name="test.ico"  Source="test.ico">
       </File>
       <File Id="FileId5" Name="packager.dll"  Source="packager.dll">
       </File>
     </Component>
     <Directory Id="dirid6" Name="app">
      <Component Id="comp1" DiskId="1" Guid="ec2f648f-05ec-4deb-bf65-b938e40209f4">
       <CreateFolder/>
       <RemoveFolder Id="RemoveDir7" On="uninstall" />
         <RegistryKey Root="HKCU"  Key="Software\test GmbH\test" Action="createAndRemoveOnUninstall">
          <RegistryValue Name="Version" Value="1.6" Type="string" KeyPath="yes"/>
        </RegistryKey>
        <File Id="FileId8" Name="jacob-1.18-M2-x86.dll"  Source="app\jacob-1.18-M2-x86.dll">
        </File>
        <File Id="FileId9" Name="test.cfg"  Source="app\test.cfg">
        </File>
        <File Id="FileId10" Name="test.jar"  Source="app\test.jar">
        </File>
      </Component>
      <Directory Id="dirid11" Name="libs">
       <Component Id="comp2" DiskId="1" Guid="d41462cb-43f3-4705-94b6-20b30405a6dd">
        <CreateFolder/>
        <RemoveFolder Id="RemoveDir12" On="uninstall" />
          <RegistryKey Root="HKCU"  Key="Software\test GmbH\test" Action="createAndRemoveOnUninstall">
           <RegistryValue Name="Version" Value="1.6" Type="string" KeyPath="yes"/>
         </RegistryKey>
         <File Id="FileId13" Name="bcprov-ext-jdk15on-152.jar"  Source="app\libs\bcprov-ext-jdk15on-152.jar">
         </File>
         <File Id="FileId14" Name="jacob.jar"  Source="app\libs\jacob.jar">
         </File>
       </Component>
      </Directory>
     </Directory>
   </Directory>
  </Directory>
  <Directory Id="DesktopFolder" />
  <Directory Id="ProgramMenuFolder">
    <Directory Id="ProgramMenuDir" Name="test GmbH">
      <Component Id="comp3" Guid="b81b7415-1f39-47a9-9a99-435b3269bc7e">
        <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
         <RegistryValue Root="HKCU" Key="Software\test GmbH\test" Type="string" Value="" />
      </Component>
    </Directory>
 </Directory>
 </Directory>
 <Feature Id="DefaultFeature" Title="Main Feature" Level="1">
    <ComponentRef Id="comp0" />
    <ComponentRef Id="comp1" />
    <ComponentRef Id="comp2" />
    <ComponentRef Id="comp3" />
    <ComponentRef Id="CleanupMainApplicationFolder" />
 </Feature>
</Include>

EDIT 2

I tried to changed the wxs file in several ways. It seems, that my changes somehow are not included in MSI package. I added a file, registry keys and IniFile. But nothing changes in the MSI package.

Here is my current wxs file:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
    <Product Id="ca010b32-9fce-45aa-83f3-3a38f0903b26" Name="test" Language="1033" Version="1.00" Manufacturer="test GmbH" UpgradeCode="ab0ba5d0-6760-4c00-991d-75816e2409a7">
        <Package Description="test" Comments="None" InstallerVersion="200" Compressed="yes" InstallScope="perUser" Platform="x86" />
        <Media Id="1" Cabinet="simple.cab" EmbedCab="yes" />
        <!-- Check some requirements ONLY on "install", but not on modify or uninstall. -->
        <Property Id="JAVA_CURRENT_VERSION">
            <RegistrySearch Id="JRE_CURRENT_VERSION_REGSEARCH" Root="HKLM" Key="SOFTWARE\JavaSoft\Java Runtime Environment" Name="CurrentVersion" Type="raw" Win64="no" />
        </Property>
        <Condition Message="Java Runtime Environment (32 Bit) is not installed. Please install Oracle JRE."><![CDATA[(Installed OR JAVA_CURRENT_VERSION)]]></Condition>
        
        <Property Id="APPLICATIONFOLDER">
            <RegistrySearch Key="SOFTWARE\test GmbH\test" Root="HKCU" Type="raw" Id="APPLICATIONFOLDER_REGSEARCH" Name="Path" />
        </Property>
        <DirectoryRef Id="APPLICATIONFOLDER">
            <Component Id="CleanupMainApplicationFolder" Guid="*" Win64="no">
                <RemoveRegistryKey Id="RemoveValidationRegistryKeys" Action="removeOnUninstall" Root="HKCU" Key="Software\test GmbH" />
                <RegistryValue Root="HKCU" Key="SOFTWARE\test GmbH\test" Name="Path" Type="string" Value="[APPLICATIONFOLDER]" KeyPath="yes" />
                <!-- We need to use APPLICATIONFOLDER variable here or RemoveFolderEx
                     will not remove on "install". But only if WiX 3.6 is used. -->
                <util:RemoveFolderEx On="uninstall" Property="APPLICATIONFOLDER" />
                <IniFile Id="ConfigFile" Action="removeLine" Key="app.runtime" Name="test.cfg" Section="Application" Directory="dirid6" />
            </Component>
        </DirectoryRef>
        <DirectoryRef Id="dirid6">
            <Component>
                <IniFile Id="ConfigFileasasd" Action="removeLine" Key="app.runtime" Name="test.cfg" Section="Application" Directory="dirid6" />
                <RegistryValue Key="SOFTWARE\test GmbH\test" KeyPath="yes" Root="HKCU" Value="[APPLICATIONFOLDER]" Type="string" Name="Path2" />
            </Component>
        </DirectoryRef>
        <?include bundle.wxi ?>
        <UI />
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Name="AppData" Id="LocalAppDataFolder">
                <Directory Id="APPLICATIONFOLDER" Name="test">
                    <Directory Id="dirid6" Name="app">
                        <Component Id="comp1" DiskId="1" Guid="ec2f648f-05ec-4deb-bf65-b938e40209f4">
                            <IniFile Id="ConfigFile" Action="addLine" Directory="INSTALLDIR" Name="test.cfg" Section="Application" Key="app.runtime" />
                        </Component>
                    </Directory>
                </Directory>
            </Directory>
        </Directory>
        <Icon Id="DesktopIcon.exe" SourceFile="test.ico" />
        <Icon Id="StartMenuIcon.exe" SourceFile="test.ico" />
    </Product>
</Wix>

EDIT 3

I found out myself what the problem is. The log states that the compiler is using default wxs file instead of custom wxs file.

Config files are saved to C:\Users\xxx\AppData\Local\Temp\fxbundler5060494280971686435\windows. Use them to customize package.

Using default package resource [WiX config file] (add package/windows/test.wxs to the class path to customize)

Where do I have to add/place the custom wxs file in my project?

Community
  • 1
  • 1
Sebastian Siemens
  • 2,302
  • 1
  • 17
  • 24

2 Answers2

0

My guess is your bundle.wxi file is all inside a <Fragment> tag. You'll need to just add a <Property Id="BundleFile"/> to your generated file and in your main product add a <PropertyRef Id="BundleFile"/>

Just referencing the file isn't enough to get its contents actually included in your final output. The preprocessor will go through and basically reorganize your code before compiling. If there's no reference anywhere or chain of references anywhere that eventually link a fragment to the main <product> tag for your wix installer, that code will be discarded. This is what I assume is happening when you try to link in your dynamically generated wxi file. You link it in and then the preprocessor discards everything in it because there is nothing tying it to your main installer.

Generally you will use a <SomethingRef Id="IdOfSomething"/> tag to reference something in a fragment so the whole fragment is included in your main product.


I read the question again and I don't know if what I initially wrote applies. looking at the <? include ?> tag it looks like this just means the preprocessor puts in "/I file" to the compiler cmd line. It doesn't insert the file in where you put it in the wxs.

The issue you might be having is that you tell your installer that the INI file is in the INSTALLDIR but I don't see you setting or defining INSTALLDIR anywhere.

Brian Sutherland
  • 4,698
  • 14
  • 16
  • The wxi file is not the problem. My problem is, that the inifile settings are not executed during install. The wxi file is generated by the compiler and includes files to be installed (like jar files and dll files and the executable). Here I cannot change the behavior. The only thing I can change is the wxs file. But I have no idea where to put my IniFile settings. I only want to change the IniFile during install. – Sebastian Siemens May 10 '16 at 06:03
  • I still don't see INSTALLDIR being defined anywhere. Where's this ini file located? What happens if you take out Directory="INSTALLDIR" so it inherits the directory of the component it is part of? – Brian Sutherland May 10 '16 at 16:05
  • Also try adding a registrykey (that doesn't exist) to the component with IniFile and set the registrykey as the keypath="yes", just something to try since it might be assuming the "IniFile" component is already present since it takes the component's dir as the keypath*I think* when there is no explicit keypath set. – Brian Sutherland May 10 '16 at 16:09
  • I removed directory, but nothing changes. I added directory again with the property where the correct path is stored. In wxi file there is dirId6 defined. In this path the config file i want to change is stored. Why is nothing changing? all my changes are not in the msi package... – Sebastian Siemens May 12 '16 at 06:45
  • the problem is that compiler is using default wxs file instead of my custom wxs file. Do you know where I have to place my custom wxs file? – Sebastian Siemens May 12 '16 at 09:13
  • I don't know I've never encountered cached files being used. I've only built my installer projects with visual studio/MSBuild and never had an issue like that. You can try just deleting the stuff in the temp directory. At this point if your msi doesn't even have an IniFile Table I would just write a custom action to change the file. Maybe the IniFile stuff only works on actuall *.ini extension files? I couldn't find the answer to that. – Brian Sutherland May 12 '16 at 14:41
  • I fixed the problem with the custom wxs file. I had to define the class path for ant. Under the class path there has to be folder package\windows. Now I have a different problem. Thanks for your effort. – Sebastian Siemens May 17 '16 at 06:22
0

u need to add your wxs file to package/windows/ >yourfile.wxs>

make sure it is the same name that is in your temp folder , then it will use this instead :)

Squiggz
  • 11
  • 3