Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Update registry entries #1

Open
Advaith3600 opened this issue Dec 29, 2024 · 5 comments
Open

[Feature] Update registry entries #1

Advaith3600 opened this issue Dec 29, 2024 · 5 comments

Comments

@Advaith3600
Copy link

I am currently using this for my currency converter plugin, and it works wonderfully. I just have one suggestion: please update the registry entries. I am adding a system registry entry during installation, which allows users to quickly uninstall the plugin and view its details through the Control Panel or the Installed Apps page in Settings. Therefore, during updates, it would be beneficial if the updater could modify this registry entry to reflect the new version.

Thank you!

@hlaueriksson
Copy link
Owner

I'm not sure what you mean by "registry entries".

@Advaith3600
Copy link
Author

I meant the Windows registry. Currently, my EXE file is creating a registry entry at HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\CurrencyConverter\DisplayVersion. It would be great if the updater could update the version here during the update.

@hlaueriksson
Copy link
Owner

This project has no idea about Windows Registry updates.

However, your plugin can listen to the UpdateInstalled event:

event EventHandler<PluginUpdateEventArgs>? UpdateInstalled;

Example:

private void OnUpdateInstalled(object? sender, PluginUpdateEventArgs e)
{
Log.Info("UpdateInstalled: " + e.Version, GetType());
Context!.API.ShowNotification($"{Name} {e.Version}", "Update installed");
}

☝️ Add updates to the Registry here.

@Advaith3600
Copy link
Author

I don't think a system-level modification for an update should be handled in the plugin itself, and I believe elevation is also required to run it, making it more suitable to be done at an updater level.

# rest of the code

Write-Log "Extract release"
$parent = Split-Path -Path $pluginDirectory -Parent
Expand-Archive -Path $release -DestinationPath $parent -Force

Write-Log "Update registry version"
$registryPath = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\$name"
if (Test-Path $registryPath) {
    Set-ItemProperty -Path $registryPath -Name "DisplayVersion" -Value $newVersion
    Write-Log "Registry version updated to $newVersion"
}
else {
    Write-Warning "Registry path not found: $registryPath"
}

@hlaueriksson
Copy link
Owner

hlaueriksson commented Jan 7, 2025

I don't think this project should know anyting about the Windows Registry.

I'm open for a way for plugin authors to include a post upgrade script that is invoked at the end of update.ps1.
It would be a more generic solution.

For example:

  1. The plugin includes a script, e.g. postupdate.ps1

  2. The PluginUpdateSettings could have a property public string? PostUpdateScriptPath { get; set; }

  3. The plugin could set the property here:

public PluginUpdateSettings Update { get; set; } = new PluginUpdateSettings { ResultScore = 100 };

  1. The PluginUpdateHandler adds the PostUpdateScriptPath param here:

var arguments = $"-ExecutionPolicy Bypass -File \"{Metadata.PluginDirectory}\\update.ps1\" \"{LatestAsset.browser_download_url}\"";

  1. The update.ps1 invokes the post upgrade script after these lines:

Write-Log "Extract release"
$parent = Split-Path -Path $pluginDirectory -Parent
Expand-Archive -Path $release -DestinationPath $parent -Force

Perhaps support for a pre upgrade script would also be of interest to plugin authors!?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants