1 / 0

Best Practices Deploying SharePoint 2010 Solutions

Best Practices Deploying SharePoint 2010 Solutions. Solutions, Power Shell and the SharePoint 2010 Management Console. Presented to the Puget Sound SharePoint Users Group February 17, 2011 Presented by Martin Cox, Principal Consultant Martin.Cox@Neudesic.com 425-945-1818.

bandele
Télécharger la présentation

Best Practices Deploying SharePoint 2010 Solutions

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. Best Practices Deploying SharePoint 2010 Solutions

    Solutions, Power Shell and the SharePoint 2010 Management Console Presented to the Puget Sound SharePoint Users GroupFebruary 17, 2011 Presented by Martin Cox, Principal Consultant Martin.Cox@Neudesic.com 425-945-1818
  2. SharePoint Solutions can get complex BCS WFE ASP Sandboxed WSP Client OM Content Types Web Parts Silverlight Site Def CSS App Pool Workflow FAST Forms LINQ Ribbon Features Service Apps Performance Point REST CAML
  3. You Have Enough to Worry About. You are Building a SharePoint Solution… Don’t let Deployment Slow You Down!
  4. Best Practices Recognize where you Project falls on the Tooling/Complexity Matrix Streamline the process for setup, deployment and configuration of your solution Maintain your Deployment Process just like your code, and follow your process consistently At least on Test, Staging and Production Use PowerShell to Automate Solution Deployment Configuration Steps Creation of Test Data and Test Accounts
  5. Recognize where you Project falls on the Tooling/Complexity Matrix
  6. The Tooling/Complexity Matrix
  7. Use PowerShell to Automate + Streamline Deployment
  8. Sample Solution: BMP.AMC Visual Studio 2010 Sample Project BMP Asset Management Compliance Project Name = Bmp.Amc Project Includes Two Solutions Bmp.Amc.Foundation = Field Items and other prerequisites common to multiple solutions Bmp.Amc.WebSite = Content Types, Lists, Libraries and everything else that goes into the Application Deploying the Bmp.Amc.WebSite Requires prerequisites from deploying Bmp.Amc.Foundation The Foundation Solution may include prerequisite for other solutions, e.g. Bmp.Fsc.Extranet
  9. Solution Best Practices Fewer, Bigger Solutions are easier to deploy than multiple, smaller solutions Keep All-in-One Solution (= One WSP) unless you need the flexibility e.g. Foundation WSP includes prerequisites for multiple, separate applications Use Solution Naming Conventions like <Company>.<Project>.<Thing> Collates solutions and assemblies together Note you can punctuate project names Use Short Names (Acronyms, TLAs) Helps you distinguish your solutions in the output of Get-SpSolution Helps avoid windows-file-path-too-long Avoid namespace nightmares like, FederalAviationAdministration.EffectiveComputingInitiative.SharePoint.EmployeeCompensationReviewProcess.ContentTypes.EmployeeIdentifier
  10. Sample Solution Deployment Considerations Sample Project Includes Two Solutions Bmp.Amc.Foundation.WSP Field Items Site Definitions Other Foundational Features Bmp.Amc.WebSite.WSP Content Types List, Library Templates Web Parts, Workflows Everything else Deploying WebSite.WSP requires creating a Site Collection if it does not already exist This is what PowerShell was made for
  11. Why You Need a Scripted, Consistent Deployment Process “But I just press F5” “I have my own way…” “It works on my machine…”
  12. Why You Need a Scripted, Consistent Deployment Process If you have more than one developer… If you have more than one farm… If you need predictability…then you need a script
  13. What is PowerShell ? A command-line shell and scripting language Designed especially for system administrators all Microsoft systems Windows Server Exchange Server SQL Server SharePoint IIS Built on .NET Framework “Welcome to your new IDE!” “Notepad and the command prompt.”
  14. How to Get Started Using PowerShell Learn PowerShell for SharePoint developers by studying Windows PowerShell Boot Camp for SharePoint Professionals Found in chapter 1 of the new book, Inside Microsoft SharePoint 2010 By Ted Pattison, Andrew Connell, and Scot Hillier Book not yet generally available but chapters 1 - 4 are on MSDN: http://msdn.microsoft.com/en-us/library/ff742316.aspx
  15. Power Shell Interactive Open a Windows PowerShell console window and you can execute commands interactively by just typing them in DOS-style (or Unix - style). Just like Unix shells have countless commands, PowerShell has countless cmdlets. Names of cmdlets follow convention Noun-Verb e.g. "Get-SpSolution".
  16. Power Shell Scripting You write PowerShell scripts by writing text files with the .PS1 filename extension. You can then run these scripts by entering their file name in the PowerShell Console window just like a cmdlet. The text inside these scripts is the same commands you can execute interactively at the PowerShell console window.
  17. PowerShell Integrated Scripting Environment (ISE) You can use Notepad to create and edit PowerShell scripts, but it's better to use the Windows PowerShell Integrated Scripting Environment (ISE) which is free and built-in to Windows 7 and Windows Server 2008 and W2K8R2. However, you have to install it.
  18. How To Install Windows PowerShell ISE on Win2K8R2: Windows Server 2008 R2 --> Server Manager --> Features --> Add Features --> Select Windows PowerShell Integrated Scripting Environment (ISE) and click Next --> Install --> Close. How To Run the Windows PowerShell ISE on Win2K8R2: Open any PowerShell Console window and enter ise at the prompt.
  19. What is the SharePoint 2010 Management Shell? A Windows PowerShell "snap-in“ Included with SharePoint Foundation 2010 Provides hundreds of cmdlets in 30 categories Access Services Backup and Recovery Business Connectivity Services Database Enterprise Content Management Excel Services Farm Features and Solutions General (Assignment) Import and Export InfoPath Services Logging and Events Performance Performance Point Services Search Secure Store Services Security Service Application SharePoint Foundation 2010 Search Site Collection Site Management State Service and Session State Timer Jobs Upgrade and Migration User Profile Services Visio Graphics Services Web Analytics Web application Word Services Workflow Management Like stsadm.exe, the SharePoint 2010 Management Shell is available on all Production SharePoint Servers where Visual Studio is not
  20. How to Run the SharePoint 2010 Management Shell Installing SharePoint Foundation includes a Windows PowerShell "snap-in" called Microsoft SharePoint 2010 Management Shell Find under Start-->Microsoft SharePoint 2010 Products right along side SharePoint 2010 Central Admin and SharePoint 2010 Products Configuration Wizard. Best Practice: Set the Properties of your Shell right-mouse click on SharePoint 2010 Management Shell and select Properties Click the ShortCuttab Click Advanced… On the Advanced Properties, select "Run as Administrator" Ok Click the Options tab In the Edit Options, select “Quick Edit” (so can paste text into cmd prompt) Use the Font and Layout tabs to make it easier on the eyes Best Practice: pin to your taskbar right-mouse click on SharePoint 2010 Management Shell and Pin to Taskbar.
  21. Use PowerShell to Automate Solution Deployment Add-SPSolution Compare to: stsadm -o addsolution -filename bmp.amc.wsp Install-SPSolution Compare to: stsadm -o deploysolution -name bmp.amc.wsp -immediate -allcontenturls -allowGacDeployment Enable-SPFeature Compare to: stsadm -o activatefeature -name bmp.amc.Foundation -urlhttp://vm01/sites/amc WSP Add-SPSolution Install-SPSolution
  22. How to Create your SharePoint Solution Package (WSP) The SharePoint Solution Framework bundles all components of a SharePoint Solution into a single Solution Package (WSP) file Use Visual Studio 2010 to create your Solution Package (WSP) file In Solution Explorer, right-mouse click on your solution project Select Package Visual Studio writes The Solution Package WSP file to the Output Path C:\<solution>\<project>\bin\Debug\<project>.wsp
  23. How to Deploy a SharePoint Solution Using PowerShell Best Practice #1 Add a Deploy folder to your SharePoint 2010 Project Create the following PowerShell (PS1) Scripts and Add them to your Project AddSolution.ps1 Installs and Deploys the solution (WSP) RemoveSolution.ps1 Un-Installs and Removes the solution (WSP) EnableFeatures.ps1 Enables the features in the solution DisableFeatures.ps1 Disables the features in the solution CreateSite.ps1 Creates the Site Collection that hosts your application DeleteSite.ps1 Deletes the Site Collection that hosts your application These scripts and the WSP are all you need to deploy to any SP server
  24. AddSolution Copies Latest WSP from Output Path AddSolution runs in the Deploy folder of your SharePoint 2010 Project AddSolution copies the latest WSP from the Output Path to the Deploy Path Then it calls Add-SPSolutionon the WSP Add-PSSnapinMicrosoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue" Start-SPAssignment -global Out-Host -InputObject "Copying Bmp.Amc.Foundation Solution from Debug..." Copy-Item ..\bin\Debug\Bmp.Amc.Foundation.wsp . -Force Out-Host -InputObject "Adding Bmp.Amc.Foundation Solution..." Add-SPSolution -LiteralPath $(Get-ChilditemBmp.Amc.Foundation.wsp) TIP #1: –LiteralPath $(Get-Childitemwspfilename) PowerShell cmdlets don’t look in current working directory by default (!) You have to use Get-Childitem to get the full path of the current working directory
  25. Script Must Wait for Add-SPSolution to Finish Add-SPSolution returns before SharePoint Job is Done Install-SPSolution often fails if started too soon TIP #2: Script must poll and sleep until Add Job is Done Add-SPSolution -LiteralPath $(Get-ChilditemBmp.Amc.Foundation.wsp) do { Write-Host "Waiting for job to complete adding Bmp.Amc.Foundation solution..." $targetSolution = Get-SPSolution | Where-Object {$_.Name –eq "Bmp.Amc.Foundation.wsp"} if ($targetSolution.JobExists -eq “True”) { Write-Host "Sleeping 5 seconds..." Start-Sleep -s 5} } while ($targetSolution.JobExists -eq “True”) Out-Host -InputObject "Installing Bmp.Amc.Foundation Solution..." Install-SPSolution -Identity Bmp.Amc.Foundation.wsp -GACDeployment -Force WSP Add-SPSolution Install-SPSolution
  26. After Install-SPSolution is Finished, Enable Features Feature Activation broken out into separate script Useful modularity TIP #3: Install-SPSolutioncmdlets does not automatically activate Features This is the opposite of how Visual Studio F5 works Script calls EnableFeatures script .\EnableFeatures.ps1 Write-Host "AddSolution: Done."
  27. RemoveSolution Script Must Wait for Uninstall to Finish Uninstall-SPSolution returns before SharePoint Job is Done Remove-SPSolutionfails if started too soon TIP #3: Script must poll and sleep until Uninstall Job is Done Uninstall-SPSolution -Identity 76d81ffc-6fad-491d-8d0c-222c333de83a -Confirm:$false do { Write-Host "Waiting for job to complete un-installing Bmp.Amc.Foundation solution..." $targetSolution = Get-SPSolution | Where-Object {$_.Id -eq "76d81ffc-6fad-491d-8d0c-222c333de83a"} if ($targetSolution.JobExists -eq "True") { Write-Host "Sleeping 5 seconds..." Start-Sleep -s 5} } while ($targetSolution.JobExists -eq "True") Write-Host "Removing Bmp.Amc.Foundation solution..." Remove-SPSolution -Identity 76d81ffc-6fad-491d-8d0c-222c333de83a -Force -Confirm:$false Write-Host "RemoveSolution: Done." Uninstall-SPSolution Remove-SPSolution
  28. How to Deploy a SharePoint Solution Using PowerShell Best Practice #2 Document your procedure for building and deploying your solution Document both your New Setup / First Time deployment procedure and your Update / Upgrade procedure Include things like software prerequisites, environment variables, and web.config settings Maintain your Deploy scripts and your Documented Procedure just as do your source code You can maintain your documented procedure in TFS along with your source code QA should test the deployment procedures just as they do the code Follow your procedures, at least on Test, Staging and Production Farms Developers will use F5 and other Visual Studio shortcuts But developers should be able to close Visual Studio and deploy without it
  29. Use Environment Variables to Handle Different Systems Best Practice #3 Write your scripts so that they work unmodified on all environments: dev, test, staging, and production. You can define environment variables for: BMP_AMC_WEBAPPURL URL of the Web Application (if needed) to deploy Web-App-Scoped solutions BMP_AMC_SITEURL URL of the Site Collection (SPSite) to be created and where features should be enabled BMP_AMC_OWNERALIAS Alias (DOMAIN\Login) of the user who should be set as site collection owner when creating a new Asset Management Compliance site
  30. How to Use Environment Variables in PowerShell Scripts Write-Host "Enabling Bmp Amc Content Types Feature on Amc site..." Enable-SPFeature -Identity "e5ded58e-32b5-4bab-b180-9de1122d4c65" -Confirm:$false -Force:$true -Url $Env:BMP_AMC_SITEURL Enable-SPFeature is enabling a site scoped feature at the URL specified by the environment variable BMP_AMC_SITEURL
  31. How to Check if a Solution is Deployed Write-Host "Checking for Bmp.Amc.WebSite solution..." $targetSolution = Get-SPSolution | Where-Object {$_.Id -eq "2bce7c34-ad08-449c-bf7f-2ae6d4ab56aa"} if ($targetSolution.Deployed -ne “True”) { Write-Host "Bmp.Amc.WebSite solution is not yet deployed." Write-Host "Calling AddSolution script..." .\AddSolution.ps1 } The script checks whether the solution is deployed and, if not, calls the AddSolution script to deploy it
  32. How to Check if a Web Site Exists Write-Host "Checking if Amc site exists..." if( (Get-SPWeb -Identity $Env:BMP_AMC_SITEURL -eaSilentlyContinue) -eq $null) { Write-Host "Amc site not found." Write-Host "Creating new AmcSPSite..." New-SPSite -Url $Env:BMP_AMC_SITEURL -OwnerAlias $Env:BMP_AMC_OWNERALIAS -Name Amc -Template "STS#1" } The script checks if the site at the URL specified by the environment variable BMP_AMC_SITEURL exists and, if not, calls the New-SPSitecmdlet to create it. TIP #4: -eaSilentlyContinue prevents big blob of red text from displaying when cmdlet encounters error
  33. Use PowerShell to Automate Configuration Steps Activate Features Create SharePoint Groups Add Test User Accounts to Groups
  34. Use PowerShell to Automate Creation of Test Data Import documents Load list entries Prep for search test scenarios by running the indexer
  35. Summary

    Recognize where you Project falls on the Tooling/Complexity Matrix Streamline the process for setup, deployment and configuration of your solution Maintain your Deployment Process just like your code, and follow your process consistently Use PowerShell to Automate Solution Deployment, Configuration Steps, and Creation of Test Data and Test Accounts Thank you.
More Related