Export (0) Print
Expand All

How to: Use Visual Studio extensions for Windows SharePoint Services to Package a Workflow in a Web Solution Package

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

A SharePoint solution file has a .cab format but a .wsp extension. Visual Studio extensions for Windows SharePoint Services contains functionality to create Web solution packages (WSPs) and deploy solutions within Visual Studio. Visual Studio provides tools to develop workflows for SharePoint. You can use Visual Studio extensions for Windows SharePoint Services to package and deploy those workflows. This topic demonstrates how to do this. It does not discuss the specifics of creating workflows. The workflow is included only to demonstrate the steps for packaging it in a WSP. For more information about creating workflows, download Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions User Guide, Version 1.1 on MSDN. This topic assumes that you have created a SharePoint site.

To create a SharePoint workflow project

  1. In Visual Studio, point to New on the File menu, and then click Project.
  2. In the Project types pane, under Visual C#, click Workflow. In the Templates pane, click SharePoint 2007Sequential Workflow. Name the project MySharePointWorkflow. Click OK.
  3. In the New Office SharePoint Workflow dialog box, the name should be MySharePointWorkflow. Enter a SharePoint URL for testing the workflow. Click Next. Note that the SharePoint site must include lists or documents.
  4. In the Select the lists you will use when debugging dialog box, clear the Automatically associate workflow check box, and then click Finish.
  5. In Solution Explorer, right-click Workflow1.cs, click Rename, and then rename the file to MySharePointWorkflow.cs.
  6. Click Yes to renaming all the references.

Figure 1 illustrates the MySharePointWorkflow directory structure.

Ff650086.HowTo_packworkflow_flowdir01(en-us,PandP.10).png

Figure 1
MySharePointWorkflow project

Figure 2 illustrates the designer view of the workflow.

Ff650086.HowTo_packworkflow_flowdiag02(en-us,PandP.10).png

Figure 2
A basic workflow

The next procedure demonstrates how to create a WSP project and package the workflow.

To create a WSP project and package the workflow

  1. In Solution Explorer, right-click the solution, point to Add, and then click New Project.
  2. In the Add New Project dialog box, in the Project Types pane, expand VisualC#, and then click SharePoint. In the Templates pane, click Empty. Name the project MySharePointWorkflowWSP. Click OK.
  3. In Solution Explorer, right-click MySharePointWorkflowWSP, point to Add, and then click Existing Item.
  4. Navigate to the MySharePointWorkflow project. Click the MySharePointWorkflow.cs, MySharePointWorkflow.designer.cs, and workflow.xml files. (Use CTRL+click to perform multiple selections.) In the Add drop-down box, click Add as Link.
  5. In Solution Explorer, right-click the References node of MySharePointWorkflowWSP, and then click Add Reference. In the dialog box, click the .NET tab. Scroll down, click the following files (use CTRL+click), and then click OK:
    • System
    • System.Core
    • System.Drawing
    • System.Workflow.Activities
    • System.Workflow.ComponentModel
    • System.Workflow.Runtime
    • Windows® SharePoint® Services
    • Windows® SharePoint® Services Workflow Actions
  1. Open MySharePointWorkflow.cs. If you are in the Designer view, right-click in the designer, and then click View Code. Remove the following line of code
    using Microsoft.Office.Workflow.Utility;
    
    
  2. Provide a unique identifier for the Elements element in the Workflow.xml file. To do this, do the following:
    1. On the Tools menu, click Create GUID. Click Registry Format. Click New GUID. Click Copy. Click Exit.
    2. Add an Id attribute at the end of the Elements node in the Workflow.xml file
    3. Paste in the GUID. Remove the opening and closing curly braces. The following code is an example of the revised Elements node.
      <Elements xmlns="http://schemas.microsoft.com/sharepoint/" Id="3ED87B37-
                0F39-4a9b-91D7-CAF41556792B">
      
      
    4. Save the changes to Workflow.xml.
  3. In Solution Explorer, click the WSP View tab. If the WSP view is not shown, point to Other Windows on the View menu, and then click WSP View.
  4. Click the refresh button. The MySharePointWorkflowWsp project appears. Expand the project.
  5. A feature named Untitled 1 exists. Press the F2 key to rename both the feature and feature subfolder to MySharePointWorkflow. Figure 3 illustrates the MySharePointWorkflowWSP structure.

    Ff650086.HowTo_packworkflow_wsp_step10(en-us,PandP.10).png

    Figure 3
    WspProject structure

  6. Open the Feature.xml file in the WSP view. Change the Scope attribute in the Feature element from Web to Site.
  7. Update the Title attribute from Untitled 1 to My SharePoint Workflow.
  8. In Solution Explorer, right-click MySharePointWorkflowWSP, point to Add, and then click Existing Item. Navigate to the MySharePointWorkflow project, and then click the Key.snk file. In the Add drop-down box, click Add as Link.
  9. Delete the MySharePointWorkflowWSP.snk file from the MySharePointWorkflowWSP project's Properties folder.
  10. Right-click MySharePointWorkflowWSP and click Properties. On the Signing tab, choose the Key.snk file from the drop-down box to sign the assembly. Use CTRL+S to save the property settings.
  11. In the MySharePointWorkflowWSP project, open the Workflow.xml file. Update the CodeBesideClass attribute and the CodeBesideAssembly attribute. The CodeBesideClass should match the namespace and class name of the MySharePointWorkflow.cs file. The CodeBesideAssembly attribute should match the assembly name of the MySharePointWorkflowWSP project. The following code demonstrates what the file should look like with the names used in this procedure.
    ....
    <Workflow
    Name="MySharePointWorkflow"
    Description="My SharePoint Workflow"
    Id="2bb8ba99-e2cb-42f8-bbcc-6166fcbfb624"
         CodeBesideClass="MySharePointWorkflow.MySharePointWorkflow"
         CodeBesideAssembly="MySharePointWorkflowWSP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=069a99ef300e498a">
    ....
    
    
  12. Right-click MySharePointWorkflowWSP, and then click Deploy.
  13. Verify that the MySharePointWorkflowWSP.wsp file exists in the bin\debug folder of the MySharePointWorkflowWSP project.
  14. Verify that the Workflow feature has been deployed on SharePoint. Open the SharePoint site. On the Home tab, click Site Actions, and then click Site Settings. Under Galleries, click Workflows. The list of workflows on the Site Collection Workflows page should include the workflow that you created.

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Show:
© 2015 Microsoft