Tutorial: Deploy your Enterprise Architect C# add-in with an MSI package Tutorial: Deploy your Enterprise Architect C# Add-in with an MSI package by Geert Bellekens [email protected] originally published on http://geertbellekens.wordpress.com at http://wp.me/p1dEib-3j 2011-02-23 Author: Geert Bellekens Page 1 of 12 Tutorial: Deploy your Enterprise Architect C# add-in with an MSI package Contents Requirements....................................................................................................................................... 3 The plan ............................................................................................................................................... 3 Step 1: Create a setup project ............................................................................................................. 4 Step 2: Edit Setup.wxs......................................................................................................................... 6 Step 3: Add the program files .............................................................................................................. 7 Step 4: Register MyAddin.dll for COM Interop..................................................................................... 8 Step 5: Add the EA Addin registry key................................................................................................. 9 Step 6: Fill in the license details......................................................................................................... 11 Step 7: Build and test your setup project ........................................................................................... 11 More resources .................................................................................................................................. 12 Related blog posts.......................................................................................................................... 12 Source code on GitHub .................................................................................................................. 12 Sparx Systems ............................................................................................................................... 12 Other............................................................................................................................................... 12 2011-02-23 Author: Geert Bellekens Page 2 of 12 Tutorial: Deploy your Enterprise Architect C# add-in with an MSI package In previous posts I talked about Creating and Testing your Enterprise Architect C# add-in, and how to use the C# add-in template to speed up the development process. Once created and tested you’ll probably want to install and use the add-in on other computers then your development machine. This tutorial explains how to create an MSI installer package using the open source SharpDevelop and WiX software. The reason I’m using SharpDevelop as opposed to Visual Studio C# Express is because SharpDevelop is free and open source, and Visual Studio C# Express doesn’t allow to create setup projects, or attach to a running process to debug your add-in. Requirements • SharpDevelop 4.0 http://www.sharpdevelop.net/OpenSource/SD/Download/#SharpDevelop4x • WiX 3.5 http://wix.codeplex.com/releases/view/60102 SharpDevelop 4.0 already contains Wix 3.0, but we need 3.5 for the “register for COM interop” functionality. SharpDevelop 4.1 comes with Wix 3.5, but at the moment of writing that is still in pre-alpha phase, and not stable enough to be used. The plan As explained in Tutorial: Create your first C# Enterprise Architect addin in 10 minutes we need our installer to do three things for us: • Copy the dll’s to a program folder. • Register the add-in dll for COM Interop so Windows knows where to find the add-in dll. • Create the registry key so EA knows about our add-in. 2011-02-23 Author: Geert Bellekens Page 3 of 12 Tutorial: Deploy your Enterprise Architect C# add-in with an MSI package Step 1: Create a setup project • Open the solution for your add-in in SharpDevelop. If you have developed the add-in with Visual Studio, that fine. Sharpdevelop uses the exact same project setup as Visual Studio, with the .sln and .csproj files • Add a new project and choose for Setup Project – WixUI Minimal You can of course choose for another template, but for the purpose of this tutorial the WixUI Minimal is enough. 2011-02-23 Author: Geert Bellekens Page 4 of 12 Tutorial: Deploy your Enterprise Architect C# add-in with an MSI package • SharpDevelop will now have created a new Setup project in your solution containing three files: o Files.wxs This is were we define wich files and registry keys the installer needs to install o license.rtf Contains the license for your software o Setup.wxs Where we define the general setup of the installer like the name, and the components to install. 2011-02-23 Author: Geert Bellekens Page 5 of 12 Tutorial: Deploy your Enterprise Architect C# add-in with an MSI package Step 2: Edit Setup.wxs Next we’re going to tell the installer about the application it will install. The .wxs files are actually XML files, and you can edit them directly in SharpDevelop. • Open Setup.wxs and edit the highlighted parts Notice that we also added a ComponentRef for MyAddinRegEntries. 2011-02-23 Author: Geert Bellekens Page 6 of 12 Tutorial: Deploy your Enterprise Architect C# add-in with an MSI package Step 3: Add the program files • Open up the setup files view with View|Setup|Files • Right-click on the MyAddinFiles component and choose Add Files… Now browse to the MyAddin project folder and select all files in the MyAddin\bin\debug or MyAddin\bin\release folder, depending on how you last built your project. Not all of these files might be necessary, but I can’t be bothered to figure out exactly which files we need to install the add-in on another computer. • This should now have created a line in the files.wxs for each binary file similar to <File Id ="EAAddinFramework.dll" Name ="EAAddinFramework.dll" Source ="..\MyAddin\bin\Deb ug\EAAddinFramework.dll" /> <File Id ="UMLToolingFramework.dll" Name ="UMLToolingFramework.dll" Source ="..\MyAddin\b in\Debug\UMLToolingFramework.dll" /> <File Id ="EAAddinFramework.pdb" Name ="EAAddinFramework.pdb" Source ="..\MyAddin\bin\Deb ug\EAAddinFramework.pdb" /> <File Id ="Interop.EA.dll" Name ="Interop.EA.dll" Source ="..\MyAddin\bin\Debug\Interop.E A.dll" /> <File Id ="MyAddin.pdb" Name ="MyAddin.pdb" Source ="..\MyAddin\bin\Debug\MyAddin.pdb" /> <File Id ="MyAddin.tlb" Name ="MyAddin.tlb" Source ="..\MyAddin\bin\Debug\MyAddin.tlb" /> <File Id ="UMLToolingFramework.pdb" Name ="UMLToolingFramework.pdb" Source ="..\MyAddin\b in\Debug\UMLToolingFramework.pdb" /> <File Id ="MyAddin.dll" Name ="MyAddin.dll" Source ="..\MyAddin\bin\Debug\MyAddin.dll" /> 2011-02-23 Author: Geert Bellekens Page 7 of 12 Tutorial: Deploy your Enterprise Architect C# add-in with an MSI package Step 4: Register MyAddin.dll for COM Interop The MyAddin.dll is the add-in dll that EA needs to talk to, so this dll needs to be registered for COM Interop. This is the part that is done by regasm.exe when doing a manual installation, but we don’t want to be calling any executables on the target machine during install if we can avoid it. Instead we will just add the same registry keys that regasm.exe creates. This is the part were we need WiX version 3.5, because the previous versions don’t take into account the COM Interop stuff. • Open a command prompt in the folder where MyAddin.dll is located (bin\Debug\) • Execute following command: "C:\Program Files\Windows Installer XML v3.5\bin\heat.exe" file MyAddin.dll -ag - template fragment -out MyAddin.wxs This will have created a file in the same folder with the name MyAddin.wxs. • Open that file and copy the contents of the Component tag: <Class Id ="{10BC65F1-32C0-3ED4-98A0- 17661A8C4455}" Context ="InprocServer32" Description ="MyAddin.MyAddinClass" ThreadingMo del ="both" ForeignServer ="mscoree.dll" > <ProgId Id ="MyAddin.MyAddinClass" Description ="MyAddin.MyAddinClass" /> </Class> <File Id ="filCC4172BEC1312562EDEF49648E45AE0D" KeyPath ="yes" Source ="..\MyAddin\bin\D ebug\MyAddin.dll" /> <RegistryValue Root ="HKCR" Key ="CLSID\{10BC65F1-32C0-3ED4-98A0- 17661A8C4455}\Implemented Categories\{62C8FE65-4EBB-45e7-B440- 6E39B2CDBF29}" Value ="" Type ="string" Action ="write" /> <RegistryValue Root ="HKCR" Key ="CLSID\{10BC65F1-32C0-3ED4-98A0- 17661A8C4455}\InprocServer32\1.0.0.0" Name ="Class" Value ="MyAddin.MyAddinClass" Type =" string" Action ="write" /> <RegistryValue Root ="HKCR" Key ="CLSID\{10BC65F1-32C0-3ED4-98A0- 17661A8C4455}\InprocServer32\1.0.0.0" Name ="Assembly" Value ="MyAddin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Type ="string" Action ="write" /> <RegistryValue Root ="HKCR" Key ="CLSID\{10BC65F1-32C0-3ED4-98A0- 17661A8C4455}\InprocServer32\1.0.0.0" Name ="RuntimeVersion" Value="v4.0.30319" Type ="s tring" Action ="write" /> <RegistryValue Root ="HKCR" Key ="CLSID\{10BC65F1-32C0-3ED4-98A0- 17661A8C4455}\InprocServer32\1.0.0.0" Name ="CodeBase" Value ="file:///[#filCC4172BEC131 2562EDEF49648E45AE0D]" Type ="string" Action ="write" /> <RegistryValue Root ="HKCR" Key ="CLSID\{10BC65F1-32C0-3ED4-98A0- 17661A8C4455}\InprocServer32" Name ="Class" Value ="MyAddin.MyAddinClass" Type ="string" Action ="write" /> <RegistryValue Root ="HKCR" Key ="CLSID\{10BC65F1-32C0-3ED4-98A0- 17661A8C4455}\InprocServer32" Name ="Assembly" Value ="MyAddin, Version=1.0.0.0, Culture=neutral,
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages12 Page
-
File Size-