Workflow within other Projects

I have seen a couple of forum questions regarding this issue and I thought I will blog it out.

What if you dont want the Workflow as a separate assembly of your application? You are working with a Windows application or a WPF application and you want to be able to add the workflow files to this project system, compile them and let everything be a part of the same assembly.

It is actually very simple. Here you go -

1. Open the WPF project and in a notepad open the WPF.csproj file.

2. In the csproj file you will see the following line -

<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

This basically telling you that the WPF project system is an aggregation on top of the C# project system. The GUID - is the C# GUID and the other one of course is the WPF GUID.

3. Next open a workflow project and there again in the <ProjectTypeGUIDs> you will find the Workflow GUID. Copy this GUID into the WPF <ProjectTypeGUIDs> as follows.

<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

4. Also for successful building this is the line you would have to add in the <Import> section.

<Import Project="$(MSBuildExtensionsPath)\Microsoft\Windows Workflow Foundation\v3.5\Workflow.Targets" />

5. This is it. Now open the WPF project in VS and through the Add New Item dialog you will now see the Workflow Item templates. Add a Workflow file and compile it successfully.

 Some other important notes -

1. In a Windows application there is no <ProjectTypeGUIDs> tag. You would need to add one yourself as below.

<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

and also of course the <Imports> tag.

2. However, this trick works only partially for a Web application. You are able to add exiting workflow files but are not able to add new workflow files as they never appear in the 'Add New Item' dialog even after adding the <projectTypeGUID>. I am working with the ASP.NET team to figure out the issue and would let you know the anwer soon.

Thanks,

Kushal.