Skip to content Skip to sidebar Skip to footer

Javascript Minifier (e.g. Yui) Integrated To Asp.net Webdeploy Publish

I have a javascript file that I minify using the Yahoo YUI. When I 'Publish' the web application project, I want it to only copy the .min.js file and not the original one too. I ca

Solution 1:

You can use MSBuild Community Task project and the Exec task to do this. Here is an example.

<?xml version="1.0" encoding="utf-8"?><ProjectDefaultTargets="Build"xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><yuiCompressor>java -jar Libraries\yuicompressor-2.3.6.jar</yuiCompressor></PropertyGroup><PropertyGroup><Major>1</Major><Minor>0</Minor><Build>0</Build><Revision>1</Revision><BindMinor>0</BindMinor><BindBuild>0</BindBuild><BindRevision>0</BindRevision></PropertyGroup><ItemGroup><CssFilesInclude="css\site.css" /><CssFilesInclude="css\gray.css" /><JsFilesInclude="scripts\base.js" /><JsFilesInclude="scripts\lib.js" /><JsFilesInclude="scripts\project.js" /></ItemGroup><TargetName="Minimize"DependsOnTargets="Version"><!-- CSS Merge and Minimize --><MergeMode="TextLine"SourceFiles="@(CssFiles)"DestinationFile="merged.css" /><ExecCommand="$(yuiCompressor) --type css merged.css -o css\project-$(Revision).css" /><!-- js Merge and Minimize --><MergeMode="TextLine"SourceFiles="@(JsFiles)"DestinationFile="merged.js" /><ExecCommand="$(yuiCompressor) --type js merged.js -o scripts\project-$(Revision).js" /><DeleteFiles="merged.css" /><DeleteFiles="merged.js" /></Target></Project>

Solution 2:

If it's a web application (and not a web site), just change the Build Action to None in the properties window. This will prevent the original file from being copied when the app is published.

Post a Comment for "Javascript Minifier (e.g. Yui) Integrated To Asp.net Webdeploy Publish"