Initial commit: WpywMail 自建邮件系统:.NET 8 原生 SMTP/IMAP 服务端(DKIM 签名、SPF/DKIM/DMARC 入站校验、SQLite 存储、完整账号体系)、Node 服务端、WinUI 3 客户端与 Web 前端
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<RootNamespace>WpywMail.Installer</RootNamespace>
|
||||
<AssemblyName>wpyw-mail-server-installer</AssemblyName>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
||||
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Payload.zip" LogicalName="WpywMail.Installer.Payload.zip" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace WpywMail.Installer;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
public static int Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
var root = Path.Combine(Path.GetTempPath(), "WpywMailInstaller", Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(root);
|
||||
using var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("WpywMail.Installer.Payload.zip") ?? throw new InvalidOperationException("安装包内容缺失。");
|
||||
var zip = Path.Combine(root, "payload.zip");
|
||||
using (var output = File.Create(zip)) resource.CopyTo(output);
|
||||
ZipFile.ExtractToDirectory(zip, root);
|
||||
File.Delete(zip);
|
||||
|
||||
var script = Path.Combine(root, "install.ps1");
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = "powershell.exe",
|
||||
Arguments = $"-NoProfile -ExecutionPolicy Bypass -File \"{script}\"",
|
||||
WorkingDirectory = root,
|
||||
UseShellExecute = true,
|
||||
Verb = "runas",
|
||||
};
|
||||
using var process = Process.Start(psi) ?? throw new InvalidOperationException("无法启动安装程序。");
|
||||
process.WaitForExit();
|
||||
if (process.ExitCode != 0)
|
||||
{
|
||||
Console.Error.WriteLine($"安装程序返回错误代码:{process.ExitCode}");
|
||||
}
|
||||
return process.ExitCode;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine(ex.Message);
|
||||
Console.Error.WriteLine("安装程序无法启动。");
|
||||
Console.Error.WriteLine("请记录上面的错误信息,然后按任意键退出。");
|
||||
try { Console.ReadKey(intercept: true); } catch { }
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user