40
SP 2013: Full Trust Solution Development SharePoint Saturday – MONTRÉAL 2 février 2013 – February 2 nd 2013 Ed Musters, SharePoint MVP Twitter: @TechEdToronto

Full Trust Solution Development in SharePoint 2013

Embed Size (px)

Citation preview

Page 1: Full Trust Solution Development in SharePoint 2013

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

Ed Musters, SharePoint MVP

Twitter: @TechEdToronto

Page 3: Full Trust Solution Development in SharePoint 2013

{ 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!

Page 4: Full Trust Solution Development in SharePoint 2013

London Kraków Dubai New York Toronto Boston

Page 5: Full Trust Solution Development in SharePoint 2013

6

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

Page 6: Full Trust Solution Development in SharePoint 2013

Published Books

Page 7: Full Trust Solution Development in SharePoint 2013

Prize! Telerik DevCraft Ultimate Collection

Page 8: Full Trust Solution Development in SharePoint 2013

Agenda

Full Trust Solution

Dev

Convert From SP

2010

SP 2013 Dev

Advanced Deployme

nt

Best Practice

s

Conclusion

Page 9: Full Trust Solution Development in SharePoint 2013

Why Full Trust?

Page 10: Full Trust Solution Development in SharePoint 2013

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)

Page 11: Full Trust Solution Development in SharePoint 2013

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

Page 12: Full Trust Solution Development in SharePoint 2013

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

Page 13: Full Trust Solution Development in SharePoint 2013

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

Page 14: Full Trust Solution Development in SharePoint 2013

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

Page 15: Full Trust Solution Development in SharePoint 2013

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

Page 16: Full Trust Solution Development in SharePoint 2013

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

Page 17: Full Trust Solution Development in SharePoint 2013

Convert from SP2010

Page 18: Full Trust Solution Development in SharePoint 2013

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

Page 19: Full Trust Solution Development in SharePoint 2013

Solution Structure and Dependencies

Page 20: Full Trust Solution Development in SharePoint 2013

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">

Page 21: Full Trust Solution Development in SharePoint 2013

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">

Page 22: Full Trust Solution Development in SharePoint 2013

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

Page 23: Full Trust Solution Development in SharePoint 2013

SP 2013 Dev

Page 24: Full Trust Solution Development in SharePoint 2013

Development in SharePoint 2013

Demo

Visual Studio 2012

Page 25: Full Trust Solution Development in SharePoint 2013

Advanced Deployment

Page 26: Full Trust Solution Development in SharePoint 2013

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

Page 27: Full Trust Solution Development in SharePoint 2013

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

Page 28: Full Trust Solution Development in SharePoint 2013

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(); } } }

Page 29: Full Trust Solution Development in SharePoint 2013

Content / Contenu

Define Feature Activation Dependency

Expand section at bottom of feature designer

Page 30: Full Trust Solution Development in SharePoint 2013

Content / Contenu

Trigger Feature Activation Dependency

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

Page 31: Full Trust Solution Development in SharePoint 2013

Content / Contenu

Define Solution Activation Dependency

Must edit manifest manually and add:

Page 32: Full Trust Solution Development in SharePoint 2013

Content / Contenu

Trigger Solution Activation Dependency

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

Page 33: Full Trust Solution Development in SharePoint 2013

Best Practices

Page 34: Full Trust Solution Development in SharePoint 2013

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)

Page 35: Full Trust Solution Development in SharePoint 2013

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

Page 36: Full Trust Solution Development in SharePoint 2013

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

Page 37: Full Trust Solution Development in SharePoint 2013

Conclusion

Page 38: Full Trust Solution Development in SharePoint 2013

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

Ed [email protected]@TechEdToronto

Page 40: Full Trust Solution Development in SharePoint 2013

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