Using the Ajax Minifier Manifest Task
Microsoft Ajax Minifier supplies an
AjaxMinTask.dll that contains a couple useful build tasks for your MSBuild projects. One of the tasks is the
AjaxManifestTask. The tool also supplies a simple targets file to simplify the addition of the functionality to your project: AjaxMinTask.targets. You can add a reference to that .targets file in your .csproj file like this:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\AjaxMinTask.targets" />
Note: the above <Import> element example is assuming that Microsoft Ajax Minifier has been installed on your system via the MSI install downloaded from this CodePlex site. If you are using the Nuget package with your project, copies of the DLL and
TARGETS file will be under the tools folder of your package installation, so the $(MSBuildExtensionsPath) variable used in this <Import> example will not be what you want. You can encode the Project path using the Nuget installation path in your solution,
to your machine using the MSI, then add the AjaxMinTask.dll and AjaxMinTask.targets file to your solution. This will copy them into your project. Modify your .CSPROJ file to import the .TARGETS file from the path within your solution.
The contents of the targets file will look something like this:
<UsingTask TaskName="AjaxMinManifestTask" AssemblyFile="AjaxMinTask.dll" />
<!-- target to build all ajaxmin manifest files in the project -->
<Target Name="BuildAjaxMinManifests" AfterTargets="Build">
<Message Text="Processing AjaxMin Manifests" Importance="high" />
<CreateItem Include="@(None)" Condition="'%(Extension)'=='.ajaxmin'">
<Output TaskParameter="Include" ItemName="AjaxMinManifests"/>
This .TARGETS file defines an MSBuild target that run after the project’s normal Build task. It looks for any files in your project with the extension “.ajaxmin” and assumes that the files are all AjaxMin
manifest files. It then runs the AjaxMinManifestTask on each file.
- Whatever the project has in its defines constants are passed to AjaxMin.
- The configuration (Debug or Release) is passed.
- Warnings are not treated as errors (you can edit this if you want to change that behavior)
- The root of the project is the input folder; all <input> paths are relative to the project root.
- The Content folder under the project root is the output folder; all <output> paths are relative to that folder.
to “None,” and edit them to specify whatever arguments, output, input, resource, rename, norename, and symbolMap elements you wish.