A number of developers who have tried the SharePoint workflow features in VS 2008 wanted to know more about our support for InfoPath forms deployment. So I'm blogging it here for everyone's reference.

Before diving into details of InfoPath forms deployment here's a little bit of background on workflow and InfoPath forms integration. Typical SharePoint workflows goes through different stages - association, initiation, task completion. Also, workflows might be modified after being initiated. SharePoint supports ASP.NET and InfoPath forms to enable developers to capture user inputs at these different stages. For example, on initiation of a simple document approval workflow you might want to capture the approvers for the document.

To develop InfoPath forms you can either use the VSTO template for InfoPath that also ships with Visual Studio 2008 or InfoPath (with VSTA) itself. Once you have designed the InfoPath form it can be published as an XSN file. There is some great documentation on MSDN regarding this. In general, if you need code (custom event handlers/validation) behind your InfoPath forms you should use the VSTO InfoPath template and create a project alongside your workflow project.

Coming back to SharePoint workflow integration with InfoPath forms - It is very easy to deploy InfoPath forms along with your workflow. All you have to do is to add a relative reference to the form in the feature.xml with the <ElementFile/> element eg:

<ElementFile Location="InfoPathForm.xsn" />

When you press F5 you will see that VS will copy the form alongside your feature.xml files in the 12\TEMPLATE\FEATURES\<featname>\ directory. It must be noted that this is a relative reference to the form and VS will look in the path specified relative to the source location of feature.xml.

You can use the above feature to also install resx files or any other accompanying files. Also, the feature.xml file is processed by SharePoint on feature installation and absolute paths or relative references with ellipsis are not supported (for obvious security reasons). However, you can add references that need to be deployed as subdirectories and we will replicate the hierarchy eg:

<ElementFile Location="InfoPathForms\InfoPathForm1.xsn" />
<ElementFile Location="Resources\Resources.en-us.resx" />

On F5, a subdirectory named InfoPathForms and Resources will be created in the 12\TEMPLATE\Features\<featname>\ directory.

And yeah, don't forget to reference them also in the workflow.xml as an initiation, association, modification or task form, to see them show up at runtime.

Now go ahead and have fun with InfoPath forms!