I've created a COM visible project and have added an Setup Wizard to the project. I've also added a Custom Actions class and have attempted to write to the registry.
Below is a sample entry for a wxs installer (which I have no experience in), how could i recreate this in C# during the install action of my custom actions class?
<RegistryKey Root='HKCU' Key='Software\Autodesk\Structural\RSA\AddIns\{24D63E1C-E503-4EB4-9381-BF9F6A35E199}'>
<RegistryValue Type='binary' Name='AddInsType' Value='0'/>
<RegistryValue Type='binary' Name='Enable' Value='1'/>
<RegistryValue Type='string' Name='File' Value='[INSTALLDIR]myaddin.dll'/>
<RegistryValue Type='string' Name='Guid' Value='{24D63E1C-E503-4EB4-9381-BF9F6A35E199}'/>
<RegistryValue Type='binary' Name='Guid Type' Value='2'/>
<RegistryValue Type='binary' Name='KeepMenuGrade' Value='0'/>
<RegistryValue Type='string' Name='KeyName' Value='{24D63E1C-E503-4EB4-9381-BF9F6A35E199}'/>
This is what I have so far in my custom actions class, using this answer. Is it correct to add the key_value_name as the same GUID as my COM dll?
namespace RegisterRoboPython
{
[RunInstaller(true)]
public partial class RegisterRoboPython : Installer
{
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
const string key_path = "Software\\Autodesk\\Structural\\RSA\\AddIns";
const string key_value_name = "{5a0d8941-241c-481c-9811-2c76a91bf17c}";
RegistryKey key = Registry.LocalMachine.OpenSubKey(key_path, Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);
if (key == null)
{
key = Registry.LocalMachine.CreateSubKey(key_path);
}
string tgt_dir = Context.Parameters["TARGETDIR"];
key.SetValue(key_value_name, tgt_dir);
}
public override void Commit(System.Collections.IDictionary savedState)
{
base.Commit(savedState);
}
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
const string key_path = "Software\\Autodesk\\Structural\\RSA\\AddIns";
const string key_name = "{5a0d8941-241c-481c-9811-2c76a91bf17c}";
RegistryKey key = Registry.LocalMachine.OpenSubKey(key_path);
if (key.OpenSubKey(key_name) != null)
{
key.DeleteSubKey(key_name);
}
}
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
}
public RegisterRoboPython()
{
InitializeComponent();
}
}
Edit 1: When running the installations .msi I receive the following error:
system.argumentexception FILE = DOES NOT EXIST
IF THIS PARAMETER IS USED AS AN INSTALLER OPTION THE FORMAT MUST BE /KEY=[VALUE]
Which I am confused about as I have added /TARGETDIR = "[TARGETDIR]" to the install/commit CustomActionData properties.
So my question is, what is the correct way to register the COM dll using custom actions?
Am I on the right track? Thanks for reading, Tom