Friday 31 May 2013

Automation is Your Friend

Whats the biggest source of bugs/issues in developing/deploying applications? People.

My high-school computer studies teacher once said "Computers don't make mistakes, people do" and this is incredibly accurate. How many times have you heard of:

  • a build getting rejected in UAT because a developer didn't manually test all paths through the application related to their change
  • an issue slipping through regression testing and goes to production, because there were too many manual tests cases to run for every deployment
  • an issue occurring on a website because a file was missed as part of a manual deployment
I think you get the idea, doing repetitive tasks manually is both time consuming and prone to human error. I'm not saying that automating things will solve all of your problems, but it can certainly solve some.

Because automation can provide so many benefits, but can be a bit daunting to start out I have decided to collate a bunch of resources to help point you in the right direction, I will also keep updating this article over time.


Creating a Site in IIS Using PowerShell

So I have been doing a lot of work around build automation and continuous deployment lately and I thought I would do a quick post about setting up new website and application pool in IIS. I use this quite a bit in my daily work life, I use for creating development environments, test environments even remote production environments.

So firstly lets look at creating a new site and application pool:

 #Import the IIS Web Administration module
 Import-Module WebAdministration
 function AddSite($hostname, $siteRoot){
  #Check if the application pool already exists
  if (!(Test-Path "iis:\AppPools\$hostname")) {
   New-Item "iis:\AppPools\$hostname"
  }

  $NewPool = Get-Item "iis:\AppPools\$hostname"
  
  #Set the application pool's account to NETWORK SERVICE
  $NewPool.ProcessModel.IdentityType = 2
  $NewPool | Set-Item

  #Set the application pool to .NET 4
  Set-ItemProperty "IIS:\AppPools\$hostname" managedRuntimeVersion v4.0

  #Check the site exists
  if (!(Test-Path "iis:\Sites\$hostname")) {
         #Create the site and bind it to the hostname, port and folder on disk
         New-Item "iis:\Sites\$hostname" -bindings @{protocol="http";bindingInformation=":80:$hostname"} -physicalPath "$siteRoot"
  }

     #Set the site's application ppol<
     Set-ItemProperty "iis:\Sites\$hostname" -name applicationPool -value $hostname
 }

And secondly lets look at removing the site and application pool:

function RemoveSite($hostname){
    if (Test-Path "iis:\Sites\$hostname") {
        #Remove the site
        Remove-Item "iis:\Sites\$hostname" -recurse
    }

    if (Test-Path "iis:\AppPools\$hostname") {
        #Remove the application pool
        Remove-Item "iis:\AppPools\$hostname" -recurse
    }
}


Wednesday 8 May 2013

Sitecore 7 : Shooting for the Sky 100% Unit Test Coverage with Sitecore 7 & MVC

A little while ago I was asked by the company I work for (Next Digital) to write a post for the corporate blog. I decided that given I had just received early access to Sitecore 7 and that I have a thing for test driven development, that I would try and test drive an implementation in Sitecore 7 and see what sort of coverage I could get with the new features.

Below is the introduction for the post, to see the full article go here.

So I’m one of the lucky MVP’s who get early access to Sitecore 7 and I decided that for my proof of concept I would try to  completely test drive my implementation and see if I couldn't get to 100% unit test coverage.

Now some of you are going to be interested in the MVC side of things and that is great, just start reading. For those of you that are only interested in the Sitecore 7 stuff, jump straight to the Repository Layer of this post.

Again here is the link to the full post http://www.nextdigital.com/voice/shooting-for-the-sky

How to disable "Add Users" in Sitecore's Platform DXP

 I have seen a few posts going around the community asking how to disable the "Add Users" button in Sitecore Platform DXP.   This ...