Showing posts with label Deploy sharepoint webpart to bin. Show all posts
Showing posts with label Deploy sharepoint webpart to bin. Show all posts

Friday 16 March 2012

Deploy sharepoint webpart to bin


  Simply put, I had three web parts that I wanted to package up as features into a .wsp so I could run stsadm to deploy them to different environments, such as q/a and production. I followed the following two steps:
  1. First, I used WSPBuilder to create my wsp, packaging the web parts into features. I also indicated at this point that I wanted it to be a bin deployment.
  2. Once the web part assembly dll was deployed to bin, I made the required CAS policy changes, otherwise the web parts wouldn't run. This involved a policy file and the web.config.

So, as far as step 1 goes, there are few things that will need to be done:
  1. Create an 80\bin\ folder in your solution explorer.
  2. Change your project's Build Output Path to that new folder.
  3. Change AssemblyInfo.vb to import System.Security and also to AllowPartiallyTrustedCallers.
  4. Create a mirror folder structure to the 12 hive in Solution Explorer: 12/Template/Features with a folder below that for each web part/feature to be deployed. Ensure each web part/feature folder has a feature.xml, elements.xml, and .webpart.
  5. Download WSPBuilder and install it. It will be added to the Tools menu. Click Tools -> WSPBuilder - Build WSP. The manifest.xml will be autogenerated and added to the .wsp along with the assembly's dll, and the web parts' feature.xml, elements.xml, and .webpart files.
  6. Run stsadm on the resulting .wsp to add solution, deploy solution, then activate the features.

Finally, step 2 involves setting the proper CAS permissions:
  1. Make a copy of wss_minimaltrust.config (in 12/CONFIG on server) and edit this copy as it will be the required custom policy file we need.
  2. Add a reference to SharePointPermission in the <SecurityClasses> section.
  3. Add a new custom permission set that lists the required permissions. Copy and paste the permission set SPRestricted, and in the new copy, add a line for SharePointPermission.
  4. Next, add a code group that links the newly created permission set with your assembly, so SharePoint knows when to apply the permissions.
  5. Finally, hop over to your web.config and make sure its using custom trust level, and that custom trust level is pointing to your new policy file.
If you want a step-by-step with code to copy/paste, you can find it here at How to deploy a SharePoint web part to bin. You will also find links to other pages that also show how to do this.

Pages

Followers