Deploying Code in SharePointPresenter: Corey RothSenior ConsultantStonebridgeBlog: www.dotnetmafia.com
Corey RothConsultant for StonebridgeWorked in Consumer Electronics, Travel, Advertising, and Energy industriesCurrently doing MOSS development specializing in Enterprise Search, Workflow, and ECMMicrosoft Award for Customer Excellence (ACE) WinnerE-mail: corey.roth@gmail.comBlog: www.dotnetmafia.com (mirrored on sharepointblogs.com)
Challenges for New DevelopersLearning the APISetting up the development environmentDebugging
Deployment
12 HiveLocation of most key SharePoint files: C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12
12 Hive (Continued)
Deploying Binaries – Two OptionsGAC Deployment – Not recommended unless absolutely necessary (i.e.: Event Recivers, Timer jobs, Workflows, etc).Requires application pool to be reset after every deployment.Allows code to execute with full trustAcceptable for new developers starting out because it is easier
Deploying Binaries – Two OptionsBin Folder Deployment – Recommended but more complexRequires a developer to specify code access security settings or running SharePoint with full trustDoes not require application pool to be resetRecommended approach but more complicated to implement
SafeControlsSharePoint won’t execute a web part or user control unless it knows it is safeDeclare an assembly and namespace safe in web.configSafeControls elementCan be automated using a solution package (.wsp)
Deployment OptionsManually copy binaries, feature files, pages, and controls to appropriate folders on SharePoint serverCreate a Feature – Would still have to manually copy filesCreate a Solution Package (.wsp) – A cab file that contains a manifest telling SharePoint how to deploy files and what features to install
Ghetto Deployment (Manual)Manually copy binaries to GAC or bin folderManually upload .webpart files to web part galleryManually copy user controls to CONTROLTEMPLATES folderManually copy features files into FEATURES folderManually copy anything else that you might need to deploy
Building and Deploying a Web PartDeploys similarly to a user control.webpart (or .dwp) file tells SharePoint where to find the web part’s codeUse a feature to add the web part to the galleryComplete instructions at my bloghttp://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/22/intro-to-sharepoint-development-how-to-build-and-deploy-a-web-part.aspx
Demo
FeaturesA series of XML files that allow you to make changes to SharePointLocated in the TEMPLATE\FEATURES folder in the 12 hiveChanges can include creating lists, pages, content types, site columns, and web parts.Can copy files into SharePoint’s virtual file repository but the template files still have to be deployed to the 12 hive first
Solution Packages (.wsp files)A cab file that can copy binaries, features, pages, and other files to SharePoint.Defined by manifest.xml and cab.ddf filesCreated with makecab.exeCan copy binaries to bin folder or GACCan apply safe control and code access security settingsAutomatically installs featuresCan also be upgraded and retracted / deleted.Can be automated with VSeWSS, WSPBuilder, stsdev, etc.
cab.ddfSpecifies which files to copy into the wsp file.You must specify each binary, page, XML or .webpart file you want to be copied in this fileSyntax for each file is source <space> destinationThe destination specified is the location in the file not the location on the SharePoint server.
Manfiest.xmlSpecifies which features to activate and which files to copy into the 12 hive.Can deploy SiteTemplatesSpecifies SafeControl settings in web.configConfigures Code Access Security (CAS) settingsPaths are relative to the TEMPLATES folder in the 12 hivehttp://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/09/04/more-on-manfiest-xml.aspx
Manfiest.xml ElementsFeatureManifests – Specifies feautres to activateTemplateFiles – Required for any file that you want copied that is not a binary or feature fileAssemblies – Required for each binary to be deployed DeploymentTarget – WebAppplication or GlobalAssemblyCacheSafeControls – Adds SafeControl entry to web.configCodeAccessSecurity – Applies CAS policies to assembly
Deploying your solution (.wsp) fileAdd the solution with stsadmstsadm –o addsolution –filename mysolution.wspDeploy the solution with stsadm or Central Admin -> Solution Managementstsadm –o deplysolution –name mysolution.wsp –immediate –allowGacDeployment –allowCasPoliciesstsadm –o execadmsvcjobs-o upgradesolution – Upgrades an existing solution’s files-o retractsolution – Remove the solution from a given site(s)-o deletesolution – Removes the solution from the solution store
Building a User Control with Visual StudioWeb Application ProjectReference Microsoft.SharePoint.dllMust be registered as safe for SharePoint to executeTypically deployed to bin folder using Code Access SecurityControls are typically deployed to the CONTROLTEMPLATES folder in the 12 hive._ControlTemplates Virtual DirectoryComplete instructions are on my bloghttp://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/11/18/introduction-to-sharepoint-development-deploy-a-user-control-in-sharepoint.aspx
Demo
Demo
ReferencesDot Net Mafia Bloghttp://www.dotnetmafia.comVisual Studio Extensions for SharePoint (VSeWSS 1.3) CTPhttps://connect.microsoft.com/site/sitehome.aspx?SiteID=428STSDevhttp://www.codeplex.com/stsdevSharePoint Blogshttp://www.sharepointblogs.comWSPBuilderhttp://www.codeplex.com/wspbuilder
Questions?
ThanksCorey Rothcoreyroth@gmail.comwww.dotnetmafia.com

Deploying Code In SharePoint

  • 1.
    Deploying Code inSharePointPresenter: Corey RothSenior ConsultantStonebridgeBlog: www.dotnetmafia.com
  • 2.
    Corey RothConsultant forStonebridgeWorked in Consumer Electronics, Travel, Advertising, and Energy industriesCurrently doing MOSS development specializing in Enterprise Search, Workflow, and ECMMicrosoft Award for Customer Excellence (ACE) WinnerE-mail: corey.roth@gmail.comBlog: www.dotnetmafia.com (mirrored on sharepointblogs.com)
  • 3.
    Challenges for NewDevelopersLearning the APISetting up the development environmentDebugging
  • 4.
  • 5.
    12 HiveLocation ofmost key SharePoint files: C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12
  • 6.
  • 7.
    Deploying Binaries –Two OptionsGAC Deployment – Not recommended unless absolutely necessary (i.e.: Event Recivers, Timer jobs, Workflows, etc).Requires application pool to be reset after every deployment.Allows code to execute with full trustAcceptable for new developers starting out because it is easier
  • 8.
    Deploying Binaries –Two OptionsBin Folder Deployment – Recommended but more complexRequires a developer to specify code access security settings or running SharePoint with full trustDoes not require application pool to be resetRecommended approach but more complicated to implement
  • 9.
    SafeControlsSharePoint won’t executea web part or user control unless it knows it is safeDeclare an assembly and namespace safe in web.configSafeControls elementCan be automated using a solution package (.wsp)
  • 10.
    Deployment OptionsManually copybinaries, feature files, pages, and controls to appropriate folders on SharePoint serverCreate a Feature – Would still have to manually copy filesCreate a Solution Package (.wsp) – A cab file that contains a manifest telling SharePoint how to deploy files and what features to install
  • 11.
    Ghetto Deployment (Manual)Manuallycopy binaries to GAC or bin folderManually upload .webpart files to web part galleryManually copy user controls to CONTROLTEMPLATES folderManually copy features files into FEATURES folderManually copy anything else that you might need to deploy
  • 12.
    Building and Deployinga Web PartDeploys similarly to a user control.webpart (or .dwp) file tells SharePoint where to find the web part’s codeUse a feature to add the web part to the galleryComplete instructions at my bloghttp://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/22/intro-to-sharepoint-development-how-to-build-and-deploy-a-web-part.aspx
  • 13.
  • 14.
    FeaturesA series ofXML files that allow you to make changes to SharePointLocated in the TEMPLATE\FEATURES folder in the 12 hiveChanges can include creating lists, pages, content types, site columns, and web parts.Can copy files into SharePoint’s virtual file repository but the template files still have to be deployed to the 12 hive first
  • 15.
    Solution Packages (.wspfiles)A cab file that can copy binaries, features, pages, and other files to SharePoint.Defined by manifest.xml and cab.ddf filesCreated with makecab.exeCan copy binaries to bin folder or GACCan apply safe control and code access security settingsAutomatically installs featuresCan also be upgraded and retracted / deleted.Can be automated with VSeWSS, WSPBuilder, stsdev, etc.
  • 16.
    cab.ddfSpecifies which filesto copy into the wsp file.You must specify each binary, page, XML or .webpart file you want to be copied in this fileSyntax for each file is source <space> destinationThe destination specified is the location in the file not the location on the SharePoint server.
  • 17.
    Manfiest.xmlSpecifies which featuresto activate and which files to copy into the 12 hive.Can deploy SiteTemplatesSpecifies SafeControl settings in web.configConfigures Code Access Security (CAS) settingsPaths are relative to the TEMPLATES folder in the 12 hivehttp://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/09/04/more-on-manfiest-xml.aspx
  • 18.
    Manfiest.xml ElementsFeatureManifests –Specifies feautres to activateTemplateFiles – Required for any file that you want copied that is not a binary or feature fileAssemblies – Required for each binary to be deployed DeploymentTarget – WebAppplication or GlobalAssemblyCacheSafeControls – Adds SafeControl entry to web.configCodeAccessSecurity – Applies CAS policies to assembly
  • 19.
    Deploying your solution(.wsp) fileAdd the solution with stsadmstsadm –o addsolution –filename mysolution.wspDeploy the solution with stsadm or Central Admin -> Solution Managementstsadm –o deplysolution –name mysolution.wsp –immediate –allowGacDeployment –allowCasPoliciesstsadm –o execadmsvcjobs-o upgradesolution – Upgrades an existing solution’s files-o retractsolution – Remove the solution from a given site(s)-o deletesolution – Removes the solution from the solution store
  • 20.
    Building a UserControl with Visual StudioWeb Application ProjectReference Microsoft.SharePoint.dllMust be registered as safe for SharePoint to executeTypically deployed to bin folder using Code Access SecurityControls are typically deployed to the CONTROLTEMPLATES folder in the 12 hive._ControlTemplates Virtual DirectoryComplete instructions are on my bloghttp://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/11/18/introduction-to-sharepoint-development-deploy-a-user-control-in-sharepoint.aspx
  • 21.
  • 22.
  • 23.
    ReferencesDot Net MafiaBloghttp://www.dotnetmafia.comVisual Studio Extensions for SharePoint (VSeWSS 1.3) CTPhttps://connect.microsoft.com/site/sitehome.aspx?SiteID=428STSDevhttp://www.codeplex.com/stsdevSharePoint Blogshttp://www.sharepointblogs.comWSPBuilderhttp://www.codeplex.com/wspbuilder
  • 24.
  • 25.

Editor's Notes

  • #14 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.
  • #22 Explain the manifest.xml and cab.ddf
  • #23 VSeWSS
  • #25 Demo the use of BDC Tools, the MetaData Model and the Import Process