continuous testing of powershell scripts with visual studio

19
Continuous Testing of PowerShell Scripts with Visual Studio Alex Rand Senior Consult http://blogs.msdn.com/b/alex_rand

Upload: nikki

Post on 22-Feb-2016

83 views

Category:

Documents


0 download

DESCRIPTION

Continuous Testing of PowerShell Scripts with Visual Studio. Alex Randall Senior Consultant http://blogs.msdn.com/b/alex_randall. Continuous Testing of PowerShell Scripts with Visual Studio. Agenda SharePoint 2013 Preview Visual Studio 2012 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Continuous Testing of PowerShell Scripts with Visual Studio

Continuous Testing of PowerShell Scripts with Visual Studio

Alex RandallSenior Consultant

http://blogs.msdn.com/b/alex_randall

Page 2: Continuous Testing of PowerShell Scripts with Visual Studio

Continuous Testing of PowerShell Scripts with Visual StudioAgendaSharePoint 2013 PreviewVisual Studio 2012Deploying SharePoint solutions to production farmsAnatomy of a sample SharePoint PowerShell deploy scriptIntegrating a SharePoint PowerShell deploy script into Visual StudioHow to create your own SharePoint PowerShell deploy scripts

Page 3: Continuous Testing of PowerShell Scripts with Visual Studio

SharePoint 2013 PreviewWill this Visual Studio/PowerShell technique apply to SharePoint Preview?Yes!

(However, for this session, I will focus on SharePoint 2010 for demos)

SharePoint Foundation

2013 Preview

SharePoint Server 2013

Preview

Office 365 SharePoint

Server 2013 Preview

http://dev.office.com

http://technet.microsoft.com/en-us/sharepoint/fp142366

Page 4: Continuous Testing of PowerShell Scripts with Visual Studio

Let’s just jump right in to Visual Studio 2012! (DEMO!)

Visual Studio 2012

Page 5: Continuous Testing of PowerShell Scripts with Visual Studio

What we just saw…

Lots going on behind the scenes during deployDeactivating featuresUninstalling featuresRetracting the solutionUninstalling the solutionInstalling the solutionDeploying the solutionInstalling featuresActivating features

Integrated automatic F5 deploy functionality

Page 6: Continuous Testing of PowerShell Scripts with Visual Studio

Deploying to farms – who?

Visual StudioSharePoint

FarmI’m done! I’m ready to have this installed on the _________ farm

Developer does deployPotential to “take down the farm” for several seconds if farm based solutionPotential to cause conflicts with other deploying, testing, or demos going on, etc.SharePoint Administrator does deployMore control, however, deploying custom solutions to farms is just 1% of their jobTakes time for them to do itDeveloper has to document the deploy process for them

Page 7: Continuous Testing of PowerShell Scripts with Visual Studio

Deploying to farms – How?

Visual Studio

SharePoint Development

Farm

SharePoint Testing Farm

SharePoint Production

Farm

I’m done! I’m ready to have this installed on the _________ farm

For one farmInstall options:

1) manually through the UI(very time consuming!)(room for human error)

2) PowerShell(one click!)

3) other ways…

For multiple farmsRepeat steps above*Production farms need special care

Page 8: Continuous Testing of PowerShell Scripts with Visual Studio

PowerShell Deploy AdvantagesFrees SharePoint Administrators upTo focus on real issues such as helpdesk issues, farm stability, reliability, performance, maintenance, as well as planning for future service offerings.

Consistent Deploy ExperienceLessens possibility of human error across farms

Full control of what gets deployed and whereImagine a complex deployment across 45 site collections and 200 subsites each…

If developer writes scripts, they have intimate knowledge of their own solution

Page 9: Continuous Testing of PowerShell Scripts with Visual Studio

Anatomy of a deploy scriptDeactivate featuresUninstall featuresRetract the solutionUninstall the solutionInstall the solutionDeploy the solutionInstall featuresActivate features

Page 10: Continuous Testing of PowerShell Scripts with Visual Studio

Let’s see it in action!

DEMO: Sample SharePoint PowerShell Deploy script for a custom SharePoint solution

Page 11: Continuous Testing of PowerShell Scripts with Visual Studio

PowerShell recommended practicesPut LOTS of comments in the scriptPut all variables at the topEnsure script stops immediately if error occursEnsure proper disposal of all SharePoint disposable objectsEnsure you are calling the correct parameters on each SharePoint Cmdlet for your exact scenarioAutomatically load the SharePoint Cmdlets if they are not present

Page 12: Continuous Testing of PowerShell Scripts with Visual Studio

Integrating into Visual Studio!

DEMO: How to do the real magic! Continuous testing of PowerShell Scripts with Visual Studio!

Page 13: Continuous Testing of PowerShell Scripts with Visual Studio

What we just saw…1) Visual Studio must be run in Administrator Mode2) In the SharePoint Post Deployment Command:Copy the msbuild file to the bin directoryCopy the PowerShell scripts to the bin directoryExecute msbuild in 64 bit mode to run PowerShell in 64 bit mode and load the script

3) Create a SharePoint deployment option to only run the Post Deployment command

Not clear on these steps? No problem! I’ve documented them here with screenshots: http://blogs.msdn.com/b/alex_randall

Page 14: Continuous Testing of PowerShell Scripts with Visual Studio

Benefits of Continuous Testing of PowerShell Scripts with Visual Studio

RepeatabilityMaintainabilityConsistency Robustness

Page 15: Continuous Testing of PowerShell Scripts with Visual Studio

How to create your own scripts1) Start from a good example2) Think about your exact deploy scenario3) Build your script “line by line” in

interactive PowerShell3) Read the documentation for each

SharePoint PowerShell Cmdlet to ensure you are using the proper parameters for your deploy scenario

4) Ensure you are following recommend practices

Page 16: Continuous Testing of PowerShell Scripts with Visual Studio

Creating your PowerShell Script

DEMO: How to create a SharePoint PowerShell Deploy script

Page 17: Continuous Testing of PowerShell Scripts with Visual Studio

Summary: Continuous Testing of PowerShell Scripts in Visual Studio

Why Recommended PracticesHow

Everything I showed you is located at: http://blogs.msdn.com/b/alex_randall

Page 18: Continuous Testing of PowerShell Scripts with Visual Studio

Thanks to our sponsors!

Page 19: Continuous Testing of PowerShell Scripts with Visual Studio

Continuous Testing of PowerShell Scripts with Visual Studio

Alex RandallSenior Consultant

http://blogs.msdn.com/b/alex_randall