Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web...

50
Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell Richard Calderon Principal Consultant, Catapult Systems Better, Faster, Stronger!

description

In this session, I discuss and demonstrate how you can use SharePoint 2010 Web Templates and PowerShell scripts to give your team-based SharePoint development process a much needed productivity boost. Using these techniques, you enable your team to quickly test and review their custom components against your complete SharePoint solution while simultaneously eliminating inconsistencies often created by manual configurations. By the end of this session, you will have learned: How SharePoint web templates can be used to provision customized SharePoint sites How to leverage PowerShell scripts to automate your custom site build and feature deployments The key benefits of this approach for team-based SharePoint development So stop wasting time and come see how you can help make your SharePoint team development better, faster, and stronger!

Transcript of Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web...

Page 1: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

Richard CalderonPrincipal Consultant, Catapult Systems

Better, Faster, Stronger!

Page 2: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

2

About Me Richard Calderon Principal Consultant and SharePoint Solutions

Architect at Catapult Systems (www.catapultsystems.com)

Technology consulting since 1998, with Catapult since January 2001

[email protected] Twitter: @rcatx LinkedIn: www.linkedin.com/in/rcatx

Page 3: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

3

More About Me

Live in Austin, Texas Part-time musician

Played the drums since I was a kid Studied music in college (Percussion

Performance) Huge fan of Star Wars, saw all six movies in the

theater

Page 4: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

4

What will we cover in this session?

Web Templates – What are they and why should we use them for provisioning SharePoint

sites?

PowerShell – Automating site deployment during development phase using PowerShell

scripts

Key Benefits of this pattern for SharePointteam-based development

Page 5: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

5

Target Audience

• Solution Architects• Development Project Leads

Primary Audience

• SharePoint (.NET) Developers• SharePoint UI/UX Developers• SharePoint Administrators

Secondary Audience

Page 6: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

6

Quick poll…Which of the following apply to me? I currently work (or have worked) in a

SharePoint development team with two or more developers I have had the need to develop and deploy a custom site

“type” To meet that need, I have created:

a custom site template (using “Save site as template”)

a custom site definition I deploy SharePoint customizations via features in WSPs

whenever possible I use PowerShell scripts to automate common SharePoint

development activities

Page 7: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

7

Business RequirementsYou have been tasked with creating a new corporateintranet using SharePoint 2010 (RC Drum Company) The site will require:

Various communications areas (e.g. Products, News & Announcements, Human Resources, IT, Administration, etc.)

Collaboration capabilities (document sharing, calendars, tasks lists, etc.)

Web page publishing capabilities Custom Look-and-Feel (Branding) Must be deployable to SharePoint Online (Office 365)

Page 8: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

8

Planned Technical Design

Provision one SharePoint web application and site collection

Enable SharePoint Publishing features

Create custom site columns and

content types

Provision list instances based

off of custom lists

Apply custom branding,

including custom page layouts

Provision custom publishing pages from page layouts

Set default (welcome) page and navigation options for each web in the site

collection

Deploy a few custom .NET

component (web parts, etc.)

Page 9: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

9

Your Development Team (You) Team lead/solution architect - overall site

architecture and design .NET/SharePoint developer(s) - custom

components SharePoint UI/UX developer(s) - branding

Page 10: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

10

Site Customization MethodsWhat are some common ways to begin customizing a SharePoint site?1. SharePoint UI (Browser)

Manually provision a (publishing) site collection and sub webs

Manually create site columns, content types, lists and libraries

2. SharePoint Designer 2010 Open site, create branding artifacts

3. Visual Studio 2010 Develop custom web parts/controls Create features, package in to WSP and deploy to farm

or site solutions gallery

Page 11: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

11

Challenges With Unstructured Site Customization Methods Manual configurations are prone to

variances/errors Customizations are not versioned Challenging to maintain/upgrade Tedious to set up new developer

environments Difficult to deploy customizations

through multiple environments (e.g. Test, Staging, Production)

Time consuming

Page 12: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

12

So how can our team…work together more efficiently?

reduce/eliminate inconsistencies?

increase productivity?

Page 13: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

Part One: Web Templates

Page 14: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

14

Site Provisioning Methods(SharePoint 2010)Site Definitions

Traditional WebTemp*.xml + onet.xml combination, contains one or more site definition configurations

Stored on file system of SharePoint server(s) in folder: %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\SiteTemplates

Changes to existing site definitions not supported by MS

Can only be deployed using farm solutions, so not an option for deployment to SharePoint Online

Site Templates*

Created in the SharePoint UI by using an existing site as a model

“Save as site template” saves .wsp file to Solution Gallery of site collection (stored in the content database)

“Save site as template” method not supported by MS when publishing features are enabled*Microsoft refers to these as Web Templates on MSDN: Site Types: WebTemplates and Site Definitions

Page 15: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

15

Site Provisioning Methods(SharePoint 2010)Feature Stapling

Used to extend and customize existing site definitions

Can only extend existing site definitions, cannot create new site “types”

Portal Provisioning Providers

Replace onet.xml file with code + WebTemp*.xml files

WebTemp*.xml files must be deployed to file system, so not an option for deployment to SharePoint Online

Custom code Typically used for automated site provisioning from existing site definitions or site templates

Can be used but is a non-standard method

Web Templates

New feature element available in SharePoint 2010

Page 16: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

16

Web Templates: Overview The <WebTemplate/> element is a new option (in

SharePoint 2010) at the Feature Framework level

References an existing site definition (OOB or custom) but has a separate onet.xml

Used only when site is provisioned, site has no references to Web Template at runtime

Deployed via features

Page 17: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

17

Why provision a site using web templates? Minimize manual site configurations (feature

activations, list provisioning, web part configurations, etc.)

Provide a consistent user experience for content editors to extend sites

Reduce site maintenance and risk of complications during future upgrades (advantage over other methods)

Page 18: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

18

Web Templates: Pros/Cons

Pros Can be used with Publishing features Can be deployed to MS cloud services

(SharePoint Online) More easily upgraded to SharePoint vNext

Cons Declarative markup (XML) can be tedious to

learn/debug Does not (yet) support variations

Page 19: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

19

Web Template Development

What tools are needed? SharePoint Server 2010 (for publishing features) Visual Studio 2010 Visual Studio Extensions:

Community Kit for SharePoint (CKS)Development Tools Edition (SharePoint Server 2010 version) Current release 2.4 (May 2012) contains

WebTemplateSP Item Template!

CAML .NET Intellisense (optional, but quite useful)

Page 20: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

20

Web Template Development

What do you need to know? Thanks to CKS WebTemplate SPI, most of the tedious work

is now done for you (previously had to manually create/edit all web template items)

However, it is still important to understand what each piece does and how they fit together

Vesa Juvonen’s (MCS) blog post on MSDN “SharePoint 2010 and web templates” is an excellent source for learning about web template development

Page 21: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

21

Web Template Development To get started,

choose an existing site definition that is most like the new site (web template) you want to create (e.g. Publishing Site)

The CKS Web Template SPI has a wizard to help with this

Todd Baginski’s (MVP) blog post “Which SharePoint 2010 Site Template is Right for Me?” can help you decide

Page 22: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

22

Web Template Development

There are four main types of project items:1. The Web Template

(<WebTemplate/> element and onet.xml)

2. “Defaults” for the web template

3. A web template identifier “stamp”

4. Features to deploy web template

“So… the CKS Web Template SPI created a lot of stuff.

What does it do and how does it work? “

Page 23: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

23

<WebTemplate/> Element

The <WebTemplate/> element contains three (required) properties which reference a base site definition:

BaseTemplateName BaseTemplateID BaseConfigurationID

Page 24: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

24

ONET.xml

The onet.xml describes which features are activated (and the order of activation) when a site is provisioned from the web template.1. Start with a copy of the onet.xml from the base site

definition2. Delete all <configuration/> elements except for

Configuration ID=“0”3. Delete any <module/> elements and move to web

template “defaults” (activated via feature)Each of these steps is now handled by the CKS Web template SPI but you will need to review then customize per your requirements

Page 25: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

25

Web Template “Defaults”

Used to create any default SharePoint items (welcome page, list instance, etc.) or settings (content type binding to a doc library) required for the web template.

Page 26: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

26

Web Template “Stamp”

Used to “stamp” the site provisioned from the web template with a web template identifier Because the site has no reference to the web template at

runtime, adds a “WebTemplateId” property to the site property bag in order to trace which web template was used to create the site

Check using SharePoint Property Bag Settings 2010 (CodePlex)

Page 27: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

27

Web Template Features One site-scoped feature to activate the web

template Two web-scoped features to:

Create web template “defaults” “Stamp” the site with the web template

identifier The two web-scoped features should be

added to the bottom of the <WebFeatures/> section in the onet.xml file (CKS Web Template SPI does this for you)

Page 28: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

Demonstration:Creating Web Templates

Page 29: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

Part Two: Packaging and (Pre)Deployment Process

Page 30: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

30

Packaging and Pre-deployment ProcessPurpose: To package WSPs and copy them to a common folder prior to executing PowerShell deployment script.

Deployment

Package1.wsp

Package2.wsp

Package3.wsp

Project1/bin/Debug/

Project2/bin/Debug/

Project3/bin/Debug/

Page 31: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

31

Packaging and Pre-deployment Process1. Create a new deployment configuration (e.g.

“Copy WSP to Deployment Folder”) and add “Run Pre-Deployment Command” to the list of Selected Deployment Steps:

Page 32: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

32

Packaging and Pre-deployment Process2. Add the following command to the Pre-Deployment

Command Line:copy $(TargetDir)$(TargetName).wsp $(SolutionDir)Deployment\$(TargetName).wsp

3. Set Active Deployment Configuration to the new deployment configuration

4. Create the same deployment configuration and set as the active configuration for each project in your VS solution

Page 33: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

33

Executing the Process From the Build menu, select Deploy Solution Review the Output window to monitor the

process:

WSPs are copied to common folder

Page 34: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

Demonstration:Packaging and

(Pre)Deployment Process

Page 35: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

Part Three: PowerShell Automation

Page 36: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

36

PowerShell ScriptingPurpose: To automate process for provisioning web application, creating a site collection, and deploying solution packages during development. Scripts provide a consistent method for

provisioning, deployment, and configuration Used ‘N’ number of times during development Can also used for one-time deployment for

production site set up (on-premises only)

Page 37: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

37

PowerShell Development: ToolsUse PowerGUI (http://powergui.org) for PowerShell development (Can step-through script, toggle breakpoints, view variables and output window)

Tip: In current version (3.2), need to comment out<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /> inC:\Program Files (x86)\PowerGUI\ScriptEditor.exe.configotherwise can’ t execute SharePoint Powershell cmdlets in script editor

Page 38: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

38

Automated Site Deployment Process If DeleteWebApp –eq “true”

Deletes the existing web application Creates the web application if it was deleted or

does not already exist Else (if not deleting the web app)

Deletes the existing site collection Creates a new site collection Adds the WSPs to the site collection solutions

gallery and activates features Gets root web and applies custom web template Creates sub webs from custom web templates

Page 39: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

39

Reference Web Template in PowerShellWhen referencing a web template in your PowerShell script, use the format:

[FeatureGUID]#[WebTemplateName]

Where [FeatureGUID] is the feature GUID of the site-scoped feature in which the web template was deployed

And [WebTemplateName ] is the value of the Name property (e.g. RootWeb) of the WebTemplate element

Page 40: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

Demonstration:Site Deployment with

PowerShell

Page 41: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

Part Four: Considerations and

Key Benefits

Page 42: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

42

How The Process Works For Each Team Member During DevelopmentSolution architect

Design/develops new web templates as needed Run deployment script to test

.NET developers Run deployment script to create site F5 deploy/debug components Check-in code, rerun script as needed

UI/UX developers Run deployment script to create site Open site in SharePoint Designer, develop artifacts Copy artifacts/code to VS project(s), Check-in code Rerun script as needed

Page 43: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

43

When is this the Best Technical Design?

When you have two or more developers on a team, using a shared source control repository (e.g. TFS)

The project duration is long enough to benefit from the process (and set up)

You need the ability to consistently move code between two or more environments (Dev, Test, Production)

When the site hierarchy is fairly well-defined during requirements gathering (before development)

Page 44: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

44

What are the advantages of this development pattern? Each developer can work in isolated development

environment Dev team has opportunity to see each others

components working together (E.g. UI styles with custom developed web parts)

More easily onboard additional developers during the development phase

Scripts increase productivity and reduce inconsistencies between developer workstations

Page 45: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

45

Key Takeaways from this session Creating Web Templates is pretty

easy once you get the hang of it. Try it!

PowerShell is awesome! Use it! Your development team will

LOVE you for setting this up for them in advance! DO IT!

Page 46: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

46

References and Links

Web Templates: Vesa Juvonen’s Blog (

http://blogs.msdn.com/b/vesku/)

Todd Baginski’s Blog, Which SharePoint 2010 Site Template is Right for Me? (http://toddbaginski.com/blog/which-sharepoint-2010-site-template-is-right-for-me/)

Page 47: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

47

References and Links

PowerShell: PowerShell for SharePoint 2010 (

http://technet.microsoft.com/en-us/library/ee662539.aspx)

Windows PowerShell Command Builder for SharePoint 2010 (http://www.microsoft.com/resources/TechNet/en-us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.html)

Page 48: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

48

References and Links

Tools and VS 2010 Extensions: PowerGUI (http://powergui.org/downloads.jspa)

Community Kit for SharePoint (CKS): Development Tools Edition (http://cksdev.codeplex.com/)

CAML .NET Intellisense (http://visualstudiogallery.msdn.microsoft.com/15055544-fda0-42db-a603-6dc32ed26fde/)

SharePoint Property Bag Settings 2010 (http://pbs2010.codeplex.com/)

Page 49: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

49

References and Links

Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

http://www.slideshare.net/rcatx/using-web-templates-and-powershell-to-improve-sharepoint-team-development-12730158

Page 50: Better, Faster, Stronger! Boost Your Team-Based SharePoint Development Using SharePoint 2010 Web Templates and PowerShell

50

Questions?

Richard Calderon, Catapult SystemsEmail: [email protected]: @rcatxLinkedIn: www.linkedin.com/in/rcatx