tag:blogger.com,1999:blog-9537945.post-11527750491232697022008-04-21T18:32:00.005-05:002008-04-23T06:15:27.145-05:00VSTO Lessons LearnedA few months ago I was asked to write an Install that deployed a few .NET 3.5 features:<br /><br />Tray Application (required)<br />Office 2003 Word Add-In ( Optional )<br />Office 2007 Word Add-In ( Optional)<br /><br />At the time I blogged I was exploring these technologies and asked if anyone had already done it. Lately several people have emailed me asking if I ever figured it out. I have figured it out and during the process I confirmed that <span class="blsp-spelling-error" id="SPELLING_ERROR_0"><span class="blsp-spelling-error" id="SPELLING_ERROR_0">ClickOnce</span></span>/<span class="blsp-spelling-error" id="SPELLING_ERROR_1"><span class="blsp-spelling-error" id="SPELLING_ERROR_1">VSTO</span></span> Installer/Per-User Installs are STILL a BAD IDEA!! Using this process you can streamline (merge) multiple <span class="blsp-spelling-error" id="SPELLING_ERROR_2">VSTO</span> add-ins, other system components and related setup <span class="blsp-spelling-error" id="SPELLING_ERROR_3">prereqs</span> into a single All-Users install that can be deployed using traditional techniques.<br /><br />I've been meaning to write a white paper with sample code on this subject but I've been too busy. Until then, here's a quick recipe using <span class="blsp-spelling-error" id="SPELLING_ERROR_2"><span class="blsp-spelling-error" id="SPELLING_ERROR_4">InstallShield</span></span> 2008 ( <span class="blsp-spelling-error" id="SPELLING_ERROR_3"><span class="blsp-spelling-error" id="SPELLING_ERROR_5">InstallShield</span></span> 2009 would be a little cooler using chained feature conditioned Setup <span class="blsp-spelling-error" id="SPELLING_ERROR_4"><span class="blsp-spelling-error" id="SPELLING_ERROR_6">Prereqs to streamline the relationship between the prereqs and the features</span></span>. )<br /><br /><br />You'll need to bring a bunch of things together:<br /><br />1) Download the .NET 3.5 <span class="blsp-spelling-error" id="SPELLING_ERROR_5"><span class="blsp-spelling-error" id="SPELLING_ERROR_7">Prereq</span></span> ( Web <span class="blsp-spelling-error" id="SPELLING_ERROR_6"><span class="blsp-spelling-error" id="SPELLING_ERROR_8">downloader</span></span> of Full Install from <span class="blsp-spelling-error" id="SPELLING_ERROR_7"><span class="blsp-spelling-error" id="SPELLING_ERROR_9">InstallShield</span></span> )<br /><br />2) Create the <span class="blsp-spelling-error" id="SPELLING_ERROR_8"><span class="blsp-spelling-error" id="SPELLING_ERROR_10">VSTO</span></span> 2005SE and Office 2003 PIA Prereqs ( Conditioned for installation if Office 2003 Installed and made optional)<br /><br />3) Create the <span class="blsp-spelling-error" id="SPELLING_ERROR_10"><span class="blsp-spelling-error" id="SPELLING_ERROR_12">VSTO</span></span> 3.0 <span class="blsp-spelling-error" id="SPELLING_ERROR_11"><span class="blsp-spelling-error" id="SPELLING_ERROR_13">Prereq</span></span> ( Conditioned for installation if Office 2007 Installed and made optional)<br /><br />4) Blocking <span class="blsp-spelling-error" id="SPELLING_ERROR_12"><span class="blsp-spelling-error" id="SPELLING_ERROR_14">SystemSearch</span></span>/Launch Conditions to check .NET 3.5 is installed.<br /><br />5) <span class="blsp-spelling-error" id="SPELLING_ERROR_13"><span class="blsp-spelling-error" id="SPELLING_ERROR_15">SystemSearch</span></span> / <span class="blsp-spelling-error" id="SPELLING_ERROR_14"><span class="blsp-spelling-error" id="SPELLING_ERROR_16">FeatureConditions</span></span> to disable Add-In features if related Office versions aren't installed.<br /><br />6) `Feature Constraints` to not allow the user to select the Office-<span class="blsp-spelling-error" id="SPELLING_ERROR_15"><span class="blsp-spelling-error" id="SPELLING_ERROR_17">Addins</span></span> if the related Office versions aren't installed.<br /><br />7) A .NET Class for calling referencing the System.Security.Cryptography <span class="blsp-spelling-error" id="SPELLING_ERROR_16"><span class="blsp-spelling-error" id="SPELLING_ERROR_18">namespace</span></span> for calling the <span class="blsp-spelling-error" id="SPELLING_ERROR_17"><span class="blsp-spelling-error" id="SPELLING_ERROR_19">BCL</span></span> methods for installing various certificates. These will be needed to backup the add-in manifest for <span class="blsp-spelling-corrected" id="SPELLING_ERROR_18">run time</span> verification purposes. ( Get rid of an <span class="blsp-spelling-corrected" id="SPELLING_ERROR_19">annoying</span> dialog that is bad if the user says no. )<br /><br />8) A .NET class for calling the System.Random class to generate a random number.<br /><br />9) Office 2007 doesn't allow Add-Ins to be installed Per-Machine but it does expose a rather interesting pattern for migrating data down to the user profile without invoking an <span class="blsp-spelling-error" id="SPELLING_ERROR_20"><span class="blsp-spelling-error" id="SPELLING_ERROR_20">MSI</span></span> repair scenario. <span class="blsp-spelling-corrected" id="SPELLING_ERROR_21">Unfortunately</span> this pattern requires that you create a registry key during the <span class="blsp-spelling-error" id="SPELLING_ERROR_22"><span class="blsp-spelling-error" id="SPELLING_ERROR_21">uninstall</span></span> ( which <span class="blsp-spelling-error" id="SPELLING_ERROR_23"><span class="blsp-spelling-error" id="SPELLING_ERROR_22">MSI</span></span> doesn't support ) so you'll need a custom action for that also.<br /><br />To understand this registry migration pattern, how Office loads Add-In manifests and the roll of signing, read through the following articles.... ( make your .NET developer read it also so that he can get on the right track of knowing how to build his code and where to expect the <span class="blsp-spelling-error" id="SPELLING_ERROR_24"><span class="blsp-spelling-error" id="SPELLING_ERROR_23">runtime</span></span> execution to occur on the file system )<br /><br /><a href="http://blogs.msdn.com/mshneer/archive/2007/09/04/deploying-your-vsto-add-in-to-all-users-part-i.aspx" target="_blank">Deploying your <span class="blsp-spelling-error" id="SPELLING_ERROR_25"><span class="blsp-spelling-error" id="SPELLING_ERROR_24">VSTO</span></span> Add-In to All Users (Part I)</a><br /><br /><a href="http://blogs.msdn.com/mshneer/archive/2007/09/05/deploying-your-vsto-add-in-to-all-users-part-ii.aspx" target="_blank">Deploying your <span class="blsp-spelling-error" id="SPELLING_ERROR_26"><span class="blsp-spelling-error" id="SPELLING_ERROR_25">VSTO</span></span> Add-In to All Users (Part II) </a><br /><br /><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2707637&SiteID=1"><span class="blsp-spelling-error" id="SPELLING_ERROR_27"><span class="blsp-spelling-error" id="SPELLING_ERROR_26">MSDN</span></span> Forums: Merge (<span class="blsp-spelling-error" id="SPELLING_ERROR_28"><span class="blsp-spelling-error" id="SPELLING_ERROR_27">VSTO</span></span>) Setups</a>Christopher Painterhttp://www.blogger.com/profile/12167478740431444267noreply@blogger.com