in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Sander's Blog

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

Comments

 

Todd Hiltz said:

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

November 18, 2007 4:08 PM
 

Sander de Koning said:

Thanks Todd! I've updated my post;

November 23, 2007 4:13 PM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts