When working with Workflow projects in Visual Studio, you can add Sequential Workflows, State Machine Workflows, and Activities to a project by right clicking on the project and selecting Add > Sequential Workflow…, Add > State Machine Workflow.., or Add > Activity… menu options.
The problem I run into is that these menu options are only available if you selected one of the Workflow project templates when adding the project to your solution. How can we add workflows to existing projects in our solutions? There are a few hoops to jump through to make this happen, but it can be done.
- Add references to System.Workflow.Runtime, System.Workflow.Activities, and System.Workflow.ComponentModel to your project. Close Visual Studio and open the csproj file in a text editor. Add the following project type Guids to the PropertyGroup element:
- Add the following Import to the Project element:
* <pre><Import Project="$(MSBuildExtensionsPath)\Microsoft\Windows Workflow Foundation\v3.5\Workflow.Targets" /></pre>
- Re-open your solution in Visual Studio. The workflow menu options should now be available for your project.