Creating InfoPath 2007 Beta 2 Template Part Files in VSTO

June 29, 2006

If your developing template parts for InfoPath 2007 using Visual Studio Tools for Office (VSTO) then you will probably hit a stumbling block when you find there is no way to generate the .xtp file required for adding the Template Part into the VSTO ToolBox.

I couldn’t find a way of doing this within VSTO, so after a bit of poking around, it seems that .xtp files are just cabinet files containing a bunch of the raw data. Thankfully creating cabinet files is simple as there are a couple of command line tools to create them shipped with various SDKs.

So, to generate your .xtp file that you need for the toolbox, just add the following as a post build event. All the files you need for a .xtp file are in the “InfoPath Form Template” subfolder of your template part project.

cabarc N “$(TargetDir)$(ProjectName).xtp” “$(ProjectDir)InfoPath Form Template*.*” >> “$(TargetDir)BuildXtp.log”

This will drop a .xtp file into the target directory (ie bin\debug) when you rebuild your template part. It will also drop a log file in the same location.

If anyone knows of a way to create a .xtp file automatically using built in tools that I have been unable to find please let me know.

technorati tags:, , , , , ,