更新 WindowsAppSDKDependency.cs

This commit is contained in:
qhy040404
2024-01-15 23:55:23 +08:00
committed by GitHub
parent 6867e5e914
commit d6f15608d9

View File

@@ -1,8 +1,10 @@
using System;
using System;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.ServiceProcess;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Windows.Management.Deployment;
@@ -25,7 +27,7 @@ internal static partial class WindowsAppSDKDependency
return;
}
if (CheckRuntimeInstalled(packageName, msixVersion))
if (await CheckRuntimeInstalledAndVerifyAsync(packageName, msixVersion).ConfigureAwait(false))
{
return;
}
@@ -63,7 +65,7 @@ internal static partial class WindowsAppSDKDependency
return string.Empty;
}
private static bool CheckRuntimeInstalled(string packageName, string msixVersion)
private static async Task<bool> CheckRuntimeInstalledAndVerifyAsync(string packageName, string msixVersion)
{
Version msixMinVersion = new(msixVersion);
@@ -71,7 +73,7 @@ internal static partial class WindowsAppSDKDependency
{
if (installed.Id.Name == packageName && installed.Id.Version.ToVersion() >= msixMinVersion)
{
return true;
return await installed.VerifyContentIntegrityAsync();
}
}
@@ -111,6 +113,13 @@ internal static partial class WindowsAppSDKDependency
},
};
ServiceController service = new("appxsvc");
if (service.CanStop)
{
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(5));
}
using (installerProcess)
{
installerProcess.OutputDataReceived += (sender, e) => Console.WriteLine(e.Data);
@@ -121,6 +130,7 @@ internal static partial class WindowsAppSDKDependency
installerProcess.BeginErrorReadLine();
await installerProcess.WaitForExitAsync().ConfigureAwait(false);
Marshal.ThrowExceptionForHR(installerProcess.ExitCode);
Console.WriteLine("<----- WindowsAppRuntimeInstall Output end -------");
}
}