Order cheap dedicated servers in USA.

Packer for .NET 4.1 Released

March 1st, 2009

Packer for .NET has been updated to version 4.1. A major new addition is a new MSBuild task called UpdateWebConfig which makes it easier to prepared your web.config file during deployment. There is also the new Combine mode.

Note: Version 4.1.1 has been released with a fix to the targets file.

Breaking Change

With this release the Utility class has been renamed FileProcessor. If you are coding against the assembly you will need to change Utility to FileProcessor.

Combine Mode

Sometimes you may want to simply combine multiple files together without running the JSMin or CSSMin modes. You may like to spread our CSS across multiple files so they are easier to organize and allow multiple developers to access concurrently. The Combine mode will allow you to combine these files into one either during the build and deployment process or even at runtime if you choose. In the 4.0.3 release I added features to make it possible to push out your files in this way.

UpdateWebConfig

I automate as much as I can on a project. One of the most critical changes during deployment is updating the configuration file. To do this I make use of web site projects along with the web deployment project. This process creates a pre-compiled web site which is ready for deployment and while it does have a feature to replace sections of the configuration file, it needs to be more targeted.

A setting that we all have to change is the debug mode which is true during development but should always be false in production. To change this setting with the web deployment projects you must replace the compilation element for that one attribute which means replacing the list of assemblies which are often updated without notice by Visual Studio during development. I find it is dangerous to blindly replace this whole section, so I have been using the XmlUpdate task included with the MSBuild Community Tasks. That task allows you to use an XPath value to target updates to attributes or any node an XPath can reference.

The problem with using XmlUpdate is that it adds a lot to your MSBuild script which is hard to read and maintain. The UpdateWebConfig task allows you to set the values that you would commonly change like the appSettings, debug mode, compilation errors mode, mail host and the configSource value on the connectionStrings element. With a very easy to read MSBuild script I can now set the right values so that when the files are copied to the staging server I can simply click a button in Visual Studio and within minutes (or seconds) the site will be built, configured and copied to the staging server, ready for testing. With the latest site that I am developing this happens in under 20 seconds.

Below is a sample of the new UpdateWebConfig task.

5 Responses to “Packer for .NET 4.1 Released”

  1. DotNetShoutout Says:

    Packer for .NET 4.1 Released - Brennan’s Blog...

    Thank you for submitting this cool story - Trackback from DotNetShoutout...

  2. Miguel Moura Says:

    Hello,

    Every time I try to download this version I get asked for a password and username. Any idea why?

    I am only able to download the previous versions. What should I do?

    Thanks,
    Miguel

  3. Brennan Stehling Says:

    Miguel,

    I found that this one file did not have the right permissions. You can now download it without any problems.

  4. Miguel Moura Says:

    Hi Brennan,

    Thank You. I downloaded the file and I started using but I am having some problems. I have the following:

    Basically I would like to:
    1. All JQueryPlugins scripts should be minified and merged in one single file in OutputFolder\Scripts\JQuery.Plugins.js
    2. All ControllersScritps should be only minified and placed in OutputFolder\Scripts
    3. All CssStyles files should be only minified and placed in OutputFolder\Styles

    How can I do this?

    I have been trying but I always get, for example, for CSS files an empty file with some comments inserted by your code.

    Thank You,
    Miguel

  5. Chris Lienert Says:

    Miguel: How are you trying to do this now?
    I could show how I minify and compress my scripts and CSS but Packer for .NET can be used in a number of different ways so some more details would be useful.