Book a Demo

Author Topic: Automatically install Custom MDG Technology  (Read 4292 times)

André Ribeiro

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Automatically install Custom MDG Technology
« on: November 27, 2013, 11:36:58 pm »
Hello everyone!

I've developed a custom add-in and a MDG Technology.
I was able to create an executable for installing my add-in using this link http://bellekens.com/2011/02/23/tutorial-deploy-your-enterprise-architect-csharp-add-in-with-an-msi-package/, but now I would like to know if it's possible to install my MDG Technology also automatically.

Thanks in advance!
« Last Edit: November 27, 2013, 11:37:17 pm by krypton »

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: Automatically install Custom MDG Technology
« Reply #1 on: November 28, 2013, 12:38:32 am »
Hi André,


I think Geert was using Wix, in which case here are the code fragments I included in my WXS file.

Start by adding a new Directory group for your MDG, noting the following:

1. 3 Unique GUIDs used
2. The key (Key="Software\COMPANY\PRODUCT") used in the registry is up to you but ensure it is consist
3. Ensure that the source line (Source="$(var.myproduct.ProjectDir)\MDG\MDGXMLFILE.xml")  reflects your project.



Code: [Select]

<!-- feature to store the MDG technology into the PerUser %AppData%\Roaming\Sparx Systems\EA\MDGTechnologies directory -->
      <Directory Id="AppDataFolder" Name="AppDataFolder">
        <Directory Id="MYMDG" Name="Sparx Systems">
            <Component Id="MYMDG" Guid="A UNIQUE GUID" >
              <RemoveFolder Id="MYMDG" On="uninstall" />
              <RegistryKey Root="HKCU" Key="Software\COMPANY\PRODUCT">
                <RegistryValue Name="installed" Type="integer" Value="1" KeyPath="yes"/>
              </RegistryKey>
                          
            </Component>
              <Directory Id="EA" Name ="EA">
                <Component Id="EA" Guid="ANOTHER UNIQUE GUID" >
                  <RemoveFolder Id="EA"  On="uninstall" />
                  <RegistryKey Root="HKCU" Key="Software\COMPANY\PRODUCT" >
                    <RegistryValue Name="installed" Type="integer" Value="2" KeyPath="yes"/>
                  </RegistryKey>

                </Component>
              <Directory Id="MDGTechnologies" Name="MDGTechnologies">
              <Component Id ="MDGTechnologies" Guid="YET ANOTHER UNIQUE GUID" >
                <File Id="MDGFile" Source="$(var.ProjectDir)\MDG\MDGXMLFILE.xml"  Vital="yes" />
                <RemoveFolder Id="MDGTechnologies"  On="uninstall" />
                <RegistryKey Root="HKCU" Key="Software\COMPANY\PRODUCT">
                  <RegistryValue  Name="installed" Type="integer" Value="3" KeyPath="yes" />              
                </RegistryKey>
              </Component>
           </Directory>
          </Directory>
        </Directory>
      </Directory>


     
Then in the features section add this MDG group

      
Code: [Select]
<ComponentRef Id="MYMDG"/>  



On  install the MDG file will be placed in the Sparx Application data folder "C:\Users\NAME\AppData\Roaming\Sparx Systems\EA\MDGTechnologies" from which EA reads MDG files on startup.

I hope that helps - it took me ages to sort out all the Wix stuff - its really powerful but so complicated 1st time around - even looking back now I wonder.
            

Regards
EXploringEA - information, utilities and addins

stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: Automatically install Custom MDG Technology
« Reply #2 on: November 28, 2013, 01:35:06 am »
EA has a broadcast method where you can install your mdg technology file.

here our code:

Code: [Select]
public String EA_OnInitializeTechnologies(EA.Repository Repository)
        {
            string technology = "";
            Assembly assem = this.GetType().Assembly;
            using (Stream stream = assem.GetManifestResourceStream("PathToMDGTechFile.xml"))
            {
                try
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        technology = reader.ReadToEnd();
                    }
                }
                catch
                {
                    System.Windows.Forms.MessageBox.Show("Error Initializing Technology");
                }
            }

            return technology;
        }

André Ribeiro

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Automatically install Custom MDG Technology
« Reply #3 on: November 30, 2013, 02:35:08 am »
Thank you for the helpful answers.
I used the solution proposed by stao with a slight change.
In my case GetManifestResourceStream was always returning null, so I used File.OpenRead instead to get the stream.