38
Eliminate Team Build Headaches with Unit Tests, WiX and Virtualization Benjamin Day http://benday.com

Eliminate Team Build Headaches with Unit Tests, WiX and Virtualization

  • Upload
    hisoki

  • View
    19

  • Download
    0

Embed Size (px)

DESCRIPTION

Eliminate Team Build Headaches with Unit Tests, WiX and Virtualization. Benjamin Day http://benday.com. Who am I?. Owner, Benjamin Day Consulting, Inc. Email: [email protected] Web: http://www.benday.com Blog: http://blog.benday.com Trainer, Consultant - PowerPoint PPT Presentation

Citation preview

Page 1: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Eliminate Team Build Headaches with Unit Tests, WiX and VirtualizationBenjamin Dayhttp://benday.com

Page 2: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Who am I?

Owner, Benjamin Day Consulting, Inc.– Email: [email protected]– Web: http://www.benday.com– Blog: http://blog.benday.com

Trainer, Consultant– Visual Studio Team System, Team Foundation Server

Microsoft MVP for VSTS Microsoft VSTS/TFS Customer Advisory Council Microsoft Cloud Services Advisory Group Leader of Beantown.NET INETA User Group

Page 3: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Goals

Build, Test, and Deploy Your App The Application

– Test Driven Development / Unit Tests– ASP.NET– WCF hosted in IIS

Page 4: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Why automated builds?

Repeatability Did I mention repeatability? Eliminate the “works on my box”

problem

Page 5: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Demo 1

Tour of the app Add it to TFS source control

Page 6: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Why Continuous Integration?

Eliminate painful integration Catch bugs early (Theoretically) ship immediately Code always builds Tests always pass

Page 7: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Demo 2

Create the Team Build Run the tests from the build Configure Continuous Integration Run the build

Page 8: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

3rd Party MSBuild Tasks

Saves you time/effort Free MSBuild Community Tasks

– http://msbuildtasks.tigris.org/– IIS Configuration tasks

SDC Tasks– http://www.codeplex.com/sdctasks – Microsoft Virtual Server 2005 R2 tasks

Page 9: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Build is failing

IIS isn’t configured Best practice: delete and recreate IIS

virtual directories Ensures…

– …a clean environment– …you’re testing the right version– …you know how to configure your app

Page 10: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Demo 3

Configure IIS in the BeforeTest target

Page 11: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

KICKING IT OVER THE WALL

Page 12: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Move code between environments

How would you get the current version to QA?

QA can’t test against continuous integration– Needs a stable code base version to test

against

Page 13: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

QA Test Environment

Use Virtual Machines– Cheap– Hyper-V or Virtual Server 2005 R2

Create template machines with SysPrep.exe

Configure the machines then Enable Undo Disks– Easy rollback to completely clean, known state– Fresh state you know how to config your app

Page 14: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

How do you get the code to QA?

Need a good way to get it there Need a good way to configure it Worst-practice: humans configure the

app Best-practice: automated configuration

– Automatic deploy, config = great documentation

Create an MSI installer using WiX

Page 15: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

WIX

Page 16: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

What does an installer do for you?

Install & Uninstall Registry keys Folder paths COM registration Update logic Program menu shortcuts

Way too hard for a non-technical user Non-repeatable without an automated

installer

Page 17: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

What is WiX?

Windows Installer Xml Xml to describe Windows Installer MSI’s Developed by Microsoft

– Around 1999 Released to Open Source in April 2004 Mostly written by Rob Mensching

– http://robmensching.com/ http://wix.sourceforge.net/

Page 18: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

WiX is not dead

Sourceforge site has spotty updates Weekly drops are still getting made

http://wix.sourceforge.net/releases/ Visual Studio setup is written in WiX WiX will be included as a project type in

VS2010

Page 19: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

How do you get started?

Go to http://wix.sourceforge.net/releases/

Download & install the latest 3.0.* release

Page 20: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

WiX Projects in Visual Studio “Votive”

Page 21: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Votive Projects

Allow you to add, edit Intellisense Compiler support Defines variables to reference

solution/project paths Source control

Page 22: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Votive Project Types

WiX Project– Generates *.msi

WiX Merge Module– Installer referenced from another installer– Generates *.msm

WiX Library Project– Re-usable pieces of WiX

WiX Custom Action– Extend the installer logic

Page 23: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Other tools that comes with WiX

Heat.exe– Jump starts WiX creation

Candle.exe– WiX Compiler

Light.exe– WiX Linker

Dark.exe– Decompiler

Smoke.exe– Validator

Page 24: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Basic WiX Elements

<Wix> - Root element w/ Namespaces <Product> - What you’re installing <Directory>, <File> <Feature>, <Component> <UI>, <Dialog> <Fragment> <Property> “Refs”

Page 25: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Defining the user interface

<UI>– Defines user interface features

<UIRef Id=“ui_name”>– Reference a UI

WixUIExtension.dll– Pre-defined UI Sequences– WixUI_Mondo, WixUI_Advanced,

WixUI_FeatureTree, WixUI_InstallDir, WixUI_Minimal

Decent documentation at http://www.wixwiki.com

Page 26: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Installing Web Apps

Use heat.exe to start– HINT: don’t bother with the “website” option

Edit the directory references Add reference to WixIisExtension.dll Point <iis:WebVirtualDir> Set <iis:WebApplication>

Page 27: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Tips for Deploying Web Apps

Put each app in a separate wxs file– IIS Service Host– Web UI– Admin Web UI

During Dev/QA, use WiX to simplify deployment of releases– Generate and build WiX during TFS Team Build– Use <Target Name=“AfterCompile”> or

<Target Name=“PackageBinaries”>

Page 28: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Best Practice

Set Id=“*”– Auto generates a new id on compile

Never change your upgrade code

Page 29: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Demo 4

Create the WiX Installer Install the app Configure IIS Run the build MSI

Page 30: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

MSIExec From the Command Line

Msiexec installer.msi– /i – install– /u – uninstall– /L filename – specify a log file– /qn – silent

Pass parameters in using– MY_PARAMETER=value

Control feature installation – ADDLOCAL=ProductFeature,ProductFeature2

Page 31: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

A MORE COMPLEX ENVIRONMENT

Page 32: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Deploying to other machines

What if you need to deploy to other machines in order to test?

Deploy the WCF service to another box before running tests

Environment specific configurations in the WiX

Page 33: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Fancy.

Compile Create the installer Start virtual machines from Team Build Copy the installer to the VMs Run the installer Run tests against the running WCF app Tear down the VMs

Page 34: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Control VMs from Team Build

Start / Stop Virtual Server 2005 R2 machines

Use the SDC Taskshttp://www.codeplex.com/sdctasks

Page 35: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

The VirtualMachine Tasks

<Import Project="$(MSBuildExtensionsPath)\SDCTasks\Microsoft.Sdc.Common.tasks" />

<VirtualServer.VirtualMachine.Start ServerName=“virtualServerName"

MachineName=“virtualMachineName" Timeout="20“ />

<VirtualServer.VirtualMachine.Stop … >

Page 36: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Demo 5

Start a virtual machine Wait for it to start Copy the MSI Install the MSI Run the tests Stop the virtual machine

Page 37: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Summary

Running app with unit tests App compiled by Team Build Team Build configures the app WiX to create the installer Installer from the build that we can

hand off to QA Start virtual machines Copy / Run installer Run tests using the VM

Page 38: Eliminate Team Build Headaches with Unit Tests,  WiX  and Virtualization

Who am I?

Owner, Benjamin Day Consulting, Inc.– Email: [email protected]– Web: http://www.benday.com– Blog: http://blog.benday.com

Trainer, Consultant– Visual Studio Team System, Team Foundation Server

Microsoft MVP for VSTS Microsoft VSTS/TFS Customer Advisory Council Microsoft Cloud Services Advisory Group Leader of Beantown.NET INETA User Group