Skip to content

Commit

Permalink
尝试构建安装器
Browse files Browse the repository at this point in the history
  • Loading branch information
MakesYT committed Jan 20, 2025
1 parent 8edc325 commit 86097b0
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

name: continuous

on: [ push ]
on: [push]

jobs:
windows-latest:
Expand Down
2 changes: 1 addition & 1 deletion KitopiaAvalonia/KitopiaAvalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<DebugType Condition="'$(Configuration)' == 'Release'">none</DebugType>
<Version>0.0.2.098</Version>
<Version>0.0.2.099</Version>
<AvaloniaVersion>11.2.2</AvaloniaVersion>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU;x64</Platforms>
Expand Down
95 changes: 95 additions & 0 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
Expand All @@ -10,8 +13,12 @@
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.Git;
using Nuke.Common.Tools.GitHub;
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Utilities;
using Octokit;
using Serilog;
using SharpCompress.Archives;
using SharpCompress.Archives.SevenZip;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using Project = Nuke.Common.ProjectModel.Project;

Expand Down Expand Up @@ -258,11 +265,99 @@ class Build : NukeBuild
.Wait();
}
);
Target PreparePackInstallerGithub => _ => _.Executes(() =>
{

GitTasks.Git("clone https://github.com/MakesYT/ModernInstaller.git --single-branch --depth 1",
RootDirectory,new Dictionary<string, string>()
{
{"GIT_CLONE_PROTECTION_ACTIVE","false"}
});
var directoryInfo = new DirectoryInfo(RootDirectory / "build"/"InstallerAssets");
foreach (var enumerateFile in directoryInfo.EnumerateFiles())
{
File.Copy(enumerateFile.FullName,RootDirectory/"ModernInstaller"/"Assets"/enumerateFile.Name,true);
}
File.Copy(RootDirectory / "Kitopia" + AvaloniaProject.GetProperty("Version") +
"_WithoutContained.zip",RootDirectory/"ModernInstaller"/"Assets"/"App.zip",true);



});
Target PrepareNative=>_=>_
.DependsOn(PreparePackInstallerGithub)
.DependsOn(Pack)
.Executes(() =>
{
if (!File.Exists(RootDirectory/"ModernInstaller"/"Natives"/"Windows-x86"/"av_libglesv2.lib"))
{
using var sevenZipArchive = SevenZipArchive.Open(RootDirectory/"ModernInstaller"/"Natives"/"Windows-x86"/"Windows-x86.7z");
sevenZipArchive.ExtractToDirectory(RootDirectory/"ModernInstaller"/"Natives"/"Windows-x86");
}
});
public static Guid uuid = Guid.NewGuid();
Target BuildNativeUninstaller => _ => _

.DependsOn(PrepareNative)
.Executes(() =>
{
File.WriteAllText($"ModernInstaller{Path.DirectorySeparatorChar}Assets{Path.DirectorySeparatorChar}ApplicationUUID",uuid.ToString());
DotNetTasks.DotNetPublish(c => new DotNetPublishSettings()
.SetProject($"ModernInstaller{Path.DirectorySeparatorChar}ModernInstaller.Uninstaller")
.SetOutput(RootDirectory/"ModernInstaller" / "Publish" )
.SetFramework("net9.0-windows")
.SetRuntime("win-x86")
.SetConfiguration("Release")
.SetSelfContained(true)
.SetPublishSingleFile(true)

);
});
Target PrepareBuildNativeInstaller => _ => _
.DependsOn(BuildNativeUninstaller)
.Executes(() =>
{
File.Copy(RootDirectory /"ModernInstaller" / "Publish" / "ModernInstaller.Uninstaller.exe",RootDirectory / "Assets" / "ModernInstaller.Uninstaller.exe",true);
});
Target BuildNativeInstaller => _ => _

.DependsOn(PrepareBuildNativeInstaller)
.Executes(() =>
{
DotNetTasks.DotNetPublish(c => new DotNetPublishSettings()
//.SetProject("AvaloniaApplication1")
.SetProject($"ModernInstaller{Path.DirectorySeparatorChar}ModernInstaller")
.SetOutput(RootDirectory /"ModernInstaller" / "Publish" )
.SetFramework("net9.0-windows")
.SetRuntime("win-x86")
.SetConfiguration("Release")
.SetSelfContained(true)
.SetPublishSingleFile(true)

);
});
Target PackInstaller => _ => _
.OnlyWhenDynamic(() => FinishedTargets.Contains(CreateRelease))

.DependsOn(CreateRelease)
.DependsOn(BuildNativeInstaller)
.Executes((() =>
{
var moderninstallerExe = RootDirectory /"ModernInstaller" / "Publish" / "ModernInstaller.exe";
var assetUpload_self = new ReleaseAssetUpload
{
FileName = "Kitopia"+AvaloniaProject.GetProperty("Version") + "_Installer.exe",
ContentType = "application/octet-stream",
RawData = File.OpenRead(moderninstallerExe)
};
_gitHubClient.Repository.Release.UploadAsset(release, assetUpload_self)
.Wait();
}));
Target Clean => _ => _
.DependsOn(PackDebug)
.DependsOn(Pack)
.DependsOn(PackSelf)
.DependsOn(PackInstaller)
.Executes(() =>
{
});
Expand Down
1 change: 1 addition & 0 deletions build/InstallerAssets/Agreement.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
暂无
Binary file added build/InstallerAssets/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/InstallerAssets/IconPack.ico
Binary file not shown.
Binary file added build/InstallerAssets/IconPack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/InstallerAssets/IconUninstall.ico
Binary file not shown.
Binary file added build/InstallerAssets/IconUninstall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions build/InstallerAssets/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"DisplayIcon": "",
"DisplayName": "Kitopia",
"DisplayVersion": "1.0.0",
"Publisher": "MakesYT",
"CanExecutePath": "KitopiaAvalonia.exe",
"Is64": false
}
1 change: 1 addition & 0 deletions build/kitopia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="8.1.4"/>
<PackageReference Include="SharpCompress" Version="0.39.0" />
</ItemGroup>

</Project>

0 comments on commit 86097b0

Please sign in to comment.