CI Builds for WCF/ASP.Net apps using MSBuild

Written by Troy on July 11, 2012 Categories: Uncategorized Tags: , , , , , , , , , , , ,

MSBuild can be a bit of a bear, and having a build procedure around .Net web apps has never been neat or easy. Apparently hotmail and bing are deployed by some guy at Microsoft clicking on the ‘publish’ button in Visual Studio. But for those of us creating mission critical web apps, this is not the thing to do (to quote Green Velvet).

We use a set of centralized imports in all our projects to standardize the behaviour of all builds with a minimum of fuss. These excerpts are the hacks you can use to get your build server churning out your web apps. You may need to work with the order in your *proj file since some of the default msbuild targets will override some properties (WebProjectOutputDir for instance.)

<Project xmlns="">

<!-- ... -->

	<!-- path where you want your builds -->

	<!-- Can be a handy property, here we use it to name our output path -->
	<ProjectFolderName>$( [System.Text.RegularExpressions.Regex]::Match( $(MSBuildProjectDirectory), "[^\\]+$").Value )</ProjectFolderName>

	<!-- Makes our scripts a little neater, you will find this GUID in your web app csproj -->

<!-- Properties we set/override if it's a web project.  Notice the condition? -->
<PropertyGroup Condition="$(ProjectTypeGuids.Contains($(WebProjectGuid)))">
	<!-- Just for our use, not used by any standard msbuild targets -->

	<!-- Content gets copied here by _WPPCopyWebApplication with transforms, etc -->

	<!-- This is where assemblies end up for a csproj -->

<!-- ... -->

<!-- This target does nothing, but causes the '_WPPCopyWebApplication' to get invoked after
the build target, neatly putting our web project in our build folder, yay! -->
<Target Name="PostWebBuildContentCopy" AfterTargets="Build"

<!-- ... -->

Now, invoking msbuild (or msbuild /t:build if ‘build’ is not your default) will cause your assemblies to get built to c:\build\foo\bar\web\WcfAppName\bin and then appropriate web files placed in c:\build\foo\bar\web\WcfAppName

Handy link:

No Comments

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>