How to manually deploy a Visual Studio 2005 workflow to SharePoint

Learn which steps are required to manually deploy a custom Visual Studio 2005 workflow to WSS 3.0 or MOSS 2007.

ADVERTISEMENTS

Steps for deploying a Visual Studio workflow to SharePoint

Once you have created a Visual Studio workflow for SharePoint, you’ll have to deploy it to SharePoint before you can attach it to a list or library.

Deploying a Visual Studio workflow to SharePoint is a 3-step process:

  1. Install the DLL for your workflow into the Global Assembly Cache (GAC).
  2. Create the feature.xml and workflow.xml files.
  3. Install and activate the feature for the workflow.

1. Install the workflow DLL to the Global Assembly Cache (GAC)

Before you can install the workflow DLL in the GAC, you have to sign it with a strong name key. You can do this via the Signing section on project’s Properties window.

Once you’ve signed the DLL and built the project, you can use the gacutil.exe tool to install the DLL for your workflow to the GAC.

gacutil -i YourWorkflowDLL.dll

2. Create the feature.xml and workflow.xml files

If you installed the Windows SharePoint Services 3.0: Software Development Kit (SDK) (which includes the Workflow Developer Starter Kit), you will have access to code snippets for the feature.xml and workflow.xml files for WSS 3.0.

If you installed the SharePoint Server 2007 SDK: Software Development Kit (which includes the Enterprise Content Management Starter Kit), you will have access to code snippets for the feature.xml and workflow.xml files for MOSS 2007.

Code snippets for Visual Studio 2005 are installed by default in:
C:\Program Files\Microsoft Visual Studio 8\Xml\1033\Snippets.

Important:
Windows SharePoint Services 3.0 and Microsoft Office SharePoint Server 2007 come with their own feature.xml and workflow.xml files. Pay close attention as to which code snippets you are using, because the code snippets for WSS 3.0 will not work for workflows deployed to MOSS 2007 and vice versa.

Files for deploying a workflow to WSS 3.0

In Visual Studio 2005, in the feature.xml file, right-click, select Insert Snippet, and then select Snippets > Windows SharePoint Services Workflow > Feature.xml Code.

This will add the following XML code:

<Feature Id="GUID"
Title="Default Title"
Description="This feature is a workflow that ..."
Version="12.0.0.0"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="workflow.xml" />
</ElementManifests>
<Properties>
<Property Key="GloballyAvailable" Value="true" />
</Properties>
</Feature>

You can use GuidGen.exe by accessing it from the Tools > Create GUID menu to generate a GUID to use as the Id for the feature.

Enter a Title, Description, and the Scope for your workflow.

To add the workflow.xml code, open the workflow.xml file, right-click, select Insert Snippet, and then select Snippets > Windows SharePoint Services Workflow > Workflow.xml Code.

This will add the following XML code:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Workflow
Name="My Workflow"
Description="This workflow ..."
Id="GUID"
CodeBesideClass="ProjectName.Workflow1"
CodeBesideAssembly="ProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=publicKeyToken"
TaskListContentTypeId="0x000"
AssociationUrl="_layouts/MyAssocForm.aspx"
InstantiationUrl="_layouts/MyInitForm.aspx"
ModificationUrl="_layouts/MyModForm.aspx"
StatusUrl="_layouts/WrkStat.aspx">
<Categories/>
<MetaData>
<Modification_GUID_Name>
Name of Modification
</Modification_GUID_Name>
</MetaData>
</Workflow>
</Elements>

Note: You can retrieve the publicKeyToken by going to the GAC located at C:\WINDOWS\assembly, locating the DLL for your workflow, opening its Properties dialog box, and copying the publicKeyToken.

You must perform similar actions when creating the feature.xml and workflow.xml files for a MOSS 2007 workflow.

Files for deploying a workflow to MOSS 2007

In Visual Studio 2005, in the feature.xml file, right-click and select Insert Snippet, and then select Snippets > SharePoint Server Workflow > Feature.xml Code.

This will add the following XML code:

<Feature Id="GUID"
Title="Default Title"
Description="This feature is a workflow that ..."
Version="12.0.0.0"
Scope="Site"
ReceiverAssembly="Microsoft.Office.Workflow.Feature, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
ReceiverClass=
"Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="workflow.xml" />
<ElementFile Location="MyForm.xsn"/>
</ElementManifests>
<Properties>
<Property Key="GloballyAvailable" Value="true" />
<!-- Value for RegisterForms key indicates the path to the forms relative to feature file location -->
<!-- if you don't have forms, use *.xsn -->
<Property Key="RegisterForms" Value="*.xsn" />
</Properties>
</Feature>

To add the workflow.xml code, open the workflow.xml file, right-click, select Insert Snippet, and then select Snippets > SharePoint Server Workflow > Workflow.xml Code.

This will add the following XML code:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Workflow
Name="My Workflow"
Description="This workflow ..."
Id="GUID"
CodeBesideClass="ProjectName.Workflow1"
CodeBesideAssembly="ProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=publicKeyToken"
TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160"
AssociationUrl="_layouts/CstWrkflIP.aspx"
InstantiationUrl="_layouts/IniWrkflIP.aspx"
ModificationUrl="_layouts/ModWrkflIP.aspx"
StatusUrl="_layouts/WrkStat.aspx">
<Categories/>
<!-- Tags to specify InfoPath forms for the workflow; delete tags for forms that you do not have -->
<MetaData>
<Association_FormURN>associationFormURN</Association_FormURN>
<Instantiation_FormURN>
instantiationFormURN
</Instantiation_FormURN>
<Task0_FormURN>taskFormURN</Task0_FormURN>
<Modification_GUID_FormURN>
modificationURN
</Modification_GUID_FormURN>
<Modification_GUID_Name>
Name of Modification
</Modification_GUID_Name>
<AssociateOnActivation>false</AssociateOnActivation>
</MetaData>
</Workflow>
</Elements>

3. Install and activate the feature for the workflow

To install and activate a workflow, you must:

  1. Copy the feature.xml and workflow.xml files to a folder under SharePoint’s FEATURES directory.
  2. Use stsadm.exe to install and activate the feature.

These actions are described in the Install.bat file that comes with the SharePoint workflow templates in Visual Studio 2005.

The feature.xml and workflow.xml files must be copied to a new folder with the name of your workflow feature under the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\ directory.

Then you can use the installfeature and activatefeature operations of stsadm.exe to install

stsadm -o installfeature -filename <FeatureFolderName>\feature.xml -force

and activate

stsadm -o activatefeature -filename <FeatureFolderName>\feature.xml -url http://<ServerName>

the workflow feature.

Once you have installed the workflow feature, you have to recycle the SharePoint application pool or reset IIS for the changes to take effect.

Related Articles

ADVERTISEMENTS