Presentation is loading. Please wait.

Presentation is loading. Please wait.

SharePoint Development Tools and Techniques for Creating, Packaging, Deploying, and Maintaining Code Sergio Otoya Technical Director LivePoint and echoTechnology.

Similar presentations


Presentation on theme: "SharePoint Development Tools and Techniques for Creating, Packaging, Deploying, and Maintaining Code Sergio Otoya Technical Director LivePoint and echoTechnology."— Presentation transcript:

1 SharePoint Development Tools and Techniques for Creating, Packaging, Deploying, and Maintaining Code Sergio Otoya Technical Director LivePoint and echoTechnology

2 Common Questions What do you develop with/for SharePoint technology? What kind of development environment do we recommend? What kind of tools are available? How should you deploy your handiwork? How can you maintain it?

3 Agenda Challenges to development with SharePoint technology The Visual Studio 2005 Extensions for WSS 3.0 Developing custom SharePoint solutions Packaging of what is built Deploying SharePoint solutions Deploying Web Parts Upgrading SharePoint Solutions Retracting SharePoint Solutions

4 Developing with SharePoint Technology Foundation on.NET development You learn object models You call Web services You develop assemblies You create XML files You create ASPX pages You create workflow templates for Windows Workflow Foundation

5 Developing with SharePoint Technology Differences from “Mainstream” ASP.NET development You create code to be placed in galleries You create metadata to be placed in galleries Your site is a set of metadata, not a set of code assets Site metadata references a site definition Site definitions references pages, Web parts, content modules, etc. List metadata references a list definition, field definitions, receivers, etc. Instance data contains differences between site and its definitions When you build and your site application, you: Deploy site definition info Deploy code assets Execute WSS Create one site Use and debug that site to trigger pages, components, etc.

6 Anatomy of a Site Home Page Request The Stand-Alone ASP.NET Site Way Database Browser: HTTP GET http://server/appname IIS / ASP.NET C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx

7 List Definition schema.xml allitems.aspx Anatomy of a Site Home Page Request The Windows SharePoint Services Way Database Site Definition onet.xml Default.aspx all work and no play makes Jack a dull boy retrieve list data, get list def reference /bin or GAC WebPart1.dll WebPart2.dll Web Part Assemblies retreive list def get site def reference (Uncustomized site) WSS retrieve site def Browser: HTTP GET http://server/appname IIS / ASP.NET page built in memory

8 Many Sites On A Single Farm The Stand-Alone ASP.NET Site Way Browser: HTTP GET http://server/appname IIS / ASP.NET Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx Database C:\inetpub\wwwroot\appname web.config default.aspx… myapp.css mycontrol.dll myothercontrol.ascx

9 List Definition schema.xml allitems.aspx Many Sites On A Single Farm The Windows SharePoint Services way Database Site Definition onet.xml Default.aspx all work and no play makes Jack a dull boy /bin or GAC WebPart1.dll WebPart2.dll WSS Browser: HTTP GET http://server/appname IIS / ASP.NET

10 List Definition schema.xml allitems.aspx What You Develop For SharePoint Technology Database Site Definition onet.xml Default.aspx all work and no play makes Jack a dull boy /bin or GAC WebPart1.dll WebPart2.dll WSS Browser: HTTP GET http://server/appname IIS / ASP.NET Assemblies: Web Parts Event Receivers Policies Workflow Activities Workflow Assemblies Timer Jobs Schema: Site Definitions Feature Definitions List Definitions Content Types/Fields Document Templates ASP.NET resources: Site Pages Application Pages Images Style Sheets User Controls Master Pages Navigation Controls Data Manipulation: (via Object Model) Web Services (which call the Object Model) Remote Clients (which call the Web services) Services: Search, Profiling, Audiences Calculation, Rendering, Data Access, Migration, etc…

11 Development Environment Working Remotely Central Development Server running WSS/MOSS Developer works on client OS Advantages No server software required locally Central backup + code control system Disadvantages Remote debugging can be a challenge Extra work in packaging and deploying work while testing

12 SharePoint Development Environment Working Locally Development on Windows Server 2003 Use it as your workstation (best) Or develop in a Virtual PC (2 nd best) Advantages Productivity increases Local testing and debugging Disadvantages Requires discipline For source control, check-ins to centralized server For ASP.NET assets, copy server content to file system, then check- in to source control In the long run, this is worth it I personally recommend this

13 When Using a VPC for Development (our experience) Assign memory to your VPC 4 Gb on your host environment then assign about 3.5Gb to VPC 3 Gb on your host environment then assign about 2.5b to VPC 2 Gb on your host environment then assign about 1.5Gb to VPC Second Hard disk to host the VPC USB 2.0 minimum But Firewire or eSata is preferred. Secondary bay for Hard disk is even better. Connect to the VPC via Remote desktop Accessing the VPC client slows down the environment Running IE on your host environment rather than inside the VPC or remote session For better performance No outlook rich client (use OWA!) Virtual Server 2005 seems to consume less resources and vpcs are compatible.

14 Application Deployment Windows SharePoint Services 2.0 Development was difficult One Web Part project template for Visual Studio 2003 Deployment was difficult Many manual steps Lack of management tools No easy way to amend existing sites Third party tools such as Echo for SharePoint eventually emerged No good story for updating existing solutions Only automated deployment was for Web Parts.CAB file deployment via stsadm.exe MSI deployment possible but not well-supported No support for creating/deploying schema-based solutions (e.g., site definitions)

15 Improvements in Windows SharePoint Services 3.0 Development VS.NET Extensions for WSS 3.0 ASP.NET 2.0 Events Everywhere Improved APIs WSS Features Community Tools Packaging Solutions (WSP) VS Extensions for WSS MakeCab.exe Deployment Solution Store SharePoint Central Admin Solution Mgt Full exposure in OM Automated push of solutions out to front-end Web servers Managing Upgrade deployed solutions Retracting solutions

16 Visual Studio 2005 Extensions for WSS 3.0 Latest download (15 March 2007) http://www.microsoft.com/downloads/details.aspx?familyid=19f21e5e-b715-4f0c-b959- 8c6dcbdc1057&displaylang=en Visual Studio 2005 Extensions Project Templates Web Part Team Site Definition Blank Site Definition List Definition Item Templates Web Part Custom Field List Definition (with optional Event Receiver) Content Type (with optional Event Receiver) Module (file set) F5 Debugging SharePoint Solution Generator Generates a Site Definition project from an existing SharePoint site This is not about page editing That’s still SharePoint Designer’s job

17 DEMO Building and Testing a Web Part with the Visual Studio 2005 Extensions for Windows SharePoint Services 3.0 (Sub sites web part)

18 An Example: Building a Custom Site Definition With Solution Generator Create site in browser Customize look and feel Add containers and custom components (eg Web Parts) Generate site definition from customized site With VS Extensions for WSS Add extensions to project e.g., provisioning assemblies Manual clean-up or post-editing Build and Deploy Test and Debug

19 DEMO Building and Extending Custom Site Definition with the Visual Studio 2005 Extensions for Windows SharePoint Services 3.0 (Solution Generator)

20 SharePoint Solutions « Solution » is an official term for a distribution package Solutions consist of:.NET Assemblies Deployment Files Schemas Configurations An installation script (manifest.xml) documents All assets involved in a solution Target locations for all assets Needed modifications to be made to sample configuration files The end result is a SharePoint Solution Package (.WSP file)

21 Solution Manifest File Solution has a SolutionId (GUID) DeploymentServerType ApplicationServer WebFrontEnd ResetWebServer Solution TIP: WSS.XSD gives you intellisense in VS.NET

22 Solution Manifest File Solution FeatureManifests FeatureManifest Used to copy a feature to the features folder Location

23 Solution Manifest File Solution Used to make an assembly available DeploymentTarget GlobalAssemblyCache WebApplication Location SafeControl element used for web.config ClassResources used for things like images FeatureManifests FeatureManifest Assemblies Assembly SafeControl SafeControls ClassResource ClassResources

24 Solution Manifest File Solution Application resource file to include in the solution Location FeatureManifests FeatureManifest Assemblies ApplicationResourceFiles Assembly ApplicationResourceFile

25 Solution Manifest File Solution Code access security policy for a solution PermissionSet groups the permissions for a solution's code access security policy IPermission represent individual permissions Assembly points to the assembly for which PermissionSet needs to be applied FeatureManifests FeatureManifest Assemblies ApplicationResourceFiles Assembly ApplicationResourceFile CodeAccessSecurity PolicyItem IPermission PermissionSet Assembly Assemblies

26 Solution Manifest File Solution Specifies the Web Part files (.dwp or.webpart) to include in the solution FeatureManifests FeatureManifest Assemblies ApplicationResourceFiles CodeAccessSecurity DwpFiles Assembly ApplicationResourceFile PolicyItem DwpFile

27 Solution Manifest File Solution Specifies the resources (e.g. resx files) to include in the solution FeatureManifests FeatureManifest Assemblies ApplicationResourceFiles CodeAccessSecurity DwpFiles Resources Assembly ApplicationResourceFile PolicyItem DwpFile Resource

28 Solution Manifest File Solution Used for custom site definitions Specifying site definition manifests to include in the solution Copy of the WebTemp to its final destination FeatureManifests FeatureManifest Assemblies ApplicationResourceFiles CodeAccessSecurity DwpFiles Resources Assembly ApplicationResourceFile PolicyItem DwpFile Resource SiteDefinitionManifests SiteDefinitionManifest WebTemp

29 Solution Manifest File Solution Specifies the root paths to which solution files are copied. FeatureManifests FeatureManifest Assemblies ApplicationResourceFiles CodeAccessSecurity DwpFiles Resources SiteDefinitionManifests RootFiles Assembly ApplicationResourceFile PolicyItem DwpFile Resource SiteDefinitionManifest RootFile

30 Solution Manifest File Solution Specifies the template files to include in the solution. FeatureManifests FeatureManifest Assemblies ApplicationResourceFiles CodeAccessSecurity DwpFiles Resources SiteDefinitionManifests RootFiles TemplateFiles Assembly ApplicationResourceFile PolicyItem DwpFile Resource SiteDefinitionManifest RootFile TemplateFile

31 Example Packaging a Web Part Web Part Development Web Part Feature Installation Script DDFDDF WP.WSP Wp.dll Resources Feature.xml Wp.webpart ElementManifest.xml Manifest.xml

32 DEMO A closer look at a Web Part SharePoint Solution

33 Example Packaging a Site Definition Provision Code DDFDDF MySite.WSP Provision Feature MySite.dll feature.xmlprovisioner.xml Site Definition Feature feature.xmlelementManifest.xml Site Definition Schemas ONET.XML WebtempMySite.xml # Features (lists/libraries) feature.xmlelementManifest.xml Installation Script Manifest.xml

34 Solution Generator Gotchas Resource strings get expanded for the original site’s language Only one configuration is extracted (e.g. STS#0) Works best with the web application on port 80 Use host file and alternate access mappings otherwise

35 DEMO A closer look at the Site Definition SharePoint Solution

36 Deploying the Solution Add.WSP to the solution store Via command line using STSADM Via Central Administration Deploy to all or individual Web Applications Via Central Administration (solution mgmt) Via Command-line Via Object Model Stsadm –o addsolution –filename mypackage.wsp Front-End Web Servers Solution Store stsadm -o deploysolution -name mypackage.wsp –local -url IISWebApp

37 DEMO Deploying a Custom Web Part (Subsites)

38 Sidebar Topic: Code Access Security and Web Parts Web Part assemblies deployed to a Web Application’s /bin folder depend on trust-level set in web.config Best practice Keep the Web Application’s trust-level at minimal, medium at the most Let Web Parts ask for needed permissions Administrator during deployment grants these permissions Manual rebuild of WSP needed if working with Visual Studio.NET Extensions for WSS 3.0

39 CAS Policy in Manifest.xml <PermissionSet class="NamedPermissionSet" version="1" Description="My webpart's permission set">

40 Manual Rebuild of WSP Create DDF file Make a call to MakeCab.exe Deploy the Solution Activate Feature in site.OPTION EXPLICIT.Set CabinetNameTemplate=WeatherWebPartPackage.wsp.set DiskDirectoryTemplate=CDROM.Set CompressionType=MSZIP.Set UniqueFiles="OFF".Set Cabinet=on manifest.xml.Set DestinationDir=Assemblies Assemblies\WeatherWebPart.dll.Set DestinationDir=WeatherWebpart WeatherWebpart\feature.xml WeatherWebpart\elementManifest.xml WeatherWebpart\WeatherWebPart.webpart makecab.exe” /f WeatherWebPart.ddf stsadm -o addsolution -filename WeatherWebPartPackage.wsp stsadm -o deploysolution -allowCasPolicies -name WeatherWebPartPackage.wsp –local -url IISWebApp

41 What happens during deployment? New custom CAS policy file is created with: Copy of content of active policy file Plus the permissions granted to the Web Part Replaces original trust level in web.config <trustLevel name="WSS_Minimal" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\config\wss_minimaltrust.config" /> <trustLevel name="WSS_Custom" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\config\wss_custom_wss_minimaltrust.config" />

42 Upgrading a Solution General Rules Things you can do Add new files Remove old versions of files Add new features Update/change receiver assembly Add/change feature elements (element.xml files) Add or change feature properties Things you cannot do Remove old features Change a feature ID or scope Remove feature elements (element.xml files) Remove feature properties

43 Upgrading a Solution Process MySolution.wsp (“version 1.0.0.0”) MySolution.wsp (“version 2.0.0.0”) MySolution.wsp Stsadm –o addsolution –filename mysolution.wsp Deploy Solution Stsadm –o upgradesolution -name mysolution.wsp –filename mysolution.wsp –immediate -allowgacdeployment SolutionID must be the same!

44 Pitfalls Classic rules of code updates still apply Don’t break interfaces For Web Parts, don’t break layout of property data Solutions themselves do not contain version information You version their internal components The Solution Management pages in SharePoint Central Administration do not show version information VS.NET Extensions for WSS 3.0 cannot perform an upgrade You can only do this via STSADM or an object model call.resx files can’t be deployed to app_globalresources So you have to embed resources in assemblies We’re looking into what we can do about this ASAP

45 DEMO Upgrading Web Parts

46 “Upgrading” Metadata Sites, lists, etc., based on feature defs, site defs, etc., will not survive an update Only changes from definitions are stored in database Change data depends on definition being stable Data will conform to original schema Your only option is to: Edit the original definition to mark it as hidden Create a new definition in the same solution New ID and new target folder Same display name Update the solution Script a bulk update of old sites Tools like Echo for SharePoint can help

47 How do you upgrade web parts? Once the web part has been deployed to many sites… You have to add and remove the web part manually Or write scripts to replace properties When writing scripts/custom code, beware of: Special web part types (e.g. listview and dataview web parts) Differences between V2 style and v3 style web parts (.dwp and.webpart) Web part connections to other web parts Activating the feature before adding the web part (if web part installed as part of a feature)

48 How echo for Sharepoint can help you Replicate design changes in bulk Add/replace/remove web parts (dataviews, listviews, connections, etc) Activate/deactivate features Add lists/update list definitions (security, workflow associations, columns, views, settings, etc) Site security, alerts, settings, etc. Load documents and list items How? Make the changes to one site/list/web part Point to a source Point to multiple destinations Change management Move your changes from dev to staging to production.

49 Retracting Solutions Process of removing assemblies, files, resources, safe control entries, and other solution components from computers to which they have been deployed In cases where a solution is completely retracted, the features contained within a solution are uninstalled from the server farm Use custom logic wrapped in event handlers to avoid breaking changes

50 Batch Files You’ll Need To Create and Use Often Retractsolution Removesolution Addsolution Deploysolution All of the above, in the above order Delete and rebuild a test site Activate the features you need You’ll be writing these yourself, but: You’re not alone It’s not that hard

51 A Final Word on Deployment Models Solutions (.WSPs) are great, but… MSIs offer: EULAs Deployment of assets beyond what is delivered to SharePoint sites (registry settings, register COM objects, install files anywhere in the file system, etc). Hybrid Create a MSI that: Presents a EULA Does non-WSS work Deploys a WSS solution Info and examples forthcoming

52 Other useful tools (but not limited to…) Sharepoint Spy 2007 (from www.echotechnology.com)www.echotechnology.com Allows you to see properties of objects Allows you to compare properties of objects side by side. Echo for Sharepoint 2007 (www.echotechnology.com)www.echotechnology.com Manage dev / staging / production Replication of design changes Content loading BDC Metaman (http://www.bdcmetaman.com)http://www.bdcmetaman.com BDC meta data creation Fiddler HTTP Debugging (http://www.fiddlertool.com)http://www.fiddlertool.com Lutz Roeder Reflector (http://www.aisto.com/roeder/dotnet/)http://www.aisto.com/roeder/dotnet/ Internet Explorer Developer Tool Bar (from ms downloads) Great for reverse engineering wss themes Visual Studio 2005 Extensions for.NET 3.0 (Workflow)

53 DEMO Sharepoint Spy 2007

54 Free Downloads from echoTechnology www.echotechnology.com SharePoint Spy 2007 Sub sites web part Open Containing Folder feature Custom Field Type (authenticated user field) Register for Echo for Sharepoint 2007 beta on our site


Download ppt "SharePoint Development Tools and Techniques for Creating, Packaging, Deploying, and Maintaining Code Sergio Otoya Technical Director LivePoint and echoTechnology."

Similar presentations


Ads by Google