This commit is contained in:
Lightczx
2024-01-31 16:32:21 +08:00
parent de074e40e0
commit f39463f0d3
4 changed files with 47 additions and 47 deletions

View File

@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata> <metadata>
<id>Snap.Hutao.Deployment.Runtime</id> <id>Snap.Hutao.Deployment.Runtime</id>
<version>1.15.2</version> <version>1.15.3</version>
<authors>DGP Studio</authors> <authors>DGP Studio</authors>
<developmentDependency>true</developmentDependency> <developmentDependency>true</developmentDependency>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>

View File

@@ -2,6 +2,7 @@
using System.CommandLine.Invocation; using System.CommandLine.Invocation;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using Windows.Management.Deployment; using Windows.Management.Deployment;
@@ -24,30 +25,30 @@ internal static partial class Invocation
ArgumentException.ThrowIfNullOrEmpty(path); ArgumentException.ThrowIfNullOrEmpty(path);
Console.WriteLine($""" Console.WriteLine($"""
Snap Hutao Deployment Tool [1.15.2] Snap Hutao Deployment Tool [1.15.3]
PackagePath: {path} PackagePath: {path}
FamilyName: {name} FamilyName: {name}
------------------------------------------------------------ ------------------------------------------------------------
"""); """);
if (!File.Exists(path))
{
Console.WriteLine($"Package file not found.");
if (isUpdateMode)
{
await ExitAsync(true).ConfigureAwait(false);
return;
}
else
{
Console.WriteLine("Start downloading package...");
await PackageDownload.DownloadPackageAsync(path).ConfigureAwait(false);
}
}
try try
{ {
if (!File.Exists(path))
{
Console.WriteLine($"Package file not found.");
if (isUpdateMode)
{
await ExitAsync(true).ConfigureAwait(false);
return;
}
else
{
Console.WriteLine("Start downloading package...");
await PackageDownload.DownloadPackageAsync(path).ConfigureAwait(false);
}
}
await Certificate.EnsureGlobalSignCodeSigningRootR45Async().ConfigureAwait(false); await Certificate.EnsureGlobalSignCodeSigningRootR45Async().ConfigureAwait(false);
await WindowsAppSDKDependency.EnsureAsync(path).ConfigureAwait(false); await WindowsAppSDKDependency.EnsureAsync(path).ConfigureAwait(false);
await RunDeploymentCoreAsync(path, name, isUpdateMode).ConfigureAwait(false); await RunDeploymentCoreAsync(path, name, isUpdateMode).ConfigureAwait(false);

View File

@@ -19,11 +19,36 @@ internal static partial class WindowsAppSDKDependency
public static async Task EnsureAsync(string packagePath) public static async Task EnsureAsync(string packagePath)
{ {
using FileStream packageStream = File.OpenRead(packagePath);
ZipArchive package = default!;
try try
{ {
package = new(packageStream, ZipArchiveMode.Read); using (FileStream packageStream = File.OpenRead(packagePath))
{
using (ZipArchive package = new(packageStream, ZipArchiveMode.Read))
{
(string packageName, string msixVersion) = await ExtractRuntimePackageNameAndMsixMinVersionFromAppManifestAsync(package).ConfigureAwait(false);
if (string.IsNullOrEmpty(packageName) || string.IsNullOrEmpty(msixVersion))
{
Console.WriteLine("No Windows App Runtime version found in Msix/AppxManifest.xml");
return;
}
if (await CheckRuntimeInstalledAndVerifyAsync(packageName, msixVersion).ConfigureAwait(false))
{
return;
}
string sdkVersion = await ExtractSDKVersionFromDepsJsonAsync(package).ConfigureAwait(false);
if (string.IsNullOrEmpty(sdkVersion))
{
Console.WriteLine("No Windows App SDK version found in Msix/Snap.Hutao.deps.json");
return;
}
Console.WriteLine("Start downloading SDK installer...");
await DownloadWindowsAppRuntimeInstallAndInstallAsync(sdkVersion).ConfigureAwait(false);
};
}
} }
catch (InvalidDataException) catch (InvalidDataException)
{ {
@@ -38,32 +63,6 @@ internal static partial class WindowsAppSDKDependency
throw; throw;
} }
using (package)
{
(string packageName, string msixVersion) = await ExtractRuntimePackageNameAndMsixMinVersionFromAppManifestAsync(package).ConfigureAwait(false);
if (string.IsNullOrEmpty(packageName) || string.IsNullOrEmpty(msixVersion))
{
Console.WriteLine("No Windows App Runtime version found in Msix/AppxManifest.xml");
return;
}
if (await CheckRuntimeInstalledAndVerifyAsync(packageName, msixVersion).ConfigureAwait(false))
{
return;
}
string sdkVersion = await ExtractSDKVersionFromDepsJsonAsync(package).ConfigureAwait(false);
if (string.IsNullOrEmpty(sdkVersion))
{
Console.WriteLine("No Windows App SDK version found in Msix/Snap.Hutao.deps.json");
return;
}
Console.WriteLine("Start downloading SDK installer...");
await DownloadWindowsAppRuntimeInstallAndInstallAsync(sdkVersion).ConfigureAwait(false);
};
} }
private static async Task<string> ExtractSDKVersionFromDepsJsonAsync(ZipArchive package) private static async Task<string> ExtractSDKVersionFromDepsJsonAsync(ZipArchive package)