【问题标题】:JavaFX eclipse customize deployed package with wixJavaFX eclipse 使用 wix 自定义部署包
【发布时间】:2016-08-29 11:26:59
【问题描述】:

我正在使用 Eclipse 4.5.2 部署 JavaFX 应用程序 (JDK 1.8)。 我想在安装过程中更改 IniFile。 Ant 任务或 JavaFX 部署正在生成​​一个动态 wxi 文件,该文件将包含在 wxs 文件中。当我自定义我的 wxs 文件时,它在安装过程中什么也不做。

<?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>

如您所见,有一部分&lt;?include bundle.wxi ?&gt;。这里将使用动态创建的 bundle.wxi 文件。

我尝试使用 wix inifile => &lt;IniFile Id="ConfigFile" Action="removeLine" Directory="INSTALLDIR" Name="test.cfg" Section="Application" Key="app.runtime" /&gt; 我的问题是,如何更改 IniFile?

当我查看 MSI 文件时,它不包含任何 IniFile 设置。

安装时没有任何变化。在 msi 日志文件中没有任何迹象表明有任何 inifile 已更改。

我做错了什么?

有没有办法通过自定义操作来做到这一点?

是否有任何描述如何自定义使用 JavaFX Packager 部署的设置?


编辑

wxi 文件被包括在内,并且 wxi 文件中定义的所有文件都安装正确。但是我无法更改 wxi 文件,因为它是由编译器生成的。所以只好改wxs文件,不知道怎么改。

这是编译时生成的wxi文件:

<?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>

编辑 2

我尝试以多种方式更改 wxs 文件。看来,我的更改不知何故未包含在 MSI 包中。我添加了一个文件、注册表项和 IniFile。但是 MSI 包没有任何变化。

这是我当前的 wxs 文件:

<?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>

编辑 3

我自己发现了问题所在。日志指出编译器正在使用默认 wxs 文件而不是自定义 wxs 文件。

配置文件保存到 C:\Users\xxx\AppData\Local\Temp\fxbundler5060494280971686435\windows。使用它们来定制包。

使用默认包资源[WiX配置文件](将package/windows/test.wxs添加到类路径中进行自定义)

在我的项目中,我必须在哪里添加/放置自定义 wxs 文件?

【问题讨论】:

  • 动态创建的bundle.wxi文件内容是什么?
  • 我将 wxi 文件添加到我的问题中

标签: java eclipse javafx ant wix


【解决方案1】:

我猜你的 bundle.wxi 文件都在 &lt;Fragment&gt; 标签内。您只需将 &lt;Property Id="BundleFile"/&gt; 添加到生成的文件中,然后在主产品中添加 &lt;PropertyRef Id="BundleFile"/&gt;

仅引用文件不足以使其内容实际包含在最终输出中。预处理器将在编译之前通过并基本上重新组织您的代码。如果没有任何地方的引用或任何地方的引用链最终将片段链接到您的 wix 安装程序的主 标记,则该代码将被丢弃。当您尝试链接动态生成的 wxi 文件时,这就是我假设正在发生的事情。您将其链接,然后预处理器丢弃其中的所有内容,因为没有任何东西将其绑定到您的主安装程序。

通常您将使用 Ref Id="IdOfSomething"/> 标签来引用片段中的某些内容,以便整个片段包含在您的主要产品中。


我再次阅读了这个问题,我不知道我最初写的内容是否适用。查看&lt;? include ?&gt; 标签,看起来这只是意味着预处理器将“/I 文件”放入编译器 cmd 行。它不会将文件插入到您在 wxs 中放置的位置。

您可能遇到的问题是您告诉安装程序 INI 文件在 INSTALLDIR 中,但我没有看到您在任何地方设置或定义 INSTALLDIR。

【讨论】:

  • wxi文件不是问题。我的问题是,安装过程中没有执行 inifile 设置。 wxi 文件由编译器生成,包含要安装的文件(如 jar 文件和 dll 文件以及可执行文件)。在这里我无法改变行为。我唯一可以更改的是 wxs 文件。但我不知道将我的 IniFile 设置放在哪里。我只想在安装过程中更改 IniFile。
  • 我仍然没有看到任何地方都定义了 INSTALLDIR。这个ini文件在哪里?如果你取出 Directory="INSTALLDIR" 让它继承它所属组件的目录会发生什么?
  • 还尝试使用 IniFile 向组件添加一个注册表项(不存在)并将注册表项设置为 keypath="yes",因为它可能假设为“IniFile”组件已经存在,因为当没有明确的 keypath 设置时,它将组件的 dir 作为 keypath我认为
  • 我删除了目录,但没有任何变化。我再次使用存储正确路径的属性添加了目录。在 wxi 文件中定义了 dirId6。在此路径中存储了我要更改的配置文件。为什么什么都没有改变?我所有的更改都不在 msi 包中...
  • 问题是编译器使用默认的 wxs 文件而不是我的自定义 wxs 文件。你知道我必须把我的自定义 wxs 文件放在哪里吗?
【解决方案2】:

你需要将你的 wxs 文件添加到 package/windows/ >yourfile.wxs>

确保它与您的临时文件夹中的名称相同,然后它将改用它:)

【讨论】:

    猜你喜欢
    • 2018-02-08
    • 1970-01-01
    • 2015-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-18
    • 1970-01-01
    相关资源
    最近更新 更多