Wednesday 04 January 2012 at 12:30 pm
Always keen that our adopted environment shouldn't dictate tooling it was important that we could achieve a good level integration between with testing tools and Team Foundation Server; however as TFS 2010 moved to using web services and XAML build workflow it can look rather challenging.
Interesting note
The snippets below are based around NUnit testing tool but it could be employed just as easily for others that are able to output their results XML in the same format, xUnit being a fine example.
Looking at integration we identified two essential requirements;
- NUnit-Console test runner executes as part of the build workflow
- Test results are published back into TFS 2010 and statistics
Read More
Sunday 01 January 2012 at 12:01 am
Despite my love for all things DVCS, DAG, and Git it's no secret that there is one area of TFS 2010 that I am quite fond of - Visual Studio Lab Management. Utilising Microsoft Hyper-V technology it allows us to manage and use virtual machines in building, testing, and deploying applications.
One post is not enough to cover this in detail (in fact I suspect a 3-day workshop might be more likely) but one element I was keen to share with you was our deployment script that enables our automated cradle-to-grave testing environment and which sits alongside our CI (Continuous Integration) and automated testing strategy.
Elevation & Execution
To achieve this we needed the workflow capability to deploy and configure an IIS 7 site on a completely fresh and clean deployed environment; importantly one with no prior manual configuration or deployments. As much of the IIS functionality would need elevated privileges this presented a couple of problems;
- How to bypass PS ExecutionPolicy that by Windows installation would default to "Restricted"
- How could we elevate the script once spawned without manual interaction
Read More
Friday 16 December 2011 at 09:18 am
If like me you don't want to have duplicate copies of your bin dependencies between your libraries/packages folder and "/_bin_deployableAssemblies" you'll want to link them; unfortunately the default Microsoft.WebApplication.targets won't publish them - absurd I know!
Through experimentation I've found the most elegant solution is to have have a custom targets files (checked into source control and branched from a common location) that I import into my web projects. It simply overrides one of the targets in Microsoft.WebApplication.targets and copies linked files to a bin sub-folder before adding them to the CreateItem collection that is later used when building/publishing.
CopyLinkedBinDeployableAssemblies.targets
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="_CopyBinDeployableAssemblies" Condition="Exists('$(MSBuildProjectDirectory)\_bin_deployableAssemblies')">
<Copy Condition=" '%(Content.Link)' != '' " SourceFiles="%(Content.Identity)" DestinationFiles="$(MSBuildProjectDirectory)\bin\%(Content.Link)" />
<CreateItem Include="$(MSBuildProjectDirectory)\bin\_bin_deployableAssemblies\**\*.*" Condition="Exists('$(MSBuildProjectDirectory)\bin\_bin_deployableAssemblies')">
<Output ItemName="_binDeployableAssemblies" TaskParameter="Include" />
</CreateItem>
<CreateItem Include="$(MSBuildProjectDirectory)\_bin_deployableAssemblies\**\*.*" Condition="Exists('$(MSBuildProjectDirectory)\_bin_deployableAssemblies')">
<Output ItemName="_binDeployableAssemblies" TaskParameter="Include" />
</CreateItem>
<Copy SourceFiles="@(_binDeployableAssemblies)" DestinationFolder="$(OutDir)\%(RecursiveDir)" SkipUnchangedFiles="true" Retries="$(CopyRetryCount)" RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" />
</Target>
</Project>;
Then in my web .csproj project file add an import link to the new targets file;
<Import Project="$(MSBuildProjectDirectory)\..\..\BuildSupport\Targets\CopyLinkedBinDeployableAssemblies.targets" />
Important! Make sure you put this after the Import to Microsoft.WebApplication.targets.
Finally...
There seems to be a myth that _bin_deployableAssemblies is MVC3 only which of course is utter tosh, this works for any project that uses Microsoft.WebApplication.targets; I know this as we use it in our FubuMVC projects to copy Simple.Data MEF dependencies 