Export (0) Print
Expand All

How to: Import and Package a Declarative Workflow in Visual Studio

Overview

When you create a declarative workflow in Microsoft® SharePoint® Designer 2010, you can save the workflow as a template in a SharePoint solution package (.wsp) file. In some circumstances, you may need to import your workflow template into the Microsoft Visual Studio® 2010 development system, and repackage it as a Visual Studio project—for example, if you want to create a solution package that contains both a declarative workflow and custom-coded workflow activities. This how-to topic describes how to import and package a workflow template in Visual Studio 2010. It outlines a method to deploy a declarative workflow developed in SharePoint Designer as a SharePoint Solution and Feature. When the Feature in the project is set to a scope of Site, activating the Feature in the site collection's Features gallery makes it available to every website in the site collection without requiring it to be separately activated on every website on which it is going to be used.

Ff798386.note(en-us,PandP.10).gifNote:
The solution package (.wsp file) created by this How-to document can be installed only on Microsoft SharePoint Server site collections, not SharePoint Foundation site collections. There is a method (see How to: Create and Deploy Declarative Workflows in Sandboxed Solutions) to create a package that can be deployed to both SharePoint Server and SharePoint Foundation site collections. However, the Feature created in that method has to be separately activated on each website on which it is to be used.

 

Ff798386.note(en-us,PandP.10).gifNote:
This how-to topic assumes that you have already created a declarative workflow in SharePoint Designer 2010 and saved it as a .wsp file.

Steps

To import a declarative workflow into Visual Studio

  1. In Visual Studio 2010, create a new project by using the Import SharePoint Solution Package template.

    Ff798386.f277052c-5bde-4d09-9b87-a0f33e84bdd8(en-us,PandP.10).png

    Ff798386.note(en-us,PandP.10).gifNote:
    It is important to use the Import SharePoint Solution Package template instead of the Import Reusable Workflow template.

  2. In the SharePoint Customization Wizard, provide a valid local site URL for debugging, and then click Next.
  3. Browse to the location of your solution package, and then click Next.

    Ff798386.a629fc91-6fb6-4ea0-83fd-6b7dd853f642(en-us,PandP.10).png

  4. On the Select items to import page, click Finish.

    Ff798386.4608d736-7ad6-4afe-a4fb-555b17bbecba(en-us,PandP.10).png

  5. When the solution import completes, use the Replace in Files tool to replace all instances of "workflows/" with "_catalogs/wfpub/" throughout the solution.
    Ff798386.note(en-us,PandP.10).gifNote:
    _catalogs/wfpub/ is the virtual directory in which declarative workflow files are stored on each site collection.

  6. Open the .xoml.wfconfig.xml file, and then make the following changes:
    1. In the Template element, change the value of the Visibility attribute to RootPublic from either Public or DraftPublic.
    2. In the Template element, change the value of the DocLibURL attribute to _catalogs/wfpub.
  7. In Solution Explorer, expand the PropertyBags node, and then open the Elements.xml file within the PropertyBags node.

    Ff798386.fafd0824-5192-4163-ad8e-0fd50ec5990f(en-us,PandP.10).png

  8. Locate the PropertyBags node for the .xoml.config.xml file, and then change the value of the NoCodeVisibility property to RootPublic from either Public or DraftPublic.
  9. Press F5 to build and deploy your solution. You can use SharePoint Designer to verify that the workflow was added to your target site.

Show:
© 2014 Microsoft