Skip to content

Commit

Permalink
Fixed the issue of update the Windows self contained version
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Jan 30, 2025
1 parent 4526400 commit 4a32b2c
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions v2rayN/ServiceLib/Services/UpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ private async Task<RetResult> 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;
Expand All @@ -379,28 +380,28 @@ private async Task<RetResult> 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:
Expand All @@ -422,17 +423,18 @@ private async Task<RetResult> ParseDownloadUrl(ECoreType type, SemanticVersion v
}
}

private string? GetUrlFromCore(CoreInfo? coreInfo)
private async Task<string?> 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
Expand Down Expand Up @@ -586,4 +588,4 @@ private async Task DownloadGeoFile(string url, string fileName, string targetPat

#endregion Geo private
}
}
}

0 comments on commit 4a32b2c

Please sign in to comment.