1 / 19

Continuous Testing of PowerShell Scripts with Visual Studio

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

nikki
Download Presentation

Continuous Testing of PowerShell Scripts with Visual Studio

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Continuous Testing of PowerShell Scripts with Visual Studio Alex Randall Senior Consultant http://blogs.msdn.com/b/alex_randall

  2. Continuous Testing of PowerShell Scripts with Visual Studio Agenda SharePoint 2013 Preview Visual Studio 2012 Deploying SharePoint solutions to production farms Anatomy of a sample SharePoint PowerShell deploy script Integrating a SharePoint PowerShell deploy script into Visual Studio How to create your own SharePoint PowerShell deploy scripts

  3. SharePoint 2013 Preview Office 365 SharePoint Server 2013 Preview Will this Visual Studio/PowerShell technique apply to SharePoint Preview? Yes! (However, for this session, I will focus on SharePoint 2010 for demos) http://dev.office.com SharePoint Server 2013 Preview http://technet.microsoft.com/en-us/sharepoint/fp142366 SharePoint Foundation 2013 Preview

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

  5. What we just saw… Integrated automatic F5 deploy functionality Lots going on behind the scenes during deploy Deactivating features Uninstalling features Retracting the solution Uninstalling the solution Installing the solution Deploying the solution Installing features Activating features

  6. Deploying to farms – who? Developer does deploy Potential to “take down the farm” for several seconds if farm based solution Potential to cause conflicts with other deploying, testing, or demos going on, etc. Visual Studio SharePoint Farm • SharePoint Administrator does deploy • More control, however, deploying custom solutions to farms is just 1% of their job • Takes time for them to do it • Developer has to document the deploy process for them I’m done! I’m ready to have this installed on the _________ farm

  7. Deploying to farms – How? SharePoint Production Farm For one farm Install options: 1) manually through the UI (very time consuming!) (room for human error) 2) PowerShell (one click!) 3) other ways… Visual Studio SharePoint Testing Farm I’m done! I’m ready to have this installed on the _________ farm SharePoint Development Farm • For multiple farms • Repeat steps above • *Production farms need special care

  8. PowerShell Deploy Advantages Frees SharePoint Administrators up To focus on real issues such as helpdesk issues, farm stability, reliability, performance, maintenance, as well as planning for future service offerings. Consistent Deploy Experience Lessens possibility of human error across farms Full control of what gets deployed and where Imagine a complex deployment across 45 site collections and 200 subsites each… If developer writes scripts, they have intimate knowledge of their own solution

  9. Anatomy of a deploy script Deactivate features Uninstall features Retract the solution Uninstall the solution Install the solution Deploy the solution Install features Activate features

  10. Let’s see it in action! DEMO: Sample SharePoint PowerShell Deploy script for a custom SharePoint solution

  11. PowerShell recommended practices Put LOTS of comments in the script Put all variables at the top Ensure script stops immediately if error occurs Ensure proper disposal of all SharePoint disposable objects Ensure you are calling the correct parameters on each SharePoint Cmdlet for your exact scenario Automatically load the SharePoint Cmdlets if they are not present

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

  13. What we just saw… 1) Visual Studio must be run in Administrator Mode 2) In the SharePoint Post Deployment Command: Copy the msbuild file to the bin directory Copy the PowerShell scripts to the bin directory Execute 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

  14. Benefits of Continuous Testing of PowerShell Scripts with Visual Studio Consistency Maintainability Repeatability Robustness

  15. How to create your own scripts Start from a good example Think about your exact deploy scenario Build your script “line by line” in interactive PowerShell Read the documentation for each SharePoint PowerShell Cmdlet to ensure you are using the proper parameters for your deploy scenario Ensure you are following recommend practices

  16. Creating your PowerShell Script DEMO: How to create a SharePoint PowerShell Deploy script

  17. Summary: Continuous Testing of PowerShell Scripts in Visual Studio Everything I showed you is located at: http://blogs.msdn.com/b/alex_randall Why How Recommended Practices

  18. Thanks to our sponsors!

  19. Continuous Testing of PowerShell Scripts with Visual Studio Alex Randall Senior Consultant http://blogs.msdn.com/b/alex_randall

More Related