Quantcast
Channel: Brennan's Blog » msbuild
Viewing all articles
Browse latest Browse all 10

Packer for .NET 4.0.3 Released

$
0
0

Packer for .NET has been updated to provide an easy way to return the minified content directly for a web request. Until now the process of "minifying" content was done either on the command-line or with with MSBuild.

The task of creating the compacted content can easily be forgotten during a deployment. And when the source control system locks the output files which are updated with the build script there can be trouble in both writing out the files as well as keeping the files current in source control. So instead of referencing the generate file it would be useful to reference the source files dynamically. Read on for an example.

First SiteUtility.cs defines a property that is a collection of the all of the scripts that a web page would reference. The RegisterJavaScript method will register script references with a ScriptManager control. Then ScriptsHandler.ashx uses the same list of scripts to dynamically generate the compacted content. Anytime the list of scripts is updated the change will take affect for both the RegisterJavaScript method as well as the handler.

Another feature of the SiteUtility class is the debug mode switching. If you are working in debug mode the scripts will be referenced directly. When the web site is deployed the debug mode can be disabled which will use the ScriptHandler.ashx to output the scripts as a single compacted reference.

App_Code/SiteUtility.cs

ScriptsHandler.ashx


Viewing all articles
Browse latest Browse all 10

Trending Articles