A .NET MSBuild tasks package contains utilities for minification, html preprocessing
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



The MSBuild tasks package contains utilities for JS, CSS and HTML minification without server-side participation in release, HTML preprocessing. It uses WebGreace config for bundles definition.


  1. Microsoft Ajax for JS and CSS minification.
  2. Zeta HTML Compressor - a .NET Port of Google's HTML compresor

Quick start for ASP.NET MVC developers

Manual for developers who use cshtml, i.e. not static HTML. If you have no plans to use static HTML you can look for alternative, but IMHO the definition of the package is less convienment that [WebGrease] (http://webgrease.codeplex.com/wikipage?title=WebGrease%20configuration%20file).

  1. Install System.Web.StaticOptimization package from Nuget (if you have probs, here is the help).
  2. Add reference to System.Web.StaticOptimization.dll, System.Web.StaticOptimization.Mvc.dll (will be automated later in special NuGet package for ASP.NET MVC developers)
  3. Add following initialization code in Global.asax.cs:
        protected void Application_Start()
  1. Edit bundles.config file by describing your JS and CSS bundles.
  2. Fasten the belts and press F6 (rebuild) ;).

How it works? The package adds MSBuild post build tasks in your csproj. Simple and Easy. Have problems? Check out my demos.

How to use HTML preprocessing

For example, we have {filename}.template.html for template files and we want to get {filename}.html preprocessed:


<!DOCTYPE html>
<html ng-app="homepage">
    <div class="container-fluid">
        <div ng-view jq-show-effect="!(isLoading || isError)"></div>


<?xml version="1.0" encoding="utf-8"?>
  <CssFileSet name="~/Content/css/common.css">
    <!--+ over 9000 styles
  <JsFileSet name="~/bundles/common.js">
    <!-- + 100500 scripts

We expect to generate index.html with substitution of JS, CSS bundles and html templates.

Let we write in csproj or your external MSBuild file:

  <!--Task import-->
  <UsingTask AssemblyFile="$(StaticOptimizationLib)" TaskName="System.Web.StaticOptimization.HtmlMinifierTask" />
  <Target Name="AfterBuild">
      <!--output HTML replace rules goes here. This example means that it will create
      the output file with the same name as input, but with replaced '.template.html'
      occurrence to '.html'. E.g.: index.template.html -> index.html -->
      <OutputFileNameReplaceRule Include=".template.html">
    <!-- Process all *template.html files with concrete bundles config and using release mode for rendering of bundles-->
    <HtmlPreprocessingTask OutputFileNameReplaceRules="@(OutputFileNameReplaceRule)" InputFile="*template.html" BundleConfig="$(BundleConfig)" IsRelease="True" />
    <!--Here you can place html minificator (template.html is ignored by default -->
    <!--<HtmlMinifierTask InputDir="$(MSBuildProjectDirectory)" />-->

Press F6;)


  1. Prepare demo for SPA (using HTML preprocessing engine)
  2. Automate Global.asax generation
  3. Detailed documentation for extra input params of each task