2

Could someone explain to me how to use the Microsoft Ajax Minifier from a nant-script as a nant-task. I've seen examples of how to use it in Visual Studio but I would like the minification to be done on our CI-server.

pnuts
  • 58,317
  • 11
  • 87
  • 139
Vinblad
  • 676
  • 1
  • 7
  • 18

4 Answers4

3

I'm not sure specifically about the MS Ajax Minifier, but here's what I did to get the Yahoo! UI Library: YUI Compressor for .Net working.

  1. Downloaded the YUI Compressor assemblies for .NET
  2. Modified their Sample MSBuild.xml File
  3. Modified my nAnt script to run the MSBuild task (more details here: Build and publish .Net 2.0 projects with NAnt and the MSBuild task)
Adam Kahtava
  • 412
  • 3
  • 11
1

This is the code i use, it minifies all *.js and *.css in a folder using ajaxminifier

<foreach item="File" property="filename">
    <in>
        <items>
            <include name="${deployment.dir}\js\*.js"></include>        
            <include name="${deployment.dir}\css\*.css"></include>
        </items>
    </in>
    <do>
        <echo message="Minifying ${filename} and overwritting file"/>
        <exec program="${ajaxminifier.exe}"
            workingdir="."
            failonerror="true"
            commandline='-clobber:true ${filename} -o ${filename}'/>
    </do>
    </foreach>

Note that this script overwrites the files with the minified version ( with -clobber:true arg). ${ajaxminifier.exe} is the path to ajaxmin.exe

Elph
  • 1,594
  • 1
  • 15
  • 20
0
<foreach item="File" property="Debugfile" >
    <in>        
        <items>
            <include name="**\*.debug.js"/>
        </items>
    </in>
    <do failonerror="false">
        <regex pattern="^(?'filename'.*)\.(?'extension2'\w+)\.(?'extension3'\w+)$" input="${Debugfile}" />
        <regex pattern="^(?'path'.*(\\|/)|(/|\\))(?'file'.*)$" input="${Debugfile}" />
        <echo message="renaming with filename=${path},file=${file}"/>
        <exec program="${Minifie.lib}\ajaxmin.exe" commandline="${filename}.debug.js -o ${filename}.js" failonerror="true"/>
    </do>
</foreach>
animuson
  • 53,861
  • 28
  • 137
  • 147
Lokesh
  • 1
0

    description="AjaxminFilesCreation.">
    <foreach item="File" property="Debugfile" >
        <in>        
            <items>
            <include name="**\*.debug.js"/>
        </items>
        </in>
        <do failonerror="false">

        <regex pattern="^(?'filename'.*)\.(?'extension2'\w+)\.(?'extension3'\w+)$" input="${Debugfile}" />
        <regex pattern="^(?'path'.*(\\|/)|(/|\\))(?'file'.*)$" input="${Debugfile}" />
        <echo message="renaming with filename=${path},file=${file}"/>
    <exec program="${Minifie.lib}\ajaxmin.exe" commandline="${filename}.debug.js -o ${filename}.js" failonerror="true"/>
        </do>
    </foreach>
</target>
lokesh
  • 1