Skip to content

Commit

Permalink
1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Dec 28, 2023
1 parent 9d71ac8 commit cd6a3bb
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Snap.Hutao.Deployment.Runtime</id>
<version>1.7.0</version>
<version>1.8.0</version>
<authors>DGP Studio</authors>
<developmentDependency>true</developmentDependency>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand Down
Binary file modified src/Snap.Hutao.Deployment.Runtime/Snap.Hutao.Deployment.exe
Binary file not shown.
42 changes: 31 additions & 11 deletions src/Snap.Hutao.Deployment/Invocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@

namespace Snap.Hutao.Deployment;

internal static class Invocation
internal static partial class Invocation
{
public static async Task RunDeploymentAsync(InvocationContext context)
{
string? path = context.ParseResult.GetValueForOption(InvocationOptions.PackagePath);
string? name = context.ParseResult.GetValueForOption(InvocationOptions.FamilyName);
bool isUpdateMode = context.ParseResult.GetValueForOption(InvocationOptions.UpdateBehavior);

if (!isUpdateMode)
{
AllocConsole();
}

ArgumentException.ThrowIfNullOrEmpty(path);

Console.WriteLine($"""
Expand All @@ -30,8 +35,7 @@ public static async Task RunDeploymentAsync(InvocationContext context)

if (isUpdateMode)
{
Console.WriteLine("Exit in 10 seconds...");
await Task.Delay(10000).ConfigureAwait(false);
await ExitAsync(true).ConfigureAwait(false);
return;
}
else
Expand All @@ -43,10 +47,11 @@ public static async Task RunDeploymentAsync(InvocationContext context)

await Certificate.EnsureGlobalSignCodeSigningRootR45Async().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
{
Expand Down Expand Up @@ -109,23 +114,38 @@ private static async Task RunDeploymentCoreAsync(string path, string? name)
ActivityId: {result.ActivityId}
ExtendedErrorCode: {result.ExtendedErrorCode}
ErrorText: {result.ErrorText}
Exit in 10 seconds...
""");

await Task.Delay(10000).ConfigureAwait(false);
}
}
catch (Exception ex)
{
Console.WriteLine($"""
Exception occured:
{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);
}
}

[LibraryImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static partial bool AllocConsole();

[LibraryImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static partial bool FreeConsole();
}
3 changes: 2 additions & 1 deletion src/Snap.Hutao.Deployment/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System.CommandLine;
using System.Runtime.InteropServices;
using System.Threading.Tasks;

namespace Snap.Hutao.Deployment;

internal static class Program
internal static partial class Program
{
internal static async Task<int> Main(string[] args)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Snap.Hutao.Deployment/Snap.Hutao.Deployment.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand All @@ -12,6 +12,7 @@
<SelfContained>true</SelfContained>
<DebugType>embedded</DebugType>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit cd6a3bb

Please sign in to comment.