SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

Infopath VSTO post-build steps

Also tired of running the publish form wizard every time? Especially when you are developing a larger number of forms this can be a frustrating and time consuming task.

This is a description of the post-build steps for automatically building and deploying the forms:

1. Copy the files to a temp dir (Visual Studio creates a lock on the files)
xcopy "$(ProjectDir)Infopath Form Template\*" "c:\temp\$(ProjectName)\"

2. Delete Myschema.xsx - this is not part of the form template
del /Q "c:\temp\$(ProjectName)\*.xsx"

3. Put the folder in a cab file (download the CAB tool here)
cabtool "c:\temp\$(ProjectName)"

4. Rename the CAB to XSN
ren "c:\temp\$(ProjectName).cab" "$(ProjectName).xsn"

5. Deactivate the previous edition of the form
stsadm -o deactivateformtemplate -url http://yoursite -filename "c:\temp\$(ProjectName).xsn"

6. Remove the previous version of the form
stsadm -o removeformtemplate -filename "c:\temp\$(ProjectName).xsn"

7. Kick the job service (saves you the wait)
stsadm -o execadmsvcjobs

8. Upload the new template
stsadm -o uploadformtemplate -filename "c:\temp\$(ProjectName).xsn"

9. Kick the job service (again)
stsadm -o execadmsvcjobs

10. Activate the new form template
stsadm -o activateformtemplate -url http://yoursite -filename "c:\temp\$(ProjectName).xsn"

11. Clean up the mesh 
del /Q "c:\temp\$(ProjectName)"
del /Q "c:\temp\$(ProjectName).xsn"
rmdir "c:\temp\$(ProjectName)" /q /s

This will result in:
xcopy "$(ProjectDir)Infopath Form Template\*" "c:\temp\$(ProjectName)\"
del /Q "c:\temp\$(ProjectName)\*.xsx"
cabtool c:\temp\$(ProjectName)
ren "c:\temp\$(ProjectName).cab" "$(ProjectName).xsn"
stsadm -o deactivateformtemplate -url http://yoursite -filename "c:\temp\$(ProjectName).xsn"
stsadm -o deactivateformtemplate -url http://theirsite -filename "c:\temp\$(ProjectName).xsn"
stsadm -o removeformtemplate -filename "c:\temp\$(ProjectName).xsn"
stsadm -o execadmsvcjobs
stsadm -o uploadformtemplate -filename "c:\temp\$(ProjectName).xsn"
stsadm -o execadmsvcjobs
stsadm -o activateformtemplate -url http://yoursite -filename "c:\temp\$(ProjectName).xsn"
stsadm -o activateformtemplate -url http://theirsite -filename "c:\temp\$(ProjectName).xsn"
del /Q "c:\temp\$(ProjectName)"
del /Q "c:\temp\$(ProjectName).xsn"
rmdir "c:\temp\$(ProjectName)" /q /s

Additional tip:
Once you switch from a Debug build to the Release build you should:
- manually remove the pdb files from your manifest file
- remove the pdb files from your project directory


Posted 10-16-2007 2:28 PM by Sander de Koning

Comments

Todd Hiltz wrote re: Infopath VSTO post-build steps
on 11-18-2007 4:08 PM

Thanks Sander!!

It would have been nice if MS had included this as they did with the SharePoint workflow templates.

In any case I had 2 issues with the above script. Hopefully this saves someone else the same troubleshooting effort.

1. Invoking cabtool in the .bat file required quotes like: "%ProjectDir%\DeploymentFiles\cabtool.exe" "c:\temp\%ProjectName%"

2. Add this to the end to remove the temporary folder: rmdir "c:\temp\%ProjectName%" /q /s

Sander de Koning wrote re: Infopath VSTO post-build steps
on 11-23-2007 4:13 PM

Thanks Todd! I've updated my post;

onur biyik wrote re: Infopath VSTO post-build steps
on 09-15-2008 6:41 AM

can you make cabtool available on your site? the link is not working and I could not find it with a quick googling.

thanks for this great info

jeniferlopaz wrote re: Infopath VSTO post-build steps
on 11-12-2008 11:59 PM

InfoPath is a great tool in the VSTO toolkit.  There are two ways you can write managed code behind an InfoPath form.  First, you can use Visual Studio Tools for Applications which ships on the Office CD with InfoPath 2007. VSTA provides a nice integrated experience and may remind you of the VBA experience of putting code behind things.  VSTA is a slimmed down version of Visual Studio that has been optimized for integration into applications that need a customization or extension experience.  In particular, VSTA does a lot for applications written in managed code as it provides a versioning resilience story for these applications so that a customization for the application can version independently of the application itself. The breakthrough InfoPath forms client application with the industry leading SQL Server relational database.

-----------------------------

Jenifer

<a href="http://fsbo.fastrealestate.net" rel="dofollow">homes for sale by owner</a>

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.