Exporting reusable workflows from SharePoint Designer 2010 to Visual Studio 2010

There are a couple of blogs out there about exporting reusable workflows but none of them really cover the problems that I ran into recently.

Exporting workflows

First of all the important question is why doing this in the first place? SharePoint Designer (SPD) is the tool that you started with to create your workflow … Did you make the wrong decision during the beginning of your project and now you changed your mind? Maybe you should just start all over again from scratch …

In my case, I want my customer to be able to update the workflow at any time but they shouldn’t need to use Visual Studio. (Reason to use SPD)

Also, SPD left some bits in the wsp which I already deleted ( e.g. I created a task which I later decided wasn’t required. the .xsn file for this task and the content type is still there in my .wsp)

When you try to deploy a .xoml file which is created by SPD you need a converted version of this file in your VS2010 project (using the import function). This then might make SPD not happy when you try to edit it at a later stage in SPD.

Finally I wanted to get more control over my declarative workflow. In my workflow I had multiple approval steps. this resulted in two content types Approval and Approval(1), or even worse Approval_x0028_1_x0029_. Next to this every file seems to need a number in SPD. In Viaul Studio you can clean this up.

Moving the SharePoint Designer workflow to Visual Studio

Most importantly after converting the workflow I was still able to get SPD  to update the workflow.

How did I do this? Here are the rough steps:

  1. Export your workflow from SPD to a wsp file.

  2. Extract all files from the .wsp (you could use winrar)

  3. Create a new wspbuilder project ( see codeplex)

  4. Copy all the files from the .wsp into your project

  5. Now you can build and deploy the workflow using wsp builder.

If your not very keen on using wspbuilder then you could follow my example where I have multiple projects, of which one is my SPD workflow project using wspbuilder, and all the other ones are using VS 2010 standard builder.

Advertisements

Please leave a comment or feedback

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.