Full Trust Solution Development in SharePoint 2013

Preview:

Citation preview

SP 2013: Full Trust Solution DevelopmentSharePoint Saturday – MONTRÉAL2 février 2013 – February 2nd 2013

Ed Musters, SharePoint MVP

Twitter: @TechEdToronto

{ About.Me() }

https://mvp.support.microsoft.com/profile/Ed.Musters

• Current SharePoint MVP• Author for two SP 2010 development books• SharePoint Architect for Infusion• Speaker at International Conferences on

SharePoint, at user groups, and at SharePoint Saturdays

• Certified Trainer for the industry leading SharePoint training from Critical Path Training

• Telerik “Insider”• Holds all MS certifications for SharePoint

2010

• Harley-Davidson ™ Enthusiast!

London Kraków Dubai New York Toronto Boston

6

And, yes, I do really have a Black Belt.

Published Books

Prize! Telerik DevCraft Ultimate Collection

Agenda

Full Trust Solution

Dev

Convert From SP

2010

SP 2013 Dev

Advanced Deployme

nt

Best Practice

s

Conclusion

Why Full Trust?

The New SharePoint « App » Model

Is this not THE new way to develop for SP?

This was all that was talked about at the MS SharePoint Conference!

No code is deployed to the SharePoint servers

You may choose any technoloogy, you host it

Apps are published – coporate store or public marketplace

Suitable for on-premise or cloud (Office 365)

The New SharePoint « App » Model

When are Apps suitable? If your primary purpose is to access data in

SharePoint Your custom solution is a new one App is not ASP.NET – iOS, Win 8, Win Phone,

MVC, LAMP (PhP) Leverage pure web dev skills – HTML, CSS,

JavaScript (jQuery) You want to be able to move from on-premise

to Cloud

Full Trust Solutions in SharePoint

What are Full Trust Solutions? Solution Packages (WSPs) are installed to

SharePoint Server Typically, compiled .NET code is deployed to

GAC Files are pushed physically to the SharePoint

Root directory More limited cloud scenarios via

« SandBox » solutions

Full Trust Solutions in SharePoint

When are they suitable? If you have an on-premise deployment of

SharePoint You have lots of existing solutions in SP

2007 / 2010 That is, solutions you may want to re-use /

migrate You are an ASP.NET web forms developer Can SandBox for cloud solutions (but

deprecated) Cannot be app – such as timer job, admin

page

Full Trust Solutions in SharePoint

How are they developed? « Traditional » development using Visual

Studio / C# Program against the SharePoint Server object

model Package using VS tools to SharePoint Solution

Packages (WSPs) Deploy to Farm, typically using PowerShell. SandBox solutions would be uploaded /

activated

Solution Packages

• Solution Packages are sets of functionality deployed to the farm or site collection (sandbox)

• May contain one or more Features, assemblies, pages, controls, and other artifacts

• SharePoint framework handles installation and configuration of solution items

• Automated packaging and deployment in Visual Studio 2010

Web Parts

Assemblies

MappedFolders

WSP

Features

• A ‘Feature’ is a defined set of functionality encapsulated within a specific format

• Features may be comprised of any combination of code, including web parts, workflows, and site definitions

• Features may be deployed individually or as a part of the solution package

Solution

Feature

XML

ReceiverAssembly

Project Item

Web Part Template Workflow

Convert from SP2010

Sample App – Footer Links

• Illustrates a very common development pattern1. Define schema: Site Columns and Content Types2. List Provisioned with attached content types3. A Web Part that performs a content query against the content type /

SP List

Solution Structure and Dependencies

Use Existing Solutions from SharePoint 2010

Possible To: Deploy Existing Solutions Will deploy to « 14 » folder in SharePoint

2013 Add « 14 » property to manifest!

<Solution xmlns="http://schemas.microsoft.com/sharepoint/" SolutionId="cae481cb-a094-44ae-8298-ea989344a025" SharePointProductVersion="14.0">

Converting VS Solutions from SharePoint 2010

Possible To: Open Solution in VS 2012 Change to latest Framework Version Change SharePoint References Add « 15 » property to manifest

<Solution xmlns="http://schemas.microsoft.com/sharepoint/" SolutionId="cae481cb-a094-44ae-8298-ea989344a025" SharePointProductVersion="15.0">

Converting VS Solutions from SharePoint 2010

My Strongest Recommendation! Create New VS SP 2013 solution Ensure Package Name is different (e.g.

append 2013) Bring in code / files from SP 2010 Ultimately package structure should be

identical Ensure feature names and IDs are the same

OR Create with new feature IDs

SP 2013 Dev

Development in SharePoint 2013

Demo

Visual Studio 2012

Advanced Deployment

Solution File (WSP) Deployment

• Know the solution deployment life cycle!

mySolution.wsp(WSS Solution Cab)

Debugging

WSS Config DB

Web Servers

“MakeCab” addremove

InstallUninstall

• Uninstall-SPSolution • Remove-SPSolution • Add-SPSolution• Install-SPSolution

Automate Solution Provisioning

Deployment Automation with Powershell$SolutionPackage = "FooterLinks2013Schema.wsp"

$solution = Get-SPSolution | where-object {$_.Name -eq $SolutionPackage}if ($Solution -ne $null) { if($Solution.Deployed -eq $true) { Write-Host "Uninstall: " $SolutionPackage Uninstall-SPSolution -Identity $SolutionPackage -Local -Confirm:$false } Write-Host "Remove: " $SolutionPackage Remove-SPSolution -Identity $SolutionPackage -Confirm:$false}

$wspPath = Resolve-Path $SolutionPackage;Write-Host "Add: " $SolutionPackageAdd-SPSolution -LiteralPath $wspPathWrite-Host "Install: " $SolutionPackageInstall-SPSolution -Identity $SolutionPackage -Local -GACDeployment -FOrce

Feature Receivers

Code that runs with Feature Activation

Example: FeatureDeactivating delete list public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { SPWeb site = properties.Feature.Parent as SPWeb; if (site != null) { SPList list = site.Lists.TryGetList("Footer Links 2013"); if (list != null) { list.Delete(); } } }

Content / Contenu

Define Feature Activation Dependency

Expand section at bottom of feature designer

Content / Contenu

Trigger Feature Activation Dependency

Attempting to Deploy « footer links » before « schema »:

Content / Contenu

Define Solution Activation Dependency

Must edit manifest manually and add:

Content / Contenu

Trigger Solution Activation Dependency

Attempting to Deploy « footer links » WSP before « footer schema » WSP:

Best Practices

Right # of Solutions?

• Partition according to feature scope• Partition with reusability in mind• Partition with maintainability in mind• Partition along activation dependencies• Put “schema” in its own solution• Item types have tendency to be grouped together (e.g. web

parts, workflow templates)

What’s Your Story?

• Methodically planned deployment• The “big bang” deployment• Visual Studio and SharePoint Designer mix• Manual Deployment – 35 page manual• Lack of Deployment Automation• Actually, there is no real deployment

Deployment Best Practices

For Full Trust Solutions Partition your solutions (WSPs) Define solution and feature activation

dependencies Automate extensively with PowerShell Handle initialization and cleanup with

Feature Receivers Set your feature Icon Set your feature version to 1.0.0.0

Conclusion

Remerc iements / ThanksQuest ions et réponses / Q&A

Ed Mustersemusters@infusion.com@TechEdToronto

Visitez-nous! – Visit Us!

Site principal / Main site – www.sharepointquebec.org Twitter - @guspquebec Facebook -

http://www.facebook.com/groups/206445679432304/ Meetup- http://www.meetup.com/guspquebec/ LinkedIn - http://www.linkedin.com/groups?gid=149597

Recommended