From 4a32b2c8142df6ddc72b98012991aff502bae308 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Thu, 30 Jan 2025 18:06:13 +0800 Subject: [PATCH] Fixed the issue of update the Windows self contained version --- v2rayN/ServiceLib/Services/UpdateService.cs | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs index d737459cc25..2d086a22553 100644 --- a/v2rayN/ServiceLib/Services/UpdateService.cs +++ b/v2rayN/ServiceLib/Services/UpdateService.cs @@ -368,6 +368,7 @@ private async Task ParseDownloadUrl(ECoreType type, SemanticVersion v try { var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(type); + var coreUrl = await GetUrlFromCore(coreInfo) ?? string.Empty; SemanticVersion curVersion; string message; string? url; @@ -379,28 +380,28 @@ private async Task ParseDownloadUrl(ECoreType type, SemanticVersion v { curVersion = await GetCoreVersion(type); message = string.Format(ResUI.IsLatestCore, type, curVersion.ToVersionString("v")); - url = string.Format(GetUrlFromCore(coreInfo), version.ToVersionString("v")); + url = string.Format(coreUrl, version.ToVersionString("v")); break; } case ECoreType.mihomo: { curVersion = await GetCoreVersion(type); message = string.Format(ResUI.IsLatestCore, type, curVersion); - url = string.Format(GetUrlFromCore(coreInfo), version.ToVersionString("v")); + url = string.Format(coreUrl, version.ToVersionString("v")); break; } case ECoreType.sing_box: { curVersion = await GetCoreVersion(type); message = string.Format(ResUI.IsLatestCore, type, curVersion.ToVersionString("v")); - url = string.Format(GetUrlFromCore(coreInfo), version.ToVersionString("v"), version); + url = string.Format(coreUrl, version.ToVersionString("v"), version); break; } case ECoreType.v2rayN: { curVersion = new SemanticVersion(Utils.GetVersionInfo()); message = string.Format(ResUI.IsLatestN, type, curVersion); - url = string.Format(GetUrlFromCore(coreInfo), version); + url = string.Format(coreUrl, version); break; } default: @@ -422,17 +423,18 @@ private async Task ParseDownloadUrl(ECoreType type, SemanticVersion v } } - private string? GetUrlFromCore(CoreInfo? coreInfo) + private async Task GetUrlFromCore(CoreInfo? coreInfo) { if (Utils.IsWindows()) { //Check for standalone windows .Net version - if (coreInfo?.CoreType == ECoreType.v2rayN - && File.Exists(Path.Combine(Utils.StartupPath(), "wpfgfx_cor3.dll")) - && File.Exists(Path.Combine(Utils.StartupPath(), "D3DCompiler_47_cor3.dll")) - ) + if (coreInfo?.CoreType == ECoreType.v2rayN && RuntimeInformation.ProcessArchitecture == Architecture.X64) { - return coreInfo?.DownloadUrlWin64?.Replace(".zip", "-SelfContained.zip"); + var runtimes = await Utils.GetCliWrapOutput("dotnet", "--list-runtimes"); + if (runtimes == null || runtimes.Contains("Microsoft.WindowsDesktop.App 8") == false) + { + return coreInfo?.DownloadUrlWin64?.Replace(".zip", "-SelfContained.zip"); + } } return RuntimeInformation.ProcessArchitecture switch @@ -586,4 +588,4 @@ private async Task DownloadGeoFile(string url, string fileName, string targetPat #endregion Geo private } -} \ No newline at end of file +}