From 5cb5ad04848c9dac4d8361935d48124837dca507 Mon Sep 17 00:00:00 2001 From: htcfreek <61519853+htcfreek@users.noreply.github.com> Date: Wed, 2 Apr 2025 18:32:47 +0200 Subject: [PATCH 1/2] changes --- .../PowerLauncher/Plugin/PluginManager.cs | 5 +++-- .../Properties/Resources.Designer.cs | 2 +- .../PowerLauncher/Properties/Resources.resx | 2 +- .../launcher/PowerLauncher/SettingsReader.cs | 3 +-- .../launcher/Wox.Plugin/PluginMetadata.cs | 20 +++++++++++++++++++ src/modules/launcher/Wox.Plugin/PluginPair.cs | 5 +++-- 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/modules/launcher/PowerLauncher/Plugin/PluginManager.cs b/src/modules/launcher/PowerLauncher/Plugin/PluginManager.cs index ad01b7eba4b9..f12359c52875 100644 --- a/src/modules/launcher/PowerLauncher/Plugin/PluginManager.cs +++ b/src/modules/launcher/PowerLauncher/Plugin/PluginManager.cs @@ -185,9 +185,10 @@ public static void InitializePlugins(IPublicAPI api) if (!failedPlugins.IsEmpty) { - var failed = string.Join(", ", failedPlugins.Select(x => x.Metadata.Name)); + string title = Resources.FailedToInitializePluginsTitle.ToString().Replace("{0}", Constant.Version); + var failed = string.Join(", ", failedPlugins.Select(x => $"{x.Metadata.Name} ({x.Metadata.ExecuteFileVersion})")); var description = $"{string.Format(CultureInfo.CurrentCulture, FailedToInitializePluginsDescription, failed)}\n\n{Resources.FailedToInitializePluginsDescriptionPartTwo}"; - Application.Current.Dispatcher.InvokeAsync(() => API.ShowMsg(Resources.FailedToInitializePluginsTitle, description, string.Empty, false)); + Application.Current.Dispatcher.InvokeAsync(() => API.ShowMsg(title, description, string.Empty, false)); } } diff --git a/src/modules/launcher/PowerLauncher/Properties/Resources.Designer.cs b/src/modules/launcher/PowerLauncher/Properties/Resources.Designer.cs index d4c435a900a3..b67d172e2fbd 100644 --- a/src/modules/launcher/PowerLauncher/Properties/Resources.Designer.cs +++ b/src/modules/launcher/PowerLauncher/Properties/Resources.Designer.cs @@ -160,7 +160,7 @@ public static string FailedToInitializePluginsDescriptionPartTwo { } /// - /// Looks up a localized string similar to PowerToys Run - Plugin Initialization Error. + /// Looks up a localized string similar to PowerToys Run {0} - Plugin Initialization Error. /// public static string FailedToInitializePluginsTitle { get { diff --git a/src/modules/launcher/PowerLauncher/Properties/Resources.resx b/src/modules/launcher/PowerLauncher/Properties/Resources.resx index 421919bb13b9..e3a64a6fdda2 100644 --- a/src/modules/launcher/PowerLauncher/Properties/Resources.resx +++ b/src/modules/launcher/PowerLauncher/Properties/Resources.resx @@ -189,7 +189,7 @@ Fail to initialize plugins: {0} - PowerToys Run - Plugin Initialization Error + PowerToys Run {0} - Plugin Initialization Error Don't translate "PowerToys Run". This is a product name. diff --git a/src/modules/launcher/PowerLauncher/SettingsReader.cs b/src/modules/launcher/PowerLauncher/SettingsReader.cs index 7d03e4cb278b..41d0524f69b9 100644 --- a/src/modules/launcher/PowerLauncher/SettingsReader.cs +++ b/src/modules/launcher/PowerLauncher/SettingsReader.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.IO.Abstractions; using System.Linq; @@ -252,7 +251,7 @@ private static IEnumerable GetDefaultPluginsSetting Id = x.Metadata.ID, Name = x.Plugin == null ? x.Metadata.Name : x.Plugin.Name, Description = x.Plugin?.Description, - Version = FileVersionInfo.GetVersionInfo(x.Metadata.ExecuteFilePath).FileVersion, + Version = x.Metadata.ExecuteFileVersion, Author = x.Metadata.Author, Website = x.Metadata.Website, Disabled = x.Metadata.Disabled, diff --git a/src/modules/launcher/Wox.Plugin/PluginMetadata.cs b/src/modules/launcher/Wox.Plugin/PluginMetadata.cs index 9a22fa485a89..4596e7da4a43 100644 --- a/src/modules/launcher/Wox.Plugin/PluginMetadata.cs +++ b/src/modules/launcher/Wox.Plugin/PluginMetadata.cs @@ -2,6 +2,8 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Diagnostics; +using System.IO; using System.IO.Abstractions; using System.Text.Json.Serialization; @@ -42,6 +44,9 @@ public PluginMetadata() public string ExecuteFileName { get; set; } + [JsonIgnore] + public string ExecuteFileVersion { get; private set; } + public string PluginDirectory { get @@ -53,6 +58,7 @@ internal set { _pluginDirectory = value; ExecuteFilePath = Path.Combine(value, ExecuteFileName); + SetExecutableVersion(); } } @@ -84,5 +90,19 @@ public override string ToString() [JsonIgnore] public int QueryCount { get; set; } + + private void SetExecutableVersion() + { + // Using version from plugin metadata json as fallback + try + { + var v = FileVersionInfo.GetVersionInfo(ExecuteFilePath).FileVersion; + ExecuteFileVersion = (v is null or "0.0.0.0") ? Version : v; + } + catch (FileNotFoundException) + { + ExecuteFileVersion = Version; + } + } } } diff --git a/src/modules/launcher/Wox.Plugin/PluginPair.cs b/src/modules/launcher/Wox.Plugin/PluginPair.cs index d31970d16d03..01daf9fb2296 100644 --- a/src/modules/launcher/Wox.Plugin/PluginPair.cs +++ b/src/modules/launcher/Wox.Plugin/PluginPair.cs @@ -82,8 +82,9 @@ public void Update(PowerLauncherPluginSettings setting, IPublicAPI api, Action r if (!IsPluginInitialized) { - string description = $"{Resources.FailedToLoadPluginDescription} {Metadata.Name}\n\n{Resources.FailedToLoadPluginDescriptionPartTwo}"; - Application.Current.Dispatcher.InvokeAsync(() => api.ShowMsg(Resources.FailedToLoadPluginTitle, description, string.Empty, false)); + string title = Resources.FailedToLoadPluginTitle.ToString().Replace("{0}", Constant.Version); + string description = $"{Resources.FailedToLoadPluginDescription} {Metadata.Name} ({Metadata.ExecuteFileVersion})\n\n{Resources.FailedToLoadPluginDescriptionPartTwo}"; + Application.Current.Dispatcher.InvokeAsync(() => api.ShowMsg(title, description, string.Empty, false)); } } else From 95160d3621c9b1715ec7c3df385f4f8d0c247380 Mon Sep 17 00:00:00 2001 From: htcfreek <61519853+htcfreek@users.noreply.github.com> Date: Wed, 2 Apr 2025 18:36:58 +0200 Subject: [PATCH 2/2] fix resx --- .../launcher/Wox.Plugin/Properties/Resources.Designer.cs | 2 +- src/modules/launcher/Wox.Plugin/Properties/Resources.resx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/launcher/Wox.Plugin/Properties/Resources.Designer.cs b/src/modules/launcher/Wox.Plugin/Properties/Resources.Designer.cs index b90d429f40b4..6e08434dfcb0 100644 --- a/src/modules/launcher/Wox.Plugin/Properties/Resources.Designer.cs +++ b/src/modules/launcher/Wox.Plugin/Properties/Resources.Designer.cs @@ -79,7 +79,7 @@ public static string FailedToLoadPluginDescriptionPartTwo { } /// - /// Looks up a localized string similar to PowerToys Run - Plugin Loading Error. + /// Looks up a localized string similar to PowerToys Run {0} - Plugin Loading Error. /// public static string FailedToLoadPluginTitle { get { diff --git a/src/modules/launcher/Wox.Plugin/Properties/Resources.resx b/src/modules/launcher/Wox.Plugin/Properties/Resources.resx index c8b8b2e9a7ea..1286bea532cf 100644 --- a/src/modules/launcher/Wox.Plugin/Properties/Resources.resx +++ b/src/modules/launcher/Wox.Plugin/Properties/Resources.resx @@ -125,7 +125,7 @@ "https://aka.ms/powerToysReportBug" is a web uri. - PowerToys Run - Plugin Loading Error + PowerToys Run {0} - Plugin Loading Error Don't translate "PowerToys Run". This is a product name.