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:
- 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.
- 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:
- Create an 80\bin\ folder in your solution explorer.
- Change your project's Build Output Path to that new folder.
- Change AssemblyInfo.vb to import System.Security and also to AllowPartiallyTrustedCallers.
- 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.
- 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.
- Run stsadm on the resulting .wsp to add solution, deploy solution, then activate the features.
Finally, step 2 involves setting the proper CAS permissions:
- 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.
- Add a reference to SharePointPermission in the <SecurityClasses> section.
- 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.
- Next, add a code group that links the newly created permission set with your assembly, so SharePoint knows when to apply the permissions.
- 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.