Blog

Web Deployment Project – Visual Studio 2008 Add-in

10 Feb, 2010
Xebia Background Header Wave

webdeploymentproject

Visual Studio Web Deployment Projects, provide additional functionality to build and deploy Web sites and Web applications in Visual Studio 2008. This Add-In can be downloaded from Microsoft website: Web Deployment Projects

The Visual Studio built-in "Copy Website" and "Publish Website" options are lacking of flexibility. Web Deployment Projects provides additional functionality for example:

  • merging assemblies (from context menu)
  • the ability to create pluggable configuration files (from context menu)
  • exclude files and folders (*.wdproj file in deployment project)

When merging assemblies you can specify to get only 1 result DLL, instead of multiple when using "Publish web site".
Second thing is, that you can define a strong name of result DLL file which means, that it will be easier to updates the web site on the webserver – just replacing the DLL, instead of deleting all assemblies with *.compiled XMLs and copying new ones (can be hundreds). So you don’t have to carry about the "strange" assemblies file names (with the hash code varying) like: App_Web_0375kxso.dll, etc.

Ability to create pluggable configuration files allows you to specify independent files, that store the contents of a particular configuration section independently, based on solution configurations. That means for example, that the Web.config section will include different database connectionString for Debug and Release, or any other user specified solution configuration.

You can also exclude files and folders that shouldn’t be part of the release, e.g: reports, uploaded files, etc.

Finally the *.wdproj configuration file has a MSBuild syntax, so you can specify there whatever you want. Out of the box there are 4 build process sections: BeforeBuild, BeforeMerge, AfterMerge, AfterBuild, where you can specify your tasks.

The detailed description of the Web Deployment Projects can be found HERE.


Find below some of my *.wdproj configuration examples:

Exclude directory:
<ItemGroup>
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)<strong>_svn</strong>" />
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)<strong>.svn</strong>" />
</ItemGroup>

Exclude directory except specified file:
<ItemGroup>
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)ChartImages<strong><em>.</em>" Exclude="$(SourceWebPhysicalPath)ChartImages</strong>place.holder" />
</ItemGroup>

Minimize (shrink) JavaScript files using Microsoft Ajax Minifier (based on Łukasz Gąsior blog):
<Import Project="$(MSBuildExtensionsPath)MicrosoftMicrosoftAjaxAjaxMin.tasks" />
<Target Name="AfterBuild">
<ItemGroup>
<!-- Create the list of JS files to minimize. Exclude *.min.js files, e.g. jquery-xxx.min.js -->
<JsFilesDevelopment Include="$(OutputPath)<strong><em>.js" Exclude="$(OutputPath)</em></strong>.min.js" />
</ItemGroup>
<!-- Minimize the JavaScript using AjaxMin -->
<AjaxMin SourceFiles="@(JsFilesDevelopment)" SourceExtensionPattern=".js$" TargetExtension=".js" LocalRenaming="CrunchAll" />
</Target>


Questions?

Get in touch with us to learn more about the subject and related solutions

Explore related posts