Creating folders inside zip file in NAnt
Asked Answered
K

1

7

At the end of a NAnt script, the last step is to create a ZIP file.

Currently, I'm doing this:

<zip zipfile="${target.dropfile}">
    <fileset basedir="${somefolder}">
        <include name="file1.dll" />
    </fileset>
    <fileset basedir="${someotherfolder}">
        <include name="file2.dll" />
    </fileset>
    <!-- ...etc ... -->
</zip>

This works fine, but I want the zip file to be a little more organized. I want the zip file to contain two folders, folder1 and folder2, and I want file1.dll to be in folder1 and file2.dll to be in folder2. Is there any way of doing this within the <zip /> task?

Kroon answered 31/7, 2012 at 15:46 Comment(0)
N
7

Just use the prefix variable.

<zip zipfile="${target.dropfile}">
    <fileset basedir="${somefolder}" prefix="folder1">
        <include name="file1.dll" />
    </fileset>
    <fileset basedir="${someotherfolder}" prefix="folder2">
        <include name="file2.dll" />
    </fileset>
    <!-- ...etc ... -->
</zip>
Nautch answered 31/7, 2012 at 16:36 Comment(2)
I get Unexpected attribute "prefix" on element <include>. - am I using an old version of NAnt?Kroon
So it looks like prefix should be put on the fileset, not on the include (corrected)Kroon

© 2022 - 2024 — McMap. All rights reserved.