mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.Deployment.git
synced 2025-11-19 21:08:45 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a16fcbd2bb | ||
|
|
cd6a3bbfd9 |
@@ -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.7.0</version>
|
<version>1.9.0</version>
|
||||||
<authors>DGP Studio</authors>
|
<authors>DGP Studio</authors>
|
||||||
<developmentDependency>true</developmentDependency>
|
<developmentDependency>true</developmentDependency>
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
|
|||||||
Binary file not shown.
@@ -8,7 +8,7 @@ using Windows.Management.Deployment;
|
|||||||
|
|
||||||
namespace Snap.Hutao.Deployment;
|
namespace Snap.Hutao.Deployment;
|
||||||
|
|
||||||
internal static class Invocation
|
internal static partial class Invocation
|
||||||
{
|
{
|
||||||
public static async Task RunDeploymentAsync(InvocationContext context)
|
public static async Task RunDeploymentAsync(InvocationContext context)
|
||||||
{
|
{
|
||||||
@@ -16,6 +16,11 @@ internal static class Invocation
|
|||||||
string? name = context.ParseResult.GetValueForOption(InvocationOptions.FamilyName);
|
string? name = context.ParseResult.GetValueForOption(InvocationOptions.FamilyName);
|
||||||
bool isUpdateMode = context.ParseResult.GetValueForOption(InvocationOptions.UpdateBehavior);
|
bool isUpdateMode = context.ParseResult.GetValueForOption(InvocationOptions.UpdateBehavior);
|
||||||
|
|
||||||
|
if (!isUpdateMode)
|
||||||
|
{
|
||||||
|
AllocConsole();
|
||||||
|
}
|
||||||
|
|
||||||
ArgumentException.ThrowIfNullOrEmpty(path);
|
ArgumentException.ThrowIfNullOrEmpty(path);
|
||||||
|
|
||||||
Console.WriteLine($"""
|
Console.WriteLine($"""
|
||||||
@@ -30,8 +35,7 @@ internal static class Invocation
|
|||||||
|
|
||||||
if (isUpdateMode)
|
if (isUpdateMode)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Exit in 10 seconds...");
|
await ExitAsync(true).ConfigureAwait(false);
|
||||||
await Task.Delay(10000).ConfigureAwait(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -43,10 +47,11 @@ internal static class Invocation
|
|||||||
|
|
||||||
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).ConfigureAwait(false);
|
await RunDeploymentCoreAsync(path, name, isUpdateMode).ConfigureAwait(false);
|
||||||
|
await ExitAsync(isUpdateMode).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task RunDeploymentCoreAsync(string path, string? name)
|
private static async Task RunDeploymentCoreAsync(string path, string? name, bool isUpdateMode)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -87,8 +92,8 @@ internal static class Invocation
|
|||||||
}
|
}
|
||||||
catch (COMException ex)
|
catch (COMException ex)
|
||||||
{
|
{
|
||||||
// ERROR_MRM_MAP_NOT_FOUND
|
// ERROR_MRM_MAP_NOT_FOUND or ERROR_NOT_FOUND
|
||||||
if (ex.HResult is not unchecked((int)0x80073B1F))
|
if (ex.HResult is not unchecked((int)0x80073B1F) or unchecked((int)0x80070490))
|
||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
@@ -109,11 +114,7 @@ internal static class Invocation
|
|||||||
ActivityId: {result.ActivityId}
|
ActivityId: {result.ActivityId}
|
||||||
ExtendedErrorCode: {result.ExtendedErrorCode}
|
ExtendedErrorCode: {result.ExtendedErrorCode}
|
||||||
ErrorText: {result.ErrorText}
|
ErrorText: {result.ErrorText}
|
||||||
|
|
||||||
Exit in 10 seconds...
|
|
||||||
""");
|
""");
|
||||||
|
|
||||||
await Task.Delay(10000).ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -121,11 +122,30 @@ internal static class Invocation
|
|||||||
Console.WriteLine($"""
|
Console.WriteLine($"""
|
||||||
Exception occured:
|
Exception occured:
|
||||||
{ex}
|
{ex}
|
||||||
|
|
||||||
Exit in 10 seconds...
|
|
||||||
""");
|
""");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async ValueTask ExitAsync(bool isUpdateMode)
|
||||||
|
{
|
||||||
|
if (!isUpdateMode)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Press any key to exit...");
|
||||||
|
Console.ReadKey();
|
||||||
|
FreeConsole();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Exit in 10 seconds...");
|
||||||
await Task.Delay(10000).ConfigureAwait(false);
|
await Task.Delay(10000).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[LibraryImport("kernel32.dll")]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
private static partial bool AllocConsole();
|
||||||
|
|
||||||
|
[LibraryImport("kernel32.dll")]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
private static partial bool FreeConsole();
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
using System.CommandLine;
|
using System.CommandLine;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Snap.Hutao.Deployment;
|
namespace Snap.Hutao.Deployment;
|
||||||
|
|
||||||
internal static class Program
|
internal static partial class Program
|
||||||
{
|
{
|
||||||
internal static async Task<int> Main(string[] args)
|
internal static async Task<int> Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
|
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
|
||||||
<ImplicitUsings>disable</ImplicitUsings>
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
<SelfContained>true</SelfContained>
|
<SelfContained>true</SelfContained>
|
||||||
<DebugType>embedded</DebugType>
|
<DebugType>embedded</DebugType>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user