Deploying Code In SharePoint


Published on

How to deploy code in SharePoint. Given at SharePoint Saturday Kansas City - February 2009

Published in: Technology
1 Like
  • Be the first to comment

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

No notes for slide
  • Demo manual deployment. Copy a binary out with a web part and manually copy DLL to the GAC.Demo how to export an existing .webpart definition to build from.
  • Explain the manifest.xml and cab.ddf
  • VSeWSS
  • Demo the use of BDC Tools, the MetaData Model and the Import Process
  • Deploying Code In SharePoint

    1. 1. Deploying Code in SharePoint<br />Presenter: Corey Roth<br />Senior Consultant<br />Stonebridge<br />Blog:<br />
    2. 2. Corey Roth<br />Consultant for Stonebridge<br />Worked in Consumer Electronics, Travel, Advertising, and Energy industries<br />Currently doing MOSS development specializing in Enterprise Search, Workflow, and ECM<br />Microsoft Award for Customer Excellence (ACE) Winner<br />E-mail:<br />Blog: (mirrored on<br />
    3. 3. Challenges for New Developers<br />Learning the API<br />Setting up the development environment<br />Debugging<br />
    4. 4. Deployment<br />
    5. 5. 12 Hive<br />Location of most key SharePoint files: C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions12<br />
    6. 6. 12 Hive (Continued)<br />
    7. 7. Deploying Binaries – Two Options<br />GAC Deployment – Not recommended unless absolutely necessary (i.e.: Event Recivers, Timer jobs, Workflows, etc).<br />Requires application pool to be reset after every deployment.<br />Allows code to execute with full trust<br />Acceptable for new developers starting out because it is easier<br />
    8. 8. Deploying Binaries – Two Options<br />Bin Folder Deployment – Recommended but more complex<br />Requires a developer to specify code access security settings or running SharePoint with full trust<br />Does not require application pool to be reset<br />Recommended approach but more complicated to implement<br />
    9. 9. SafeControls<br />SharePoint won’t execute a web part or user control unless it knows it is safe<br />Declare an assembly and namespace safe in web.config<br />SafeControls element<br />Can be automated using a solution package (.wsp)<br />
    10. 10. Deployment Options<br />Manually copy binaries, feature files, pages, and controls to appropriate folders on SharePoint server<br />Create a Feature – Would still have to manually copy files<br />Create a Solution Package (.wsp) – A cab file that contains a manifest telling SharePoint how to deploy files and what features to install<br />
    11. 11. Ghetto Deployment (Manual)<br />Manually copy binaries to GAC or bin folder<br />Manually upload .webpart files to web part gallery<br />Manually copy user controls to CONTROLTEMPLATES folder<br />Manually copy features files into FEATURES folder<br />Manually copy anything else that you might need to deploy<br />
    12. 12. Building and Deploying a Web Part<br />Deploys similarly to a user control<br />.webpart (or .dwp) file tells SharePoint where to find the web part’s code<br />Use a feature to add the web part to the gallery<br />Complete instructions at my blog<br /><br />
    13. 13. Demo<br />
    14. 14. Features<br />A series of XML files that allow you to make changes to SharePoint<br />Located in the TEMPLATEFEATURES folder in the 12 hive<br />Changes can include creating lists, pages, content types, site columns, and web parts.<br />Can copy files into SharePoint’s virtual file repository but the template files still have to be deployed to the 12 hive first<br />
    15. 15. Solution Packages (.wsp files)<br />A cab file that can copy binaries, features, pages, and other files to SharePoint.<br />Defined by manifest.xml and cab.ddf files<br />Created with makecab.exe<br />Can copy binaries to bin folder or GAC<br />Can apply safe control and code access security settings<br />Automatically installs features<br />Can also be upgraded and retracted / deleted.<br />Can be automated with VSeWSS, WSPBuilder, stsdev, etc.<br />
    16. 16. cab.ddf<br />Specifies which files to copy into the wsp file.<br />You must specify each binary, page, XML or .webpart file you want to be copied in this file<br />Syntax for each file is source <space> destination<br />The destination specified is the location in the file not the location on the SharePoint server.<br />
    17. 17. Manfiest.xml<br />Specifies which features to activate and which files to copy into the 12 hive.<br />Can deploy SiteTemplates<br />Specifies SafeControl settings in web.config<br />Configures Code Access Security (CAS) settings<br />Paths are relative to the TEMPLATES folder in the 12 hive<br /><br />
    18. 18. Manfiest.xml Elements<br />FeatureManifests – Specifies feautres to activate<br />TemplateFiles – Required for any file that you want copied that is not a binary or feature file<br />Assemblies – Required for each binary to be deployed <br />DeploymentTarget – WebAppplication or GlobalAssemblyCache<br />SafeControls – Adds SafeControl entry to web.config<br />CodeAccessSecurity – Applies CAS policies to assembly<br />
    19. 19. Deploying your solution (.wsp) file<br />Add the solution with stsadm<br />stsadm –o addsolution –filename mysolution.wsp<br />Deploy the solution with stsadm or Central Admin -> Solution Management<br />stsadm –o deplysolution –name mysolution.wsp –immediate –allowGacDeployment –allowCasPolicies<br />stsadm –o execadmsvcjobs<br />-o upgradesolution – Upgrades an existing solution’s files<br />-o retractsolution – Remove the solution from a given site(s)<br />-o deletesolution – Removes the solution from the solution store<br />
    20. 20. Building a User Control with Visual Studio<br />Web Application Project<br />Reference Microsoft.SharePoint.dll<br />Must be registered as safe for SharePoint to execute<br />Typically deployed to bin folder using Code Access Security<br />Controls are typically deployed to the CONTROLTEMPLATES folder in the 12 hive.<br />_ControlTemplates Virtual Directory<br />Complete instructions are on my blog<br /><br />
    21. 21. Demo<br />
    22. 22. Demo<br />
    23. 23. References<br />Dot Net Mafia Blog<br /><br />Visual Studio Extensions for SharePoint (VSeWSS 1.3) CTP<br /><br />STSDev<br /><br />SharePoint Blogs<br /><br />WSPBuilder<br /><br />
    24. 24. Questions?<br />
    25. 25. Thanks<br />Corey Roth<br /><br /><br />