共用方式為


SharePoint 2010 Extensibility Projects: OBA Deployment Item Template for Visual Studio 2010

Today in my session at the Visual Studio Launch Conference and Expo I’ll be demonstrating an all new VSIX Office Business Application (OBA) Deployment project item template that is now available from the SharePoint and Office Developer & Platform Evangelism Team. There are also two other SharePoint 2010 extensibility projects available; a Silverlight and SharePoint project template and a SharePoint Ribbon project template, but the focus of this blog is on the OBA deployment template. These three SharePoint 2010 Extensibility Projects can be downloaded from the MSDN Code Gallery here, https://code.msdn.microsoft.com/vsixforsp. Please note that these are a beta release and for use at your own risk. So give them a go and send us your feedback for updates – we’re planning another release for these in May.

Ok, let’s give this a quick run through. The assumption here is that you have a test environment with VS 2010 Beta 2 (or later) and Office 2007 or the Office 2010 Beta installed. If you do not, you can visit this blog post for instructions to download a virtual machine for Hyper-V where you can test this out. Once you have downloaded the OBA Deployment VSIX zip file, unzip it at a location of your choice in your test environment. There is Guide document, a .VSIX file and a short demo video. To install the .VSIX template in Visual Studio simply double-click on it, accept the EULA and it will install. You can confirm this by opening Visual Studio 2010 and select the Tools menu and Extension Manager…. Here you’ll see the OBA template has installed.

image   

But now, first things first. Prior to the availability of this template for VS 2010, deploying your document-level add-in for Word or Excel to SharePoint 2010 required a number of steps for the developer. These are fully detailed in the Hands-on Lab document available in the image from the Office 2010 Learning Center on Channel 9. The Security and Deployment module has this lab. However, the OBA Template now does all the heavy lifting for you and makes it very easy to deploy these solutions to SharePoint in just a few simple steps.

Step 1: Create your document-level solution.

Create your document-level solution in Visual Studio. When it is completed, right-click on the project and choose Publish…. The wizard will start, and for my example, I’ll leave the default of publish\ and choose Next.

image

Choose, From CD-ROM or DVD-ROM and click Next.

image

And then click Finish. This will publish the .VSTO deployment manifest and all other deployment files in a publish directory under your solution. This is the location you will navigate to for the .VSTO file when using the OBA template in the next step.

Step 2: Create an empty SharePoint project and add the OBA deployment item.

Open Visual Studio, select New Project…, SharePoint, 2010, Empty SharePoint Project and provide a name, e.g. OBADeployment.

image

When the wizard starts, type the URL to your SharePoint site and select, Deploy as a Farm Solution. Once the wizard completes, we need to add our OBA deployment item. Right-click on the OBADeployment project and select Add, New Item…. Now select the OBA deployment and name it, e.g. OBADeployment. Click, the Add button.

Once the wizard starts, there are three parameters you need to provide.

  1. Browse to the location of your published .VSTO file and select it.
  2. Select a Target Document Library from the dropdown list. The list has all the libraries currently available on the site. But if you do not want to use one that is already there, you can simply type in the name for a new one and it will be created for you.
  3. Lastly, you will enter in the Content Type name you want created in SharePoint for this document. 
    image 

Step 3: Deploy to SharePoint and test.

That’s it, it’s just that simple. The last step is to now deploy the solution to SharePoint and test it out.

Right-click on the solution and select Deploy Solution. Visual Studio will build and deploy your solution to SharePoint.

For security, we need to let Word/Excel know that it can trust the SharePoint site for installing Add-ins. Open either Word or Excel depending on your document-level solution, click on File for the Backstage view and click Options, click Trust Center and then click the Trust Center… button. Select Trusted Locations. Check, the Allow Trusted Locations on my network checkbox. Now click the Add new location… button. Type in the URL to your site and check the Subfolder of this location are also trusted checkbox. Click OK all the way out of the Options dialogs. Close Word/Excel. (Note: there is no need to run the OBA Client Security Prep.cmd provided in the .zip file. The above instructions essentially handle this and it’s better to know the steps.)

With that done, open a browser and navigate to your site and the document library you just created or added the Content Type to. In the ribbon click Library Tools, the Documents tab and New Document and you’ll see your new Content Type in the drop-down. Click on it.

image

After you click on your Content Type, when prompted, Install the the Add-in.

That’s it!!

Enjoy!