Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating folders inside zip file in NAnt

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?

like image 749
Matthew Groves Avatar asked Jul 31 '12 15:07

Matthew Groves


Video Answer


1 Answers

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>
like image 172
jgritty Avatar answered Sep 25 '22 15:09

jgritty