Publish a website application using MSBuild

MSBuild is soooo nice when it comes to automating compilation, testing, deployment or some other tedious task.

Until now, I believed that publishing a website application was a manual task, performed from Visual Studio.

But it is actually possible to perform publishing from the command line. Take a look at this Build.xml file:

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
  <PropertyGroup>
 
    <OutputFolder>$(MSBuildProjectDirectory)\..\Published\</OutputFolder>
 
    <LibDir>..\Lib\</LibDir>
 
  </PropertyGroup>
 
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
  <Import Project="$(LibDir)\msbuild\MSBuild.Community.Tasks.Targets"/>
 
 
  <Target Name="Publish">
    <RemoveDir Directories="$(OutputFolder)"
               ContinueOnError="true" />
    
    <MSBuild Projects="..\Core\bmv3.org.oxweb.csproj"
             Targets="ResolveReferences; _CopyWebApplication"
             Properties="WebProjectOutputDir=$(OutputFolder); OutDir=$(WebProjectOutputDir)\" />
  </Target>
 
</Project>

 

If you want to read more about using MSBuild, then take a look at this tutorial:

http://codingcockerel.co.uk/2008/04/15/automating-the-build-with-msbuild/

Are you interested in reading more about the publishing using MSBuild, then read here:

http://codingcockerel.co.uk/2008/05/18/how-to-publish-a-web-site-with-msbuild/

http://blog.m.jedynak.pl/2008/03/publishing-web-application-with-msbuild.html

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>