开发者

msi creation using nant msi task

I am trying to create an msi for my application.

I pass the client and version parameter using the command:

C:\my client\nant -D:client=abc -D:version=1.0

I get the following error message:

**

[msi] Building Installer Database 'C:\irx-client\irxclient.msi'.
      [msi] Adding Properties:
      [msi]  ProductName
      [msi]  ProductVersion
      [msi]  Manufacturer
      [msi]  ProductCode
      [msi]  UpgradeCode
      [msi]  ALLUSERS
      [msi]  TARGETDIR
      [msi] Adding Directories:
      [msi]  client
      [msi]  bitmaps
      [msi]  icsrun552
      [msi]  nls
      [msi]  reports
      [msi] Compressing Files...
                 [exec] Starting 'cabarc (-r N C:\my-client\target\myclient.cab *)' in 'C:\Documents and Settings\user123\Local Settings\Temp\tmp12AE.tmp' BUILD FAILED

**

However, I can manually run the below command successfully:

C:\my-client\target\cabarc -r -p n myclient.cab *.*

I have installed cabarc.exe, nantcontrib and microsoft platform sdk and have i开发者_开发百科ncluded them in the PATH variable.

Please advise what I am doing wrong here.

Summary of the nant script:

  1. Copy files to \target\appname-version\
  2. create msi containing all files and folders under \target\appname-version\
    <?xml version="1.0"?>
<project name="my client" default="msi-package">
<!-- import the extra libraries -->
<loadtasks assembly="${path::combine(environment::get-variable('NANT_HOME'),'contrib/bin/NAnt.Contrib.Tasks.dll')}"/>

<!--********************************************************************
  Initialize all the required variables
************************************************************************-->
<property name="source-core" value="./src/core" />
<property name="client" value="client" overwrite="false"/>    
<property name="version" value="3.3.9.7.6" overwrite="false"/>
<property name="client-target" value="./target/appname-version" />
<property name="source-bank" value="./src/${client}"/>
<property name="ProductName" value="appname" />   
<property name="ProductVersion" value="${version}"/>  
<property name="ProductManufacturer" value="manufacturer Inc"/>
<echo message="${client}"/>
<echo message="${version}"/>

<!--********************************************************************
Delete 'target' folder if it exists and create a new empty target folder.
************************************************************************-->

<target name="clean">
  <delete dir="./target" />
</target>

<target name="prepare" depends="clean">
  <mkdir dir="target" />  
<property name="target" value="./target" />
</target>

<!--**************************************************************************************
Copy files from /src/core and /src/client to target/appname-version
****************************************************************************************-->

<target name="copy-core" depends="prepare">
  <copy todir="${client-target}">
     <fileset basedir="${source-core}">
        <include name="**/*.*" />
     </fileset>
  </copy>
</target>
<target name="copy-bank" depends="copy-core">
  <copy todir="${client-target}" overwrite="true">
      <fileset basedir="${source-bank}">
          <include name="**/*.bmp"/>
          <include name="**/*.exe"/>
          <include name="**/*.icx"/>
          <include name="**/*.img"/>
          <include name="**/*.ini"/>
          <include name="**/*.txt"/>
          <include name="**/nls/*.*"/>
          <include name="**/Reports/*.*"/>
      </fileset>
  </copy>
</target> 

<!--**************************************************************************************
                  msi part should go in this section
*****************************************************************************************-->  

<target name="msi-package" depends="copy-bank">           
<!--this section calls the cabarc.exe which has been installed and the PATH environment variable has been edited to include the exe-->
<setenv>
  <variable name="PATH" path="C:\Program Files\NAnt\bin\;%PATH%" />
</setenv>

<msi sourcedir="C:\my-client\target" output="C:\my-client\myclient.msi" verbose="true" debug="true">

<properties>  
  <property name="ProductName" value="appname" /> 
  <property name="ProductVersion" value="${version}"/>    
  <property name="Manufacturer" value="mamufacturer Inc."/>
  <property name="ProductCode" value="{}" />  
  <property name="UpgradeCode" value="{}" />  
  <property name="ALLUSERS" value="2" />
  <property name="TARGETDIR" value="C:\appname-version" />
</properties>

<directories>
<directory name="C_CLIENT" foldername="client" root="TARGETDIR"/>
<directory name="C_BITMAP" foldername="bitmaps" root="TARGETDIR"/>
<directory name="C_ICSRUN" foldername="icsrun552" root="TARGETDIR" />
<directory name="C_NLS" foldername="nls" root="TARGETDIR" />
<directory name="C_RPTS" foldername="reports" root="TARGETDIR" />
</directories>        

</msi>
</target>
</project>


When I run the exact command, it fails with 'unknown command' error, but if I remove the brackets, its able to create the cab file. Apparently, nant passes the brackets along with the parameters.


I had this same issue. For some reason, adding

<components>
  <component>
    Your component here
  </component>
</components>

Fixed the issue.

You can check the required elements for the <components> element on the <msi> task documentation page: http://nantcontrib.sourceforge.net/release/0.85/help/tasks/msi.html

Also see the great example of an msi task here: Sample Request: <msi> task of nant-contrib


Have you tried using devenv.exe? I have used it in my nant script and I was able to create msi for my application. Here is the code snippet for your reference:

<target name="BuildMsi">
    <echo message="Creating installables (.msi) for MyTestApplication, please wait..."/>    
    <exec program="c:\program files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe">
        <arg value="c:\My app\My_Test_solution.sln"/>
        <arg value="/build"/>
        <arg value="Release|x86" />
        <arg value="/project"/>
        <arg value="c:\My app\setup\My_Test_solution.vdproj"/>
    </exec>
</target>

Make sure that solution file (.sln) path is correct and .vdproj file exists. Hopefully, this will help for people looking for some help in creating msi files using nant scripts. Happy coding!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜