After googling for some time, i finally found the perfect solution to minify css stylesheets and javascripts .js files.
I wanted to automaticaly compress releases files when building my websites, using web deployment projects...

The solution uses the Yahoo YUI Compressor, especially the compressor for .NET release,
(see the sample web deployment project solutions in the other downloads available !)

to put it into work, edit the web deployment project as following:

add a reference to the YUI Compressor on top of your project file:

<UsingTask TaskName="CompressorTask" AssemblyFile="..\{path to the YUI Compressor}\Yahoo.Yui.Compressor.dll" />

Then add an item group to select the input css & js files, and a compressor task in the After merge event

<Target Name="AfterMerge">

<ItemGroup>
<
CssFiles Include="$(TempBuildDir)App_Themes\**\*.css;$(TempBuildDir)CSS\*.css" />
<
JavaScriptFiles Include="$(TempBuildDir)\JavaScript\*.js" />
</
ItemGroup>

<CompressorTask
CssFiles="@(CssFiles)"
DeleteCssFiles="No"
CssOutputFile="%(rootdir)%(directory)%(Filename)%(extension)"
CssCompressionType="YuiStockCompression"
JavaScriptFiles="@(JavaScriptFiles)"
ObfuscateJavaScript="FoSho"
PreserveAllSemicolons="Yeah"
DisableOptimizations="Nope"
EncodingType="Default"
DeleteJavaScriptFiles="No"
JavaScriptOutputFile="%(rootdir)%(directory)%(Filename)%(extension)"
LoggingType="ALittleBit" />

</Target>

 

More information about the MSBuild selectors, commands, ...: http://msdn.microsoft.com/en-us/library/ms171452(VS.80).aspx