【问题标题】:How to compile NSIS script using ant?如何使用 ant 编译 NSIS 脚本?
【发布时间】:2023-03-22 18:17:01
【问题描述】:

我已经为我的java项目创建了NSIS脚本。我已经在我的eclipse中安装了nsis插件。使用插件我已经创建了nsi文件。现在我想编译nsi文件。我尝试在eclipse中使用Ant。

<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="nsis" basedir=".">
    <property name="build.path" value="build"/> 
        <property name="deploy.dir" value="/opt/test"></property>
    <path id="library.classpath">
            <fileset dir="lib">
                <include name="nsisant-1.2.jar"/>
            </fileset>
        </path>
    <target name="nsis" description="compile nsis script">
        <mkdir dir="${build.path}/nsis"/>
        <nsis script="setup.nsi">
            <classpath refid="library.classpath"/>
        </nsis>
    </target>
    </project>

但它会引发以下错误。

 BUILD FAILED
    build.xml:12: Problem: failed to create task or type nsis
    Cause: The name is undefined.
    Action: Check the spelling.
    Action: Check that any custom tasks/types have been declared.
    Action: Check that any <presetdef>/<macrodef> declarations have taken place.

我不知道为什么会这样??如何使用ant编译nsi文件?或者有没有其他方法可以在不使用 ant 的情况下进行编译?

【问题讨论】:

    标签: ant nsis


    【解决方案1】:

    使用专用的nsis 任务似乎是最好的方法,但也许不是最简单的。我只是使用这样的语法执行makensis.exe

    <exec executable="C:\Program_Files\NSIS\makensis.exe" failonerror="true" >
      <!-- providing some nsis definitions -->
      <arg value="/DPROJECT_NAME=${ant.project.name}"/>
      <!-- passing the script -->
      <arg value="${basedir}\raport.nsi"/>
    </exec>
    

    关于你的第二个问题:是的,你可以在没有 ant 的情况下编译 nsis 脚本。例如:

    C:\Program_Files\NSIS\makensis.exe /DPROJECT_NAME=this-project my-script.nsi
    

    在 Linux 上,您还应该在某处拥有 makensis

    PROJECT_NAME 的东西是我的自定义。在最简单的情况下,您不提供任何定义,省略该部分。

    【讨论】:

    • 谢谢。我在哪里得到 makensis.exe 文件? google了下没找到,是下载文件吗?你能给我任何链接或告诉我如何使用makensis.exe吗?
    • 谢谢。我已经下载了。在上面的脚本中可以同时使用 windows 和 linux 吗?只适用于 linux?
    • 在 Linux 上,您必须使用 wine 或自己构建。看到这个问题:NSIS support for Linux and Solaris.
    • failonerror="true" 这个标签有什么用?你能告诉我吗?
    • 我很乐意为您提供难以找到的东西。但我不会为你阅读手册。谷歌搜索“执行任务”。
    【解决方案2】:

    您是否使用来自Nsis Ant Sourceforge project 的 NSIS Ant 任务?安装好后就可以用了

    <taskdef name="nsis" classname="net.sf.nsisant.Task">
        <classpath location="nsisant-{version}.jar">
    </taskdef>
    

    【讨论】:

    • 你对这个“一旦安装”是什么意思。现在我只有 nsis 脚本。那么我该如何安装?通过ant我想在我要安装之后编译脚本。你能说清楚吗?
    • 已安装 = nsisant jar 文件必须位于类路径中的某个位置
    • 谢谢。如果我运行这个脚本是否需要 makensis.exe 文件?如果需要,我怎样才能得到那个 makensis.exe 文件?。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-18
    • 1970-01-01
    • 2022-11-17
    相关资源
    最近更新 更多