Best Practices Configuring And Developing Share Point Solutions


Published on

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.

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Best Practices Configuring And Developing Share Point Solutions

    1. 1. Alexander Meijers & Roel Hans Bethlehem
    2. 2. Introduction <ul><li>Alexander Meijers </li></ul><ul><li>Architect at Sparked </li></ul><ul><li>Subject matter Expert for SharePoint and Search </li></ul><ul><li> </li></ul><ul><li> </li></ul><ul><li>Roel Hans Bethlehem </li></ul><ul><li>Architect at Sparked </li></ul><ul><li>Subject matter Expert for SharePoint </li></ul>
    3. 3. Agenda <ul><li>Project & tools </li></ul><ul><li>Keep to the Basics </li></ul><ul><li>Locations </li></ul><ul><li>Permissions </li></ul><ul><li>Development </li></ul><ul><li>Styling </li></ul><ul><li>Multilanguage </li></ul><ul><li>Deployment </li></ul>
    4. 4. Setup a development project <ul><li>Create single solution </li></ul><ul><li>Add for each namespace in your project a class library project </li></ul><ul><li>Create a namespace for deployment </li></ul><ul><li>Create a duplicate tree of the 12 Hives </li></ul><ul><li>Make use of tools like </li></ul><ul><ul><li>Add in for WSP Builder ( ) </li></ul></ul><ul><ul><li>SharePoint installer ( ) </li></ul></ul><ul><li>Use features </li></ul><ul><ul><li>Installing components </li></ul></ul><ul><ul><li>Changes to config files </li></ul></ul>
    5. 5. Tools <ul><li>WSPBuilder </li></ul><ul><ul><li>Creates SharePoint Solutions files based on a folder structure </li></ul></ul><ul><ul><li>Deploy solutions </li></ul></ul><ul><li>SharePoint Installer </li></ul><ul><ul><li>Creating user friendly installation and deployments for SharePoint 2007 solutions </li></ul></ul><ul><li>VSeWSS 1.2 </li></ul><ul><ul><li>Visual Studio 2008 extensions </li></ul></ul><ul><li>STSDEV </li></ul><ul><ul><li>Generate Visual Studio project files and solution files </li></ul></ul><ul><li>STSADM </li></ul><ul><ul><li>184 operations through command line on the web server </li></ul></ul><ul><ul><li>Custom extensions possible </li></ul></ul>
    6. 6. Demo <ul><li>Tools & Project setup </li></ul>
    7. 7. Keep to the basics <ul><li>Use standard functionality as much as possible </li></ul><ul><ul><li>All SharePoint functionality out-of-the-box will still work like search, versioning and publishing </li></ul></ul><ul><li>Use SharePoint as storage </li></ul><ul><li>Powerful API model </li></ul><ul><li>Do not change or replace existing files </li></ul>
    8. 8. Master pages, layouts, CSS, images, scripts <ul><li>Into a library inside your site collection </li></ul><ul><ul><li>Can be referenced by ~site, ~sitecollection and ~masterpage </li></ul></ul><ul><ul><li>Only available within the site collection </li></ul></ul><ul><ul><li>Too many site collection makes it harder to update these files </li></ul></ul><ul><ul><li>Updatable through the web interface </li></ul></ul><ul><li>Into the _LAYOUTS folder </li></ul><ul><ul><li>Can be referenced by path to folder </li></ul></ul><ul><ul><li>Available for every Sharepoint website in farm </li></ul></ul><ul><ul><li>One place for easy updating these files </li></ul></ul><ul><ul><li>Only updatable directly on the server </li></ul></ul><ul><ul><li>All web applications on the server share this folder </li></ul></ul>
    9. 9. Code Access Security <ul><li>“ Request for the permission of type Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c failed ” </li></ul>
    10. 10. Code Access Security What is it? <ul><li>Security model use by the SharePoint API </li></ul><ul><li>Ensure your code provides error handling in the event that required permissions are not available </li></ul><ul><li>Arrange Web applications to operate in a partially trusted environment </li></ul><ul><ul><li>System.Security. AllowPartiallyTrustedCallersAttribute() </li></ul></ul><ul><li>Level of trust </li></ul><ul><ul><li>Full, High, Medium, Low, Minimal </li></ul></ul><ul><ul><li>Custom like WSS_Minimal, WSS_Medium </li></ul></ul>
    11. 11. Code Access Security What are the options? <ul><li>Decorate your code with Request Permissions </li></ul><ul><ul><li>Declarative Security like [SomePermissionAttribute(SecurityAction.Demand, Unrestricted = true)] </li></ul></ul><ul><li>Deployment and CAS </li></ul><ul><ul><li>Trustlevel in your web.config </li></ul></ul><ul><ul><li>GAC </li></ul></ul><ul><ul><li>Custom policy file </li></ul></ul>
    12. 12. <ul><li>Snippet: </li></ul><ul><li><PermissionSet class=&quot;NamedPermissionSet&quot; </li></ul><ul><li>version=&quot;1&quot; </li></ul><ul><li>Name=&quot;SPRestricted&quot;> </li></ul><ul><li><IPermission </li></ul><ul><li>class=&quot;AspNetHostingPermission&quot; </li></ul><ul><li>version=&quot;1&quot; </li></ul><ul><li>Level=“Medium&quot; </li></ul><ul><li>/> </li></ul><ul><li></PermissionSet> </li></ul>Custom policy example
    13. 13. Permissions Who am I? <ul><li>Your code runs with permissions of the logged on user </li></ul><ul><li>Set up proper testing </li></ul><ul><ul><li>Especially for anonymous internet facing sites </li></ul></ul><ul><ul><li>I always use Firefox since it does not log me on </li></ul></ul><ul><li>Coding & Elevation </li></ul><ul><ul><li>Impersonation </li></ul></ul><ul><ul><li>SPSecurity.RunWithElevatedPrivileges </li></ul></ul>
    14. 14. Demo <ul><li>Elevation </li></ul>
    15. 15. Web Part development <ul><li>Do not use any code in your Web Part </li></ul><ul><li>Always load an UserControl </li></ul><ul><ul><li>Use the ControlTemplates folder </li></ul></ul><ul><ul><li>Put the logic into the control </li></ul></ul><ul><ul><li>Code and design should be separated </li></ul></ul><ul><li>Put only properties in your Web Part </li></ul><ul><li>Two namespaces </li></ul><ul><ul><li>System.Web.UI.WebControls.WebParts </li></ul></ul><ul><ul><li>Microsoft.SharePoint.WebParts </li></ul></ul>
    16. 16. Web Part development <ul><li>Think of </li></ul><ul><ul><li>Show only accessible / all content </li></ul></ul><ul><ul><li>Check if content is published or not </li></ul></ul><ul><ul><li>Recursive reading SPWeb objects </li></ul></ul><ul><li>UX & Design </li></ul><ul><ul><li>AJAX </li></ul></ul><ul><ul><li>Silverlight </li></ul></ul><ul><ul><li>SharePoint objects like EditorPart & EntityEditorWithPicker </li></ul></ul>
    17. 17. Demo <ul><li>Web Part Development </li></ul>
    18. 18. Dispose or not to dispose? <ul><li>Two objects in the API model which needs to be disposed of </li></ul><ul><ul><li>SPSite </li></ul></ul><ul><ul><li>SPWeb </li></ul></ul><ul><li>Dispose only when created yourself by </li></ul><ul><ul><li>SPSite site1 = site2; </li></ul></ul><ul><ul><li>Use method Dispose() with try, catch, finally </li></ul></ul><ul><ul><li>or using(…) {…} </li></ul></ul><ul><li>Do not dispose contextual objects </li></ul><ul><ul><li>SPContext.Current.Web.Dispose(); </li></ul></ul><ul><li>Tool SPDisposeCheck </li></ul>
    19. 19. Demo <ul><li>Dispose or not to dispose? </li></ul>
    20. 20. Styling, what are the options? <ul><li>CSS stylesheet reference (configurable) </li></ul><ul><li>Own site definitions, masterpages and templates </li></ul><ul><ul><li>Separation of layout and content </li></ul></ul><ul><ul><li>Full control </li></ul></ul><ul><ul><li>ONET.XML editing </li></ul></ul><ul><li>Themes </li></ul><ul><ul><li>Different styles en color schemes for users (only reason to use it!) </li></ul></ul><ul><ul><li>Testing your theme is terrible </li></ul></ul><ul><li>Schema files for lists </li></ul><ul><ul><li>CAML knowledge required </li></ul></ul><ul><ul><li>Full control of list layout </li></ul></ul>
    21. 21. Styling, what are the options? <ul><li>Use Firefox with the “Web developer” add on </li></ul><ul><ul><li>Easy retrieval of styling </li></ul></ul><ul><ul><li>Enabling / Disabling certain elements </li></ul></ul><ul><ul><li>Visualizing your divs and tables </li></ul></ul><ul><li>Accessibility </li></ul><ul><ul><li>Out-of-the-box is not conform standards </li></ul></ul><ul><ul><li>Accessibility Kit for SharePoint </li></ul></ul><ul><li>Resources </li></ul><ul><ul><li>Heather Solomon </li></ul></ul><ul><ul><li>SharePoint Branding Tool </li></ul></ul>
    22. 22. Demo <ul><li>Enabling a theme with a feature </li></ul>
    23. 23. Multilanguage <ul><li>Variations </li></ul><ul><ul><li>Is really a copying mechanism </li></ul></ul><ul><li>Resources files </li></ul><ul><ul><li>Resource folders </li></ul></ul><ul><ul><li>Resx files </li></ul></ul><ul><li>Custom code must support Multilanguage </li></ul><ul><ul><li>Web Part output </li></ul></ul><ul><ul><li>Editor Parts </li></ul></ul><ul><ul><li>Custom forms </li></ul></ul>
    24. 24. Resource files <ul><li>Application resources </li></ul><ul><ul><li>Used within the normal execution of the SharePoint application. Think of Application Pages, Web Parts and Controls </li></ul></ul><ul><ul><li>For multilangual lists: 12CONFIGResources </li></ul></ul><ul><ul><li>For local webapplications: <Website URL>App_GlobalResources </li></ul></ul><ul><ul><ul><li>Caveat: cannot deploy by WSP package </li></ul></ul></ul><ul><li>Provisioning resources </li></ul><ul><ul><li>are used when provisioning elements. Think of features, site definitions and list definitions </li></ul></ul><ul><ul><li>12TEMPLATEFEATURES<feature>ResourcesResources.<culture>.resx </li></ul></ul><ul><ul><li>12TEMPLATEFEATURES<feature>Resources </li></ul></ul><ul><ul><li>12Resources </li></ul></ul><ul><li>Administrative application resources </li></ul><ul><ul><li>Used within the normal execution of the SharePoint application. Think of Application Pages, Web Parts and Controls inside the administrative environment </li></ul></ul><ul><ul><li>12CONFIGAdminResources </li></ul></ul><ul><ul><li><Website URL><port>App_GlobalResources </li></ul></ul>
    25. 25. Resource files usage <ul><li>C# </li></ul><ul><ul><li>HttpContext.GetGlobalResourceObject(&quot;MyResource&quot;, &quot;MyName&quot;).ToString(); </li></ul></ul><ul><li>ASPX properties </li></ul><ul><ul><li><%$Resources:MyResource, MyName%> </li></ul></ul><ul><li>XML </li></ul><ul><ul><li>$Resources:MyResource, MyName </li></ul></ul><ul><li>XML features, using the default resource file </li></ul><ul><ul><li>$Resources:MyName </li></ul></ul>
    26. 26. Demo <ul><li>Using a resources for </li></ul><ul><li>custom multi language Web Part </li></ul>
    27. 27. Solution deployment <ul><li>Deploy the Solution package to the farm </li></ul><ul><li>Retract the Solutions package </li></ul><ul><li>When a new web server is added, automatically deploy the solution to it </li></ul><ul><li>Deploy new versions of the Solution </li></ul><ul><li>Solution - A CAB file containing </li></ul><ul><ul><li>Manifest.xml file </li></ul></ul><ul><ul><li>All the files for the Features, Web Parts, Site or list def changes, etc... that make up your solution </li></ul></ul>
    28. 28. Solution deployment <ul><li>“ Featurize” your custom development </li></ul><ul><ul><li>Any SharePoint element </li></ul></ul><ul><ul><li>Changes in your web.config </li></ul></ul><ul><ul><li>Copying files to specific web folders </li></ul></ul><ul><li>Deploy features and other assets by WSP Solution package </li></ul>
    29. 29. Development and testing <ul><li>Your development machine does not go into production </li></ul><ul><li>Use a buildserver </li></ul><ul><li>Always test with different set of browsers (level 1 and level 2) </li></ul><ul><li>Watch out for rights </li></ul>
    30. 30. CodePlex <ul><li>The starting point of a lot of new SharePoint functionality </li></ul><ul><li>Community Kit For SharePoint </li></ul><ul><li>SharePoint learning kit </li></ul><ul><li>SharePoint Features </li></ul><ul><li>Podcasting kit for SharePoint </li></ul><ul><li>Smartpart for SharePoint </li></ul><ul><li>SharePoint AJAX toolkit </li></ul>
    31. 31. Resources <ul><li>Best practices resource center for SharePoint 2007 </li></ul><ul><li>Patterns and practices SharePoint guidance </li></ul><ul><li>Best practices for SharePoint guidance </li></ul><ul><li>SharePoint Deployment Planning Services </li></ul><ul><li>Downloadable book: Design and build sites for Office SharePoint Server 2007 </li></ul><ul><li>Other resources such as / / </li></ul>
    32. 32. <ul><li>Gary Lapointe STSADM </li></ul><ul><li>Firebug </li></ul><ul><li>Yslow </li></ul>More resources
    33. 33. <ul><li>Questions? </li></ul>
    34. 34. <ul><li>Alexander Meijers </li></ul><ul><li>[email_address] </li></ul><ul><li>Roel Hans Bethlehem </li></ul><ul><li>[email_address] </li></ul>Contact us