Subscribe
E-mail
Download View Codeplex Project Site
Powered by: newtelligence dasBlog 1.9.7174.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Rich Finn
dasBlog MOSS template
When creating a WSP in WSSv3, the common development practice is to create a project in Visual Studio using the Class Library project template. The problem with this is that none of the Workflow item templates are present when you try and add a new item, so how can you add a Workflow without having a one-off Visual Studio project just for your Workflow Feature?
The answer is that you need to make some changes to the project file in Visual Studio to make it happen. The project file (YourProject.csproj - for example) is the file which tells the IDE what files, references, folders, etc. are present so that when the project is built, MSBuild knows how to compile the assembly correctly.
The steps I'll walk you through are intended for Visual Studio 2005. You need to make sure you have the latest version of the Office Server SDK available from MSDN. The steps are pretty much identical for Visual Studio 2008, you just need to make sure you change the targeted version of the .NET Framework to be version 3.0.
First thing - if you have the project under source control, you want to make sure the project file is checked out or else you won't be able to edit it.
Now, you want to unload the project in the IDE. To do this, right-click the project and choose 'Unload Project'
Once the project has been unloaded, right-click the project again and choose 'Edit YOURPROJECT.csproj' This will open the project file for editing in Visual Studio.
Locate the first PropertyGroup in the file at the top, and paste in the following code
<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
as shown below
Now you need to make sure that the proper references are included
Locate the ItemGroup in the project file with the references
Paste in the following references after the last reference in the ItemGroup
<Reference Include="microsoft.office.workflow.tasks"/> <Reference Include="Microsoft.Sharepoint.WorkflowActions"/> <Reference Include="System.Workflow.Activities" /> <Reference Include="System.Workflow.ComponentModel" /> <Reference Include="System.Workflow.Runtime" /> <!-- you probably already have the following --> <Reference Include="Microsoft.SharePoint"/>
Save the project file and reload the project
Now you have the Workflow item templates available, along with the support of the Workflow designer.
The final step is to change the base class for the Workflows you create.
If you are creating a Sequential Workflow, you need to make sure the workflow class inherits from Microsoft.SharePoint.WorkflowActions.SharePointSequentialWorkflowActivity. This will enable the SharePoint Workflow Activities in the Visual Studio Toolbox. There is no base class for the SharePoint State Machine workflow other than the standard System.Workflow.Activities.StateMachineWorkflowActivity.
The one main piece of advice I have is to make sure you set the base class of the Workflow class before you start working on it. When you change the base class, all child activities will be removed from the Workflow. At least they were removed for me!