How to Convert a SharePoint Workflow Project to a Visual Studio Tools for Office SharePoint Workflow Project

You do not need to start a brand new project from scratch in order to take advantage of Visual Studio Tools for Office (VSTO) enhancements to SharePoint workflow development.

If you have already created a SharePoint workflow project by using templates from the Enterprise Content Management Starter Kit for 2007 Microsoft Office System, you can convert the project to a VSTO SharePoint workflow project by following the steps outlined in this article.

Why would you do this?

VSTO enhances productivity by automating the manual steps that you must perform to debug a SharePoint workflow project.

VSTO enables you to make changes to the workflow “on the fly”, and then quickly debug those changes by pressing F5.

When you start the debugger, VSTO opens the appropriate SharePoint 2007 Web site and automatically associates the workflow template with the appropriate library or list. VSTO also attaches the Visual Studio debugger to the SharePoint Services 3.0 process named w3wp.exe. All of the steps that you would have to perform manually to facilitate debugging are handled by the tools.

 

To convert a project that that you created with the Enterprise Content Management Starter Kit for 2007 Microsoft Office System, you need to perform the following steps:

  • Add a GUID to the project file that represents a VSTO project type.
  • Re-use configuration files from another VSTO SharePoint workflow project.
  • Sign the workflow assembly, and obtain the public key and assembly version number.
  • Modify the workflow.xml file.
  • Test the project

Add a GUID to the Project File That Represents a VSTO Project Type

 

To add a GUID to the project file that represents a VSTO project type

1. Open the directory that contains the project that you want to convert. For the purpose of these procedures, this project is named MySharePointSequentialWorkflow and it is a project that uses C#.

2. In the MySharePointSequentialWorkflow project directory, locate the MySharePointSequentialWorkflow.csproj file.

3. Open MySharePointSequentialWorkflow.csproj in Notepad.

4. Add the following GUID string to the <ProjectTypeGuids> element: {F8810EC1-6754-47FC-A15F-DFABD2E3FA90};

After you add this GUID, the <ProjectTypeGuids> element should appear as follows:

<ProjectTypeGuids>{F8810EC1-6754-47FC-A15F-DFABD2E3FA90};{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>.

5. Close Notepad.

6. Open SharePoint workflow project in Visual Studio.

The Visual Studio Conversion Wizard appears.

7. In the Visual Studio Conversion Wizard, click Next, Next, Finish, and then Close to complete the wizard.

8. Close Visual Studio.

Re-use Configuration Files from another VSTO SharePoint Workflow Project

You will re-use the following three files from another VSTO SharePoint workflow project:

· .user file.

· workflow.xml

· feature.xml

To re-use configuration files from another VSTO project

1. Open Visual Studio.

2. Create a new VSTO SharePoint sequential or state machine workflow project. For the purpose of these steps, we will call it TempProject.

The New Office SharePoint Workflowwizard will appear. Use this wizard to specify debug configuration settings. You can also accept the default settings by clicking Next, Next, and Finish.

3. After you create the project, close Visual Studio.

4. In Windows Explorer, browse to the location of the TempProject project directory.

5. Locate the TempProject.csproj.user, workflow.xml, and feature.xml files in this project directory. The following illustration highlights these files.

6. Copy these 3 files to the same directory that contains the MySharePointSequentialWorkflow.csproj file.

7. Rename TempProject.csproj.user to MySharePointSequentialWorkflow.csproj.user.

8. Open MySharePointSequentialWorkflow.csproj in Notepad.

9. Type “MySharePointSequentialWorkflow” for the value of the <DisplayName> element.

10. Save the file and close Notepad.

Sign the Workflow Assembly and Obtain the Public Key and Assembly Version Number

 To sign the workflow assembly and obtain the public key and assembly version number

1. Open the MySharePointSequentialWorkflow project in Visual Studio.

2. Sign the MySharePointSequentialWorkflow assembly by creating a new key file. For information on how to do this, see How to: Sign an Assembly (Visual Studio). Name the new key file “key” and do not protect the key with a password.

3. From the Build menu in Visual Studio, click Configuration Manager.

The Configuration Manager dialog box appears.

4. In the Configuration Manager dialog box, ensure that the deploy checkbox is selected and that the Configuration field is set debug.

5. Click Close to close the dialog box.

6. From the Build menu in Visual Studio, click Deploy Solution.

VSTO workflow deployment process installs the MySharePointSequentialWorkflow assembly to the GAC.

Note: You may see the message “Deploy Failed” in the Visual Studio status bar. You can ignore this for now.

7. Open the .NET Framework 2.0 Configuration manager.

In Windows 2003 Server, you can get to the manager by clicking Start -> All Programs->Administrative Tools->Microsoft .NET Framework 2.0 Configuration.

8. In the .NET Framework 2.0 Configuration dialog box, expand the My Computer node, and click Assembly Cache.

9. In the right-pane, click View List of Assemblies in the Assembly Cache.

The assemblies that are in the GAC appear.

10. In the list of assemblies, right-click MySharePointSequentialWorkflow, and then click Properties.

11. In the General tab of the properties dialog box, copy the public key token and assembly version number and paste them into Notepad. You will need this information for later.

12. Close the properties dialog box and close the .NET Framework 2.0 Configuration window.

Modify the workflow.xml File

To modify the workflow.xml file

1. Return to Visual Studio.

2. In Solution Explorer, double-click workflow.xml.

3. In workflow.xml, change the Name, CodeBesideClass, and CodeBesideAssembly strings as highlighted in the bold text below:

      Note: For the Version and PublicKeyToken string, use the values that you obtained by looking at the properties of the workflow assembly.

<?xml version="1.0" encoding="utf-8" ?>

<!-- Customize the text in square brackets.

Remove brackets when filling in, e.g.

Name="[NAME]" ==> Name="MyWorkflow" -->

<Elements xmlns="https://schemas.microsoft.com/sharepoint/">

    <Workflow

         Name="MySharePointSequentialWorkflow"

         Description="My SharePoint Sequential Workflow"

         Id="3b803ba0-1882-4461-80a2-e7baa1e9fc30"

         CodeBesideClass="MySharePointSequentialWorkflow.Workflow1"

         CodeBesideAssembly="MySharePointSequentialWorkflow, Version=3.0.0.0, Culture=neutral, PublicKeyToken=64ad7fb24a8c724a"

         AssociationUrl="_layouts/CstWrkflIP.aspx">

        <Categories/>

        <MetaData>

            <!-- Tags to specify InfoPath forms for the workflow; delete tags for forms that you do not have -->

            <!--<Association_FormURN>[URN FOR ASSOCIATION FORM]</Association_FormURN>

           <Instantiation_FormURN>[URN FOR INSTANTIATION FORM]</Instantiation_FormURN>

            <Task0_FormURN>[URN FOR TASK (type 0) FORM]</Task0_FormURN>

            <Task1_FormURN>[URN FOR TASK (type 1) FORM]</Task1_FormURN>-->

            <!-- Modification forms: create a unique guid for each modification form -->

            <!--<Modification_[UNIQUE GUID]_FormURN>[URN FOR MODIFICATION FORM]</Modification_[UNIQUE GUID]_FormURN>

          <Modification_[UNIQUE GUID]_Name>[NAME OF MODIFICATION TO BE DISPLAYED AS A LINK ON WORKFLOW STATUS PAGE</Modification_[UNIQUE GUID]_Name>

          -->

            <StatusPageUrl>_layouts/WrkStat.aspx</StatusPageUrl>

        </MetaData>

    </Workflow>

</Elements>

Test the Project

To test the project

4. In Solution Explorer, right-click Workflow.cs, and then click View Code.

5. In the constructor, set a break point next to the call to InitializeComponent.

6. Press F5.

7. In SharePoint, start the workflow. For more information on how to start the workflow, see Manually start a workflow on a document item.

8. Execution should stop at the breakpoint that you set in Visual Studio.

- Norm Estabrook

This posting is provided "AS IS" with no warranties, and confers no rights.

Use of included script samples are subject to the terms specified at https://www.microsoft.com/info/cpyright.htm.