Non-admin installation of AddIns

Further to a query in the EA forum on how to install an EA addin without admin rights here is an outline of the way I do it – it is probably not perfect and for somebody with greater knowledge than me about windows installers there are probably some slicker or better ways.  However, it has been working reliably with some of our customers for some time.

Create an installer project

Our installers are created using Wix. Hence, the steps involved are to:

  1. Create a wix project adding the wxs file to the project.  We use a graphical UI so the project will need to include references to the relevant Wix libraries (WixUIExtension, WixUtilExtension, WixNetFxExtension)
  2. Create a wxs file defining the installer requirements; an example wxs file is provided below
  3. You may optionally use heat to havest information from projects to be included in the installation (the example wxs file provides an illustration)

Points to note

It is important to note that a non-admin installation will install the addin for the current user only.  Registry entries are placed in the current user area (HKCU) and not the local machine (HKLM) need to make it generally available.

When running the installer, for somebody without admin rights, the target directory must be set to a location in current user area where they have write access.

When doing an update of a non-admin installation we recommend that your do an uninstall AND then ensure that you delete any installing dll’s as we have seen instances where the sequent install has not updated dll’s!  Perhaps an installer expert will explain why to me someday!

I wouldn’t say that sorting our installers was all plain sailing.  A useful tool that is supplied with windows SDK is orca – a tool that allows you to inspect install files (msi).  Really useful for checking information.  You can edit installers files with orca but I wouldn’t recommend it but solve issues at source, otherwise I feel you could get into a real mess.

I hope this short post provides sufficient information and you can get you non-admin installer working.

Adrian


Example WXS file

The example WXS file below will need to be adapted to your requirements by setting:

  • GUIDs for the relevant items.
  • File locations for project files
  • Files for images and any included files

<?xml version=”1.0″ encoding=”UTF-8″?>
<Wix xmlns=”http://schemas.microsoft.com/wix/2006/wi”&gt;

<!– Set as required –>
<?define MajorVersion=”0″ ?>
<?define MinorVersion=”1″ ?>
<?define BuildVersion=”2″ ?>
<?define Revision=”3″ ?>

<!– Full version number to display –>
<?define VersionNumber=”$(var.MajorVersion).$(var.MinorVersion).$(var.BuildVersion).$(var.Revision)” ?>
<!–
Upgrade code HAS to be the same for all updates.
Once you’ve chosen it don’t change it.
–>
<?define UpgradeCode=”YOUR UPGRADE GUID” ?>
<!–
Path to the resources directory. resources don’t really need to be included
in the project structure but I like to include them for for clarity
–>
<?define ResourcesDir=”$(var.ProjectDir)\Resources” ?>
<!–
The name of your application exe file. This will be used to kill the process when updating
and creating the desktop shortcut
–>
<?define ExeProcessName=”SuperForm.MainApp.exe” ?>
<!– defines include the version number –>
<Product Id=”*”
Name=”!(loc.ProductName) $(var.VersionNumber)”
Language=”!(loc.LANG)”
Version=”$(var.VersionNumber)”
Manufacturer=”!(loc.ManufacturerName)”
UpgradeCode=”$(var.UpgradeCode)”>
<!– added Install scope to install for the machine rather than per user –>
<Package Keywords=”Installer”
InstallerVersion=”300″
Description =”Your product name”
Compressed=”yes”
InstallScope =”perUser”/>
<Media Id=”1″ Cabinet=”media1.cab” EmbedCab=”yes” />
<UIRef Id=”WixUI_FeatureTree”/>
<UI>
<!–  These dialog references are needed for CloseApplication above to work correctly    –>
<DialogRef Id=”FilesInUse” />
<DialogRef Id=”MsiRMFilesInUse” />
</UI>

<!– Set the icon to show next to the program name in Add/Remove programs –>
<!– need to set $(var.????.ProjectDir) in lines below to reflect the your source project directory e.g. $(var.myaddin.ProjectDir) –>
<!– You don’t have to have icons or background images, or a licence agreement – these are optional so read the Wix documentation –>
<!– also note that the images MUST BE of an exact size otherwise they may not be clear –>
<!– banner.bmp must be 493 x 58 –>
<!– backgroud.bmp must be 493 x 312 –>
<Icon Id=”AppIcon.ico” SourceFile=”$(var.????.ProjectDir)\images\EX.ico” />
<Property Id=”ARPPRODUCTICON” Value=”AppIcon.ico” />
<WixVariable Id=”WixUIBannerBmp” Value=”$(var.????.ProjectDir)\Images\InstallBanner.bmp”/>
<WixVariable Id=”WixUIDialogBmp” Value=”$(var.????.ProjectDir)\Images\InstallBackground.bmp”/>
<WixVariable Id=”WixUILicenseRtf” Value=”$(var.????.ProjectDir)\Legal\Our Licence Agreement.rtf”/>
<CustomAction Id=’NoDowngrade’ Error=’A later version of [ProductName] is already installed.’ />
<!–     Set the default install location to the value of INSTALLLOCATION (usually c:\Program Files\YourProductName)  –>
<Property Id=”WIXUI_INSTALLDIR” Value=”INSTALLLOCATION” />
<!– Feature to build the installer file –>
<Directory Id=”TARGETDIR” Name=”SourceDir”>
<Directory Id=”ProgramFilesFolder”>
<Directory Id=”INSTALLLOCATION” Name=”!(loc.ProductName)”>
<!– this component defines the files that are to be installed DLL’s, help file and the sample eafd –>
<Component Id=”YOURDLLs” Guid=”A COMPONENT GUID” KeyPath=”yes”>
<File Id=”Interop.EA.dll” Source=”$(var.????.TargetDir)/Interop.EA.dll” Vital=”yes”  />
<!– ADD entries for all DLL’s and other files that need to be installed –>
</Component>
</Directory>
</Directory>

<!– this section creates the keys for the add in –>
<!– YOURCOMPANY and YOURPRODUCT are defined by you are are where the installer will place the keys –>
<Directory Id=”Keys”>
<Component Id=”ProgramKeys”  Guid=”ANOTHER COMPONENT GUID”>
<RegistryKey Root=”HKCU” Key=”Software\YOURCOMPANY\YOURPRODUCT”>
<RegistryValue Type=”string” Value=”Default Value” />
<RegistryValue Type=’string’ Name=’ProgramDir’ Value='[INSTALLLOCATION]’ KeyPath =”yes”/>
</RegistryKey>

<!– ADDINNAME – is a key that will be created in the registry, which EA will check on load. –>
<!– ASSEMBLY.CLASS – is the class that EA will attempt to load so needs to be registered–>
<RegistryKey Root=”HKCU” Key=”Software\Sparx Systems\EAAddins\ADDINNAME” ForceCreateOnInstall=”yes” ForceDeleteOnUninstall=”yes”>
<RegistryValue Type=”string” Value=”ASSEMBLY.CLASS”/>
</RegistryKey>
<!– when registering the class you want the keys to be placed in somewhere meaningful – hence use a string that you can find e.g. YourADDINNAME –>
<RegistryKey Root=”HKCU” Key=”Software\Microsoft\Active Setup\Installed Components\YourADDINNAME”  ForceCreateOnInstall=”yes” ForceDeleteOnUninstall=”yes”>
<RegistryValue Type=”string” Value=”YOUR Addin” />
<RegistryValue Type=”string” Name=”Version” Value=”1″ />
<RegistryValue Type=”string” Name=”StubPath”
Value=’reg add “HKCU\Software\Sparx Systems\EAAddins\ADDINNAME” /ve /d ASSEMBLY.CLASS /t REG_SZ /f’ />
</RegistryKey>

</Component>
</Directory>
</Directory>

<!– we define the features which pull in the components above –>

<!– optional you can harvest files from the project using heat – if you wish to use this method check the Heat documentation for details of parameters.
“C:\Program Files (x86)\WiX Toolset v3.10\bin\heat.exe” file “$(SolutionDir)addinname\bin\$(Platform)\$(Configuration)\MainAddin.DLL” -v -dr INSTALLLOCATION -srd -gg -g1 -cg HARVESTED_DLLS_reference -suid -var “var.addinprojectdirectory.TargetDir”  -out “$(ProjectDir)HARVESTED_DLLS_reference.dll.wxs”
–>

<Feature Id=”Complete”
Title=”AddIn setup”
Level=”1″ ConfigurableDirectory=”INSTALLLOCATION” TypicalDefault=”install”
Description=”your addin description” AllowAdvertise =”yes” >

<!– add this line (or multiple lines if you are havesting multiple projects) otherwise leave out –>
<ComponentGroupRef Id=”HARVESTED_DLLS_reference”/>
<!– these are the components define above which will be included in your installation –>
<ComponentRef Id=”YOURDLLs”/>
<ComponentRef Id=”ProgramKeys”/>
</Feature>
</Product>
</Wix>


 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s