【问题标题】:Izpack simple installation just to copy filesizpack简单安装只是为了复制文件
【发布时间】:2014-06-30 12:55:51
【问题描述】:

我正在尝试使用 IzPack 制作一个非常简单的安装程序。它应该做以下两件事 1.将dist目录的所有内容复制粘贴到UserHome/MyApp目录下。 2.执行批处理文件编辑注册表项以在用户登录时启动jar文件。

但我只停留在第一步!如果我使用以下 XML 并生成安装程序,则不会安装任何内容。生成的安装程序运行并显示 InstallPanel,但没有任何内容复制到 user_home 目录。

看起来我无法为 Install_path 变量赋值。

 <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
    <installation version="1.0">
        <variables>
            <variable name="INSTALL_PATH" value="$USER_HOME/MyApp"/>
        </variables>
        <info>
            <appname>My App</appname>
            <appversion>1.0</appversion>
            <authors>
                <author name="My APP Author" email="support@myapp.com"/>
            </authors>
            <url>http://SomeURL.net</url>
        </info>
          <guiprefs width="640" height="480" resizable="yes"/>
        <locale>
            <langpack iso3="eng"/>
        </locale>
        <panels>
            <panel classname="InstallPanel"/>
        </panels>
        <packs>
            <pack name="Base" required="yes">
                <description>The base files</description>
                <fileset dir="dist" targetdir="$INSTALL_PATH"/>
            </pack>
        </packs>
    </installation>

更新

   <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<installation version="1.0">
    <variables>
        <variable name="TargetPanel.dir.windows" value="$USER_HOME\MyTeamNinja"/>
        <variable name="TargetPanel.dir.mac" value="$USER_HOME/MyTeamNinja"/>
    </variables>
    <info>
        <appname>My App</appname>
        <appversion>1.0</appversion>
        <authors>
            <author name="MyTeamNinja" email="support@MyTeamNinja.com"/>
        </authors>
        <url>http://myteam.ninja</url>
    </info>
      <guiprefs width="640" height="480" resizable="yes"/>
    <locale>
        <langpack iso3="eng"/>
    </locale>
    <panels>
        <panel classname="DefaultTargetPanel"/>
        <panel classname="InstallPanel"/>
        <panel classname="SimpleFinishPanel"/>
    </panels>
    <packs>
        <pack name="Base" required="yes">
            <description>The base files</description>
            <fileset dir="dist" targetdir="$INSTALL_PATH"/>
        </pack>
    </packs>
</installation>

现在,只要我单击安装程序,它就会开始安装,但在 c:\program files\My App\

【问题讨论】:

    标签: izpack


    【解决方案1】:

    您需要的是TargetPanel。它允许用户选择目标目录。安装文件。在此面板中选择的位置设置$INSTALL_PATH 的值。

    但是,您也可以覆盖$INSTALL_PATH 的默认值。为了覆盖$INSTALL_PATH默认值,您可以执行以下操作:

    <variables>
      <variable name="TargetPanel.dir.windows" value="$USER_HOME/MyApp"/>
      <variable name="TargetPanel.dir.unix" value="$USER_HOME/MyApp"/>
    </variables>
    

    或者,

    <variables>
      <variable name="DEFAULT_INSTALL_PATH" value="$USER_HOME/MyApp"/>
    </variables>  
    

    另外,请记住在InstallPanel 之前添加TargetPanel,以防您选择允许用户选择目标位置。 用于安装。

        <panels>
            <panel classname="TargetPanel"/>
            <panel classname="InstallPanel"/>
        </panels>
    

    有关更多信息,请参阅HERE


    更新:

    • TargetPanel 的条目放在 InstallPanel 之前的&lt;panels&gt; 部分。
    • 删除 &lt;resources&gt; 部分:
      <resources> <res id="TargetPanel.dir.windows" src="$USER_HOME/MyApp"/> <res id="TargetPanel.dir.unix" src="$USER_HOME/MyApp"/> </resources> 这是产生错误的地方。而是使用&lt;variables&gt; 指定${INSTALL_PATH} 的默认值(请参阅我上面的答案)。
    • 另外,要为${INSTALL_PATH}&lt;variables&gt; 设置值,您需要使用name="DEFAULT_INSTALL_PATH"TargetPanel.dir.windows/unix

    更新 2:以下代码安装在正确的位置(由您在 defaultInstallDir.txt 中指定)。

    <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
    <installation version="1.0">
        <!-- variables>
            <variable name="TargetPanel.dir.windows" value="$USER_HOME\MyTeamNinja"/>
            <variable name="TargetPanel.dir.mac" value="$USER_HOME/MyTeamNinja"/>
        </variables -->
    
        <!-- remove the above <varible> section and include the REQUIRED defaultInstallDir.txt to set the value for the DefaultTargetPanel -->
        <resources>
            <res id="TargetPanel.dir" src="defaultInstallDir.txt"/>
        </resources>
    
        <info>
            <appname>My App</appname>
            <appversion>1.0</appversion>
            <authors>
                <author name="MyTeamNinja" email="support@MyTeamNinja.com"/>
            </authors>
            <url>http://myteam.ninja</url>
        </info>
          <guiprefs width="640" height="480" resizable="yes"/>
        <locale>
            <langpack iso3="eng"/>
        </locale>
        <panels>
            <panel classname="DefaultTargetPanel"/>
            <panel classname="InstallPanel"/>
            <panel classname="SimpleFinishPanel"/>
        </panels>
        <packs>
            <pack name="Base" required="yes">
                <description>The base files</description>
                <fileset dir="dist" targetdir="$INSTALL_PATH"/>
            </pack>
        </packs>
    </installation>   
    

    现在,创建一个名为 defaultInstallDir.txt 的文件,并在该文件中简单地写入以下内容:

    $USER_HOME/MyApp  
    

    只需确保通过&lt;resources&gt; 部分的src=".." 属性将该文件正确包含在安装程序中即可。
    直接双击安装程序将文件安装在$USER_HOME/MyApp(在我的情况下:C:\Users\Sunny\MyApp

    【讨论】:

    • 我得到-&gt; Fatal error : mtninstall.xml:32: Resource not found: .\$USER_HOME\MyApp com.izforge.izpack.compiler.CompilerException: mtninstall.xml:32: Resource not found: .\$USER_HOME\M yApp 我错过了什么
    • 1>Resource not found: .\$USER_HOME\M yApp .. MyApp 之间有一个空格。
    • 不,不幸的是,由于窗口宽度有限,我的 cmd 提示符没有添加新行。这里变成了一个空间。请在更新中查看我最新的 install.xml
    • 现在我的目标面板实际上显示值 "$USER_HOME/MyApp" $USER_HOME 没有被扩展
    • 另外,有没有办法根本不显示目标面板,只在用户目录中安装文件?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    • 2013-10-27
    • 1970-01-01
    • 1970-01-01
    • 2013-04-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多