-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
102 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.IO.Abstractions; | ||
using System.Runtime.InteropServices; | ||
using System.Threading.Tasks; | ||
using CSharpFunctionalExtensions; | ||
using DotnetPackaging; | ||
using DotnetPackaging.AppImage; | ||
using DotnetPackaging.AppImage.Core; | ||
using Nuke.Common.IO; | ||
using Nuke.Common.ProjectModel; | ||
using Nuke.Common.Tools.DotNet; | ||
using Zafiro.FileSystem.Lightweight; | ||
|
||
public static class AppImagePackager | ||
{ | ||
static readonly Dictionary<Architecture, (string Runtime, string RuntimeLinux)> Mapping = new() | ||
{ | ||
[Architecture.X64] = ("linux-x64", "x86_64"), | ||
[Architecture.Arm64] = ("linux-arm64", "arm64"), | ||
}; | ||
|
||
public static Task PackAppImage(Project project, Architecture architecture, Configuration configuration, AbsolutePath output, string version) | ||
{ | ||
var runtime = Mapping[architecture].Runtime; | ||
|
||
var publishDirectory = project.Directory / "bin" / "publish" / runtime; | ||
|
||
DotNetTasks.DotNetPublish(settings => settings | ||
.SetProject(project) | ||
.SetConfiguration(configuration) | ||
.SetSelfContained(true) | ||
.SetRuntime(Mapping[architecture].Runtime) | ||
.SetOutput(publishDirectory)); | ||
|
||
return Pack(project, publishDirectory, version, architecture, output); | ||
} | ||
|
||
static async Task Pack(Project project, AbsolutePath publishDirectory, string version, Architecture architecture, AbsolutePath outputDir) | ||
{ | ||
var fs = new FileSystem(); | ||
var inputDir = new DirectorioIODirectory(Maybe<string>.None, fs.DirectoryInfo.New(publishDirectory)); | ||
var appName = project.Name.Replace(".Desktop", ""); | ||
var packagePath = outputDir / appName + "-" + version + "-" + Mapping[architecture].RuntimeLinux + ".AppImage"; | ||
packagePath.Parent.CreateDirectory(); | ||
await using var output = fs.File.Open(packagePath, FileMode.Create); | ||
IEnumerable<AdditionalCategory> categories = [AdditionalCategory.FileManager, AdditionalCategory.FileTools, AdditionalCategory.FileTransfer, AdditionalCategory.Filesystem]; | ||
var metadata = new Options() | ||
{ | ||
Icon = Maybe<IIcon>.None, | ||
MainCategory = Maybe<MainCategory>.From(MainCategory.Utility), | ||
AdditionalCategories = Maybe.From(categories), | ||
AppName = appName, | ||
Comment = "Cross-Platform File Synchronization Powered by AvaloniaUI", | ||
Keywords = new List<string> | ||
{ | ||
"File Synchronization", | ||
"Cross-Platform", | ||
"AvaloniaUI", | ||
"Avalonia", | ||
"File Management", | ||
"Folder Sync", | ||
"UI Design", | ||
"Open Source", | ||
"Reactive Programming" | ||
}, | ||
StartupWmClass = appName, | ||
Version = version, | ||
}; | ||
|
||
await AppImage.WriteFromBuildDirectory(output, inputDir, metadata); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters