Skip to content

Commit 1908c98

Browse files
committed
新的安装器由Rust编写
1 parent 2e1c35e commit 1908c98

File tree

5 files changed

+50
-66
lines changed

5 files changed

+50
-66
lines changed

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
[submodule "PinyinM.NET"]
88
path = PinyinM.NET
99
url = https://github.com/Maklith/Pinyin.NET
10-
[submodule "ModernInstaller"]
11-
path = ModernInstaller
12-
url = https://github.com/Maklith/ModernInstaller
10+
[submodule "ModernInstallerR"]
11+
path = ModernInstallerR
12+
url = https://github.com/Maklith/ModernInstallerR/

ModernInstaller

Lines changed: 0 additions & 1 deletion
This file was deleted.

ModernInstallerR

Submodule ModernInstallerR added at 19117e8

build/Build.cs

Lines changed: 21 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using SharpCompress.Archives;
1818
using SharpCompress.Archives.SevenZip;
1919
using static Nuke.Common.Tools.DotNet.DotNetTasks;
20+
using FileMode = System.IO.FileMode;
2021
using Project = Nuke.Common.ProjectModel.Project;
2122

2223
[GitHubActions(
@@ -225,23 +226,23 @@ class Build : NukeBuild
225226
var rootDirectory = RootDirectory / "Publish";
226227
rootDirectory.DeleteDirectory();
227228
DotNetPublish(c => new DotNetPublishSettings()
228-
.SetProject("KitopiaEx")
229+
.SetProject(RootDirectory / "KitopiaEx" / "KitopiaEx.csproj")
229230
.SetOutput(RootDirectory / "Publish" / "plugins" / "kitopiaex")
230231
.SetRuntime("win-x64")
231232
.SetFramework("net10.0")
232233
.SetConfiguration("Release")
233234
.SetSelfContained(false)
234235
);
235236
DotNetPublish(c => new DotNetPublishSettings()
236-
.SetProject("OnnxRuntime.CPU")
237+
.SetProject(RootDirectory / "OnnxRuntime.CPU" / "OnnxRuntime.CPU.csproj")
237238
.SetOutput(RootDirectory / "Publish" / "plugins" / "kitopiaonnxruntimecpu")
238239
.SetRuntime("win-x64")
239240
.SetFramework("net10.0")
240241
.SetConfiguration("Release")
241242
.SetSelfContained(false)
242243
);
243244
DotNetPublish(c => new DotNetPublishSettings()
244-
.SetProject(AvaloniaProject.Name)
245+
.SetProject(AvaloniaProject.Path)
245246
.SetOutput(RootDirectory / "Publish")
246247
.SetRuntime("win-x64")
247248
.SetFramework("net10.0-windows10.0.19041.0")
@@ -338,71 +339,31 @@ class Build : NukeBuild
338339
.OnlyWhenDynamic(() => !IsRelease || release != null)
339340
.Executes(() =>
340341
{
341-
Directory.CreateDirectory(RootDirectory / "ModernInstaller" / "Assets");
342+
Directory.CreateDirectory(RootDirectory / "ModernInstallerR" / "installer_assets");
342343
var directoryInfo = new DirectoryInfo(RootDirectory / "build" / "InstallerAssets");
343344
foreach (var enumerateFile in directoryInfo.EnumerateFiles())
344345
{
345-
File.Copy(enumerateFile.FullName, RootDirectory / "ModernInstaller" / "Assets" / enumerateFile.Name,
346+
File.Copy(enumerateFile.FullName, RootDirectory / "ModernInstallerR" / "installer_assets" / enumerateFile.Name,
346347
true);
347348
}
348-
349-
File.Copy(RootDirectory / "Kitopia" + AvaloniaProject.GetProperty("Version") +
350-
"_WithoutContained.zip", RootDirectory / "ModernInstaller" / "Assets" / "App.zip", true);
351-
});
352-
353-
Target PrepareNative => _ => _
354-
.DependsOn(PreparePackInstallerGithub)
355-
.OnlyWhenDynamic(() => !IsRelease || release != null)
356-
.Executes(() =>
357-
{
358-
if (!File.Exists(RootDirectory / "ModernInstaller" / "Natives" / "Windows-x86" / "libHarfBuzzSharp.lib"))
359-
{
360-
using var sevenZipArchive = SevenZipArchive.Open(RootDirectory / "ModernInstaller" / "Natives" /
361-
"Windows-x86" / "Windows-x86.7z");
362-
sevenZipArchive.ExtractToDirectory(RootDirectory / "ModernInstaller" / "Natives" / "Windows-x86");
363-
}
364-
});
365-
366-
Target BuildNativeUninstaller => _ => _
367-
.DependsOn(PrepareNative)
368-
.OnlyWhenDynamic(() => !IsRelease || release != null)
369-
.Executes(() =>
370-
{
371-
DotNetPublish(c => new DotNetPublishSettings()
372-
.SetProject($"ModernInstaller{Path.DirectorySeparatorChar}ModernInstaller.Uninstaller")
373-
.SetOutput(RootDirectory / "ModernInstaller" / "Publish")
374-
.SetFramework("net10.0-windows")
375-
.SetRuntime("win-x86")
376-
.SetConfiguration("Release")
377-
.SetSelfContained(true)
378-
);
379-
});
380-
381-
Target PrepareBuildNativeInstaller => _ => _
382-
.DependsOn(BuildNativeUninstaller)
383-
.OnlyWhenDynamic(() => !IsRelease || release != null)
384-
.Executes(() =>
385-
{
386-
File.Copy(RootDirectory / "ModernInstaller" / "Publish" / "ModernInstaller.Uninstaller.exe",
387-
RootDirectory / "Assets" / "ModernInstaller.Uninstaller.exe", true);
388-
PowerShellTasks.PowerShell(
389-
$"ModernInstaller{Path.DirectorySeparatorChar}build{Path.DirectorySeparatorChar}upx.exe --force --lzma {RootDirectory /"ModernInstaller" / "Publish" / "ModernInstaller.Uninstaller.exe"} ");
349+
var rootDirectory = RootDirectory / "Publish";
350+
var pluginDirectory = rootDirectory / "plugins";
351+
352+
var destPluginZip = RootDirectory / "ModernInstallerR" / "installer_assets" / "plugins.zip";
353+
pluginDirectory.ZipTo(destPluginZip, compressionLevel: CompressionLevel.SmallestSize,fileMode: FileMode.Create);
354+
pluginDirectory.DeleteDirectory();
355+
356+
var destAppZip=RootDirectory / "ModernInstallerR" / "installer_assets" / "App.zip";
357+
rootDirectory.ZipTo(destAppZip, compressionLevel: CompressionLevel.SmallestSize,fileMode: FileMode.Create);
358+
359+
390360
});
391-
392361
Target BuildNativeInstaller => _ => _
393-
.DependsOn(PrepareBuildNativeInstaller)
362+
.DependsOn(PreparePackInstallerGithub)
394363
.OnlyWhenDynamic(() => !IsRelease || release != null)
395364
.Executes(() =>
396365
{
397-
DotNetPublish(c => new DotNetPublishSettings()
398-
.SetProject($"ModernInstaller{Path.DirectorySeparatorChar}ModernInstaller")
399-
.SetOutput(RootDirectory / "ModernInstaller" / "Publish")
400-
.SetFramework("net10.0-windows")
401-
.SetRuntime("win-x86")
402-
.SetConfiguration("Release")
403-
.SetSelfContained(true)
404-
.SetPublishSingleFile(true)
405-
);
366+
PowerShellTasks.PowerShell("scripts/build_release.ps1", workingDirectory: RootDirectory / "ModernInstallerR");
406367
});
407368

408369
Target PackInstaller => _ => _
@@ -412,9 +373,8 @@ class Build : NukeBuild
412373
.OnlyWhenDynamic(() => !IsRelease || release != null)
413374
.Executes((() =>
414375
{
415-
var moderninstallerExe = RootDirectory / "ModernInstaller" / "Publish" / "ModernInstaller.exe";
416-
PowerShellTasks.PowerShell(
417-
$"ModernInstaller{Path.DirectorySeparatorChar}build{Path.DirectorySeparatorChar}upx.exe --force --lzma {moderninstallerExe} ");
376+
var moderninstallerExe = RootDirectory / "ModernInstallerR" / "dist"/
377+
"x86_64-pc-windows-msvc" / "ModernInstaller.exe";
418378

419379
Log.Debug("Installer created: {0}", moderninstallerExe);
420380

build/InstallerAssets/info.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,29 @@
44
"DisplayVersion": "0.1.3.1",
55
"Publisher": "MakesYT",
66
"CanExecutePath": "KitopiaAvalonia.exe",
7-
"Is64": true
7+
"Is64": true,
8+
"InstallDependencies": [
9+
{
10+
"Name": ".NET 10 Windows Desktop Runtime (x64)",
11+
"Url": "https://aka.ms/dotnet/10.0/windowsdesktop-runtime-win-x64.exe",
12+
"FileName": "windowsdesktop-runtime-win-x64.exe",
13+
"RuntimeName": "Microsoft.WindowsDesktop.App",
14+
"RuntimeVersionPrefix": "10.",
15+
"InstallArgs": [
16+
"/install",
17+
"/quiet",
18+
"/norestart"
19+
]
20+
}
21+
],
22+
"InstallPackages": [
23+
{
24+
"Package": "App.zip",
25+
"Target": "{InstallDir}"
26+
},
27+
{
28+
"Package": "plugins.zip",
29+
"Target": "{localUserData}\\Kitopia\\plugins"
30+
}
31+
]
832
}

0 commit comments

Comments
 (0)