How to: Deploy a Workflow Template
Applies to: SharePoint Foundation 2010
After you have created your workflow template and any necessary workflow forms, you still have to compile, install, and activate the workflow before you can actually use it in Microsoft SharePoint Foundation 2010.
The basic steps for this are as follows:
Compile your workflow template as a strong-named assembly.
For more information on compiling and strong-naming your assembly, refer to the Visual Studio online help.
Create the feature definition file that provides SharePoint Foundation 2010 with the information necessary to deploy your workflow at the specified scope.
Create the workflow definition file that provides SharePoint Foundation with the information necessary to instantiate and run the workflow.
Set the deploy property so that building the solution deploys the workflow files to the correct location, copies the workflow assembly to the global assembly cache (GAC), and activates the workflow feature in SharePoint Foundation.
The following procedures assume you have created your workflow template using the SharePoint Foundation workflow project template. This project template, included in the Workflow Starter Kit, contains developer features specifically to help you create, deploy, and activate workflows for SharePoint Foundation. The Workflow Starter Kit is available from the Microsoft Download Center.
To Create a Feature Definition File in a SharePoint Foundation Workflow Project
In Microsoft Visual Studio, open your SharePoint Foundation workflow project, and in the Solution Explorer window, double-click the feature.xml file.
Right-click anywhere in the feature.xml file, select Insert Snippet, select SharePoint Foundation Workflow, and then click Feature.xml code.
Replace the highlighted placeholder text with the information from your workflow project. Placeholder text is formatted in all capital letters. This includes:
A GUID to serve as the feature ID. This must be different than the workflow ID specified in the workflow definition file.
The workflow template title.
A description of the workflow template.
The file path, relative to this file, of the workflow definition file. The project default is 'workflow.xml.'
For more information on feature definition XML, see Feature.XML Files. For more information about creating a SharePoint Foundation feature, see Using Features in SharePoint Foundation.
Save your files.
To Create a Workflow Definition File in a SharePoint Foundation Workflow Project
In Microsoft Visual Studio open your SharePoint Foundation workflow project, and in the Solution Explorer window, double-click the workflow.xml file.
Right-click anywhere in the workflow.xml file, select Insert Snippet, select SharePoint Foundation Workflow, and then click workflow.xml code.
Replace placeholders with the information from your workflow project. After you replace a placeholder once, it's replaced throughout the XML. This includes:
The workflow name, description, and unique identifier. This unique identified is for the workflow itself, not the Feature in which the workflow is included.
The code beside assembly and class name of the workflow assembly.
Locations of workflow and task forms used by the workflow.
For more information on creating workflow definition XML files, see Workflow Definitions.
Save your files.
To Install and Activate Your Workflow Template by Using PostBuildActions.bat
In Microsoft Visual Studio, open your SharePoint Foundation workflow project.
In the Solution Explorer window, right-click the project title, and select Properties.
On the Build Events tab, edit the Post-build command line string to deploy your workflow solution. By default, this parameter is specified as 'NODEPLOY'.
To deploy your workflow solution, the command line should read:
call "$(ProjectDir)\Deployment Files\PostBuildActions.bat" "$(ConfigurationName)" "$(ProjectDir)" "$(TargetDir)" "$(TargetName)"
DEPLOY > BuildActions.log
When the NODEPLOY parameter is specified, the workflow assembly is compiled but not deployed.
On the Build menu, select Build Solution.
After Visual Studio has built your workflow solution, it calls the PostBuildActions batch file, which automates moving your workflow solution files to the correct locations for SharePoint Foundation, and activating the workflow feature.
In Debug build mode, this batch file does the following:
Creates the feature directory at the appropriate location on the server.
Copies the feature XML and workflow definition XML files into the feature directory.
Copies the compiled workflow assembly into the Global Assembly Cache (GAC).
Activates the feature in SharePoint Foundation.
In Release build mode, this batch file creates and deploys a .wsp solution file that can be used for deployment on a production server. It does the following:
Replaces placeholder text in the manifest.xml and wsp_structure.ddf files with the information from your workflow project. This includes:
The feature directory name.
The feature XML file name.
The workflow definition XML file name.
The name and relative path of the compiled workflow assembly.
After you have activated your workflow template, it is available for administrators to associate with lists and document libraries on the site where it was activated.
Also, after you have associated the workflow with a specific list or document library, you can debug the workflow.