34
Alexander Meijers & Roel Hans Bethlehem

Best Practices Configuring And Developing Share Point Solutions

Embed Size (px)

DESCRIPTION

This presentation contains best practices from myself and Microsoft regarding configuring and developing SharePoint Solutions. What to do with development, resources, disposing, deployment and some other items.

Citation preview

Page 1: Best Practices Configuring And Developing Share Point Solutions

Alexander Meijers &

Roel Hans Bethlehem

Page 2: Best Practices Configuring And Developing Share Point Solutions

Introduction

Alexander Meijers

• Architect at Sparked• Subject matter Expert for

SharePoint and Search• http://www.bloggix.com/blogs/

microsoft• http://www.dutchsug.nl

Roel Hans Bethlehem

• Architect at Sparked• Subject matter Expert for

SharePoint

Page 3: Best Practices Configuring And Developing Share Point Solutions

Agenda

• Project & tools• Keep to the Basics• Locations• Permissions• Development• Styling• Multilanguage• Deployment

Page 4: Best Practices Configuring And Developing Share Point Solutions

Setup a development project• Create single solution• Add for each namespace in your project a class library

project• Create a namespace for deployment• Create a duplicate tree of the 12 Hives• Make use of tools like

– Add in for WSP Builder (http://www.codeplex.com)– SharePoint installer (http://www.codeplex.com)

• Use features– Installing components– Changes to config files

Page 5: Best Practices Configuring And Developing Share Point Solutions

Tools• WSPBuilder

– Creates SharePoint Solutions files based on a folder structure

– Deploy solutions

• SharePoint Installer– Creating user friendly installation and deployments for SharePoint 2007

solutions

• VSeWSS 1.2– Visual Studio 2008 extensions

• STSDEV– Generate Visual Studio project files and solution files

• STSADM– 184 operations through command line on the web server

– Custom extensions possible

Page 6: Best Practices Configuring And Developing Share Point Solutions

Demo

Tools & Project setup

Page 7: Best Practices Configuring And Developing Share Point Solutions

Keep to the basics

• Use standard functionality as much as possible– All SharePoint functionality out-of-the-box will

still work like search, versioning and publishing

• Use SharePoint as storage

• Powerful API model

• Do not change or replace existing files

Page 8: Best Practices Configuring And Developing Share Point Solutions

Master pages, layouts, CSS, images, scripts

• Into a library inside your site collection– Can be referenced by ~site, ~sitecollection and ~masterpage

– Only available within the site collection

– Too many site collection makes it harder to update these files

– Updatable through the web interface

• Into the _LAYOUTS folder– Can be referenced by path to folder

– Available for every Sharepoint website in farm

– One place for easy updating these files

– Only updatable directly on the server

– All web applications on the server share this folder

Page 9: Best Practices Configuring And Developing Share Point Solutions

Code Access Security

“Request for the permission of type Microsoft.SharePoint.Security.SharePoint

Permission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral,

PublicKeyToken=71e9bce111e9429c failed”

Page 10: Best Practices Configuring And Developing Share Point Solutions

Code Access SecurityWhat is it?

• Security model use by the SharePoint API• Ensure your code provides error handling in the event

that required permissions are not available• Arrange Web applications to operate in a partially trusted

environment– System.Security. AllowPartiallyTrustedCallersAttribute()

• Level of trust– Full, High, Medium, Low, Minimal – Custom like WSS_Minimal, WSS_Medium

Page 11: Best Practices Configuring And Developing Share Point Solutions

Code Access SecurityWhat are the options?

• Decorate your code with Request Permissions– Declarative Security like

[SomePermissionAttribute(SecurityAction.Demand, Unrestricted = true)]

• Deployment and CAS– Trustlevel in your web.config– GAC– Custom policy file

Page 12: Best Practices Configuring And Developing Share Point Solutions

• Snippet: <PermissionSet class="NamedPermissionSet"

version="1"

Name="SPRestricted">

<IPermission

class="AspNetHostingPermission"

version="1"

Level=“Medium"

/>

</PermissionSet>

Custom policy example

Page 13: Best Practices Configuring And Developing Share Point Solutions

Permissions Who am I?

• Your code runs with permissions of the logged on user

• Set up proper testing– Especially for anonymous internet facing sites– I always use Firefox since it does not log me on

• Coding & Elevation– Impersonation– SPSecurity.RunWithElevatedPrivileges

Page 14: Best Practices Configuring And Developing Share Point Solutions

Demo

Elevation

Page 15: Best Practices Configuring And Developing Share Point Solutions

Web Part development

• Do not use any code in your Web Part• Always load an UserControl

– Use the ControlTemplates folder– Put the logic into the control– Code and design should be separated

• Put only properties in your Web Part• Two namespaces

– System.Web.UI.WebControls.WebParts– Microsoft.SharePoint.WebParts

Page 16: Best Practices Configuring And Developing Share Point Solutions

Web Part development• Think of

– Show only accessible / all content– Check if content is published or not– Recursive reading SPWeb objects

• UX & Design– AJAX– Silverlight– SharePoint objects like

EditorPart & EntityEditorWithPicker

Page 17: Best Practices Configuring And Developing Share Point Solutions

Demo

Web Part Development

Page 18: Best Practices Configuring And Developing Share Point Solutions

Dispose or not to dispose?

Two objects in the API model which needs to be disposed of– SPSite– SPWeb

• Dispose only when created yourself by– SPSite site1 = site2;– Use method Dispose() with try, catch, finally– or using(…) {…}

• Do not dispose contextual objects– SPContext.Current.Web.Dispose();

• Tool SPDisposeCheck

Page 19: Best Practices Configuring And Developing Share Point Solutions

Demo

Dispose or not to dispose?

Page 20: Best Practices Configuring And Developing Share Point Solutions

Styling, what are the options?

• CSS stylesheet reference (configurable)• Own site definitions, masterpages and templates

– Separation of layout and content– Full control– ONET.XML editing

• Themes– Different styles en color schemes for users (only reason to use it!)– Testing your theme is terrible

• Schema files for lists– CAML knowledge required– Full control of list layout

Page 21: Best Practices Configuring And Developing Share Point Solutions

Styling, what are the options?

• Use Firefox with the “Web developer” add on– Easy retrieval of styling

– Enabling / Disabling certain elements

– Visualizing your divs and tables

• Accessibility– Out-of-the-box is not conform standards

– Accessibility Kit for SharePointhttp://aks.hisoftware.com/index.html

• Resources– Heather Solomon

http://www.heathersolomon.com/

– SharePoint Branding Toolhttp://www.codeplex.com/BrandingTool

Page 22: Best Practices Configuring And Developing Share Point Solutions

Demo

Enabling a theme with a feature

Page 23: Best Practices Configuring And Developing Share Point Solutions

Multilanguage

• Variations– Is really a copying mechanism

• Resources files– Resource folders– Resx files

• Custom code must support Multilanguage– Web Part output– Editor Parts– Custom forms

Page 24: Best Practices Configuring And Developing Share Point Solutions

Resource files• Application resources

– Used within the normal execution of the SharePoint application. Think of Application Pages, Web Parts and Controls

– For multilangual lists: 12\CONFIG\Resources\ – For local webapplications: <Website URL>\App_GlobalResources\

• Caveat: cannot deploy by WSP package

• Provisioning resources– are used when provisioning elements. Think of features, site definitions and list definitions

– 12\TEMPLATE\FEATURES\<feature>\Resources\Resources.<culture>.resx – 12\TEMPLATE\FEATURES\<feature>\Resources\ – 12\Resources\

• Administrative application resources– Used within the normal execution of the SharePoint application. Think of Application Pages,

Web Parts and Controls inside the administrative environment

– 12\CONFIG\AdminResources\ – <Website URL>\<port>\App_GlobalResources\

Page 25: Best Practices Configuring And Developing Share Point Solutions

Resource files usage

• C#– HttpContext.GetGlobalResourceObject("MyResource",

"MyName").ToString();

• ASPX properties– <%$Resources:MyResource, MyName%>

• XML– $Resources:MyResource, MyName

• XML features, using the default resource file– $Resources:MyName

Page 26: Best Practices Configuring And Developing Share Point Solutions

Demo

Using a resources for

custom multi language Web Part

Page 27: Best Practices Configuring And Developing Share Point Solutions

Solution deployment

• Deploy the Solution package to the farm • Retract the Solutions package • When a new web server is added, automatically

deploy the solution to it • Deploy new versions of the Solution• Solution - A CAB file containing

– Manifest.xml file – All the files for the Features, Web Parts, Site or list

def changes, etc... that make up your solution

Page 28: Best Practices Configuring And Developing Share Point Solutions

Solution deployment

• “Featurize” your custom development– Any SharePoint element– Changes in your web.config– Copying files to specific web folders

• Deploy features and other assets by WSP Solution package

Page 29: Best Practices Configuring And Developing Share Point Solutions

Development and testing

• Your development machine does not go into production

• Use a buildserver

• Always test with different set of browsers (level 1 and level 2)

• Watch out for rights

Page 30: Best Practices Configuring And Developing Share Point Solutions

CodePlex

• The starting point of a lot of new SharePoint functionality

• Community Kit For SharePointhttp://www.codeplex.com/CKS

• SharePoint learning kithttp://www.codeplex.com/SLK

• SharePoint Featureshttp://www.codeplex.com/features

• Podcasting kit for SharePointhttp://www.codeplex.com/pks

• Smartpart for SharePointhttp://www.codeplex.com/smartpart

• SharePoint AJAX toolkithttp://www.codeplex.com/sharepointajax

Page 31: Best Practices Configuring And Developing Share Point Solutions

Resources

• Best practices resource center for SharePoint 2007 http://technet.microsoft.com/en-us/office/sharepointserver/bb736746.aspx

• Patterns and practices SharePoint guidancehttp://www.codeplex.com/spg

• Best practices for SharePoint guidance http://msdn.microsoft.com/en-us/library/dd203468.aspx

• SharePoint Deployment Planning Serviceshttps://iwsolve.partners.extranet.microsoft.com/SDPS/

• Downloadable book: Design and build sites for Office SharePoint Server 2007http://go.microsoft.com/fwlink/?LinkId=110087

• Other resources such as http://www.codeplex.com / http://www.dutchsug.nl / www.microsoft.com/sharepoint

Page 32: Best Practices Configuring And Developing Share Point Solutions

• Gary Lapointe STSADM http://stsadm.blogspot.com/

• Firebug https://addons.mozilla.org/nl/firefox/addon/1843

• Yslow https://addons.mozilla.org/nl/firefox/addon/5369

More resources

Page 33: Best Practices Configuring And Developing Share Point Solutions

Questions?

Page 34: Best Practices Configuring And Developing Share Point Solutions

Alexander Meijers

[email protected]

Roel Hans Bethlehem

[email protected]

Contact us