windows-mobilenantcabwiz

NAnt exec task with cabwiz.exe fails


I am using NAnt 0.90 on Windows 7 Professional.

I am trying to build a CAB file using NAnt. NAnt is using an execute task to have CabWiz build the CAB file using an inf file. The build fails, but if I use CabWiz from the command line instead of NAnt, I can build the CAB file.

Here is the relevant part of my NAnt build file:

<target name="build Cab Production">
        <exec program="C:\Program Files (x86)\Microsoft Visual Studio 9.0\SmartDevices\SDK\SDKTools\cabwiz.exe" commandline="ACSreader2\ACSreader2Setup\Production\ACSreader2_Setup.inf  /err cab_build_errors.err"/>
</target>

The cab_build_errors.err file generated by CabWiz contains 2 warnings and a very general error message:

Warning: Section [RegKeys] has no data
Warning: Section [DefaultInstall] key "AddReg" - there are no section entries to process
Error: CAB file "ACSreader2\ACSreader2Setup\Production\ACSreader2_Setup.CAB" could not be created

When I build the CAB from the command line, I get the same 2 warnings, but no error. Here is what I use to build it from the command line:

"C:\Program Files (x86)\Microsoft Visual Studio 9.0\SmartDevices\SDK\SDKTools\cabwiz.exe" "C:\programming\ACSreader2\ACSreader2\ACSreader2Setup\Production\ACSreader2_Setup.inf" /err cab_build_errors.err

UPDATE:

I was able to reproduce the error from the command line using the following command:

"C:\Program Files (x86)\Microsoft Visual Studio 9.0\SmartDevices\SDK\SDKTools\cabwiz.exe" "ACSreader2\ACSreader2Setup\Production\ACSreader2_Setup.inf" /err cab_build_errors.err

The difference is that I am not specifying the full path to the inf file. Is there a variable or something I can use to make NAnt pass the full path without explicitly having the full path in the build script? Something that would just have the directory of the build file would work.


Solution

  • I got it to work by specifying the complete path to the inf file from within the NAnt build script with the use of the NAnt function directory::get-current-directory(). The final result is:

    <target name="build Cab Production">
            <exec program="C:\Program Files (x86)\Microsoft Visual Studio 9.0\SmartDevices\SDK\SDKTools\cabwiz.exe" commandline="${directory::get-current-directory()}\ACSreader2\ACSreader2Setup\Production\ACSreader2_Setup.inf  /err cab_build_errors.err" />
    </target>