Skip to content

Commit 7d41afe

Browse files
committed
Moving to Avalonia and .NET 8
+ Also enables the uses of NativeAOT
1 parent b814acd commit 7d41afe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1365
-2780
lines changed

.gitignore

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mono_crash.*
2323
[Rr]eleases/
2424
x64/
2525
x86/
26+
[Ww][Ii][Nn]32/
2627
[Aa][Rr][Mm]/
2728
[Aa][Rr][Mm]64/
2829
bld/
@@ -61,6 +62,12 @@ project.lock.json
6162
project.fragment.lock.json
6263
artifacts/
6364

65+
# Tye
66+
.tye/
67+
68+
# ASP.NET Scaffolding
69+
ScaffoldingReadMe.txt
70+
6471
# StyleCop
6572
StyleCopReport.xml
6673

@@ -137,6 +144,11 @@ _TeamCity*
137144
.axoCover/*
138145
!.axoCover/settings.json
139146

147+
# Coverlet is a free, cross platform Code Coverage Tool
148+
coverage*.json
149+
coverage*.xml
150+
coverage*.info
151+
140152
# Visual Studio code coverage results
141153
*.coverage
142154
*.coveragexml
@@ -168,6 +180,7 @@ DocProject/Help/html
168180

169181
# Click-Once directory
170182
publish/
183+
*build*
171184

172185
# Publish Web Output
173186
*.[Pp]ublish.xml
@@ -347,3 +360,95 @@ MigrationBackup/
347360

348361
# Ionide (cross platform F# VS Code tools) working folder
349362
.ionide/
363+
364+
# Fody - auto-generated XML schema
365+
FodyWeavers.xsd
366+
367+
##
368+
## Visual studio for Mac
369+
##
370+
371+
372+
# globs
373+
Makefile.in
374+
*.userprefs
375+
*.usertasks
376+
config.make
377+
config.status
378+
aclocal.m4
379+
install-sh
380+
autom4te.cache/
381+
*.tar.gz
382+
tarballs/
383+
test-results/
384+
385+
# Mac bundle stuff
386+
*.dmg
387+
*.app
388+
389+
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
390+
# General
391+
.DS_Store
392+
.AppleDouble
393+
.LSOverride
394+
395+
# Icon must end with two \r
396+
Icon
397+
398+
399+
# Thumbnails
400+
._*
401+
402+
# Files that might appear in the root of a volume
403+
.DocumentRevisions-V100
404+
.fseventsd
405+
.Spotlight-V100
406+
.TemporaryItems
407+
.Trashes
408+
.VolumeIcon.icns
409+
.com.apple.timemachine.donotpresent
410+
411+
# Directories potentially created on remote AFP share
412+
.AppleDB
413+
.AppleDesktop
414+
Network Trash Folder
415+
Temporary Items
416+
.apdisk
417+
418+
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
419+
# Windows thumbnail cache files
420+
Thumbs.db
421+
ehthumbs.db
422+
ehthumbs_vista.db
423+
424+
# Dump file
425+
*.stackdump
426+
427+
# Folder config file
428+
[Dd]esktop.ini
429+
430+
# Recycle Bin used on file shares
431+
$RECYCLE.BIN/
432+
433+
# Windows Installer files
434+
*.cab
435+
*.msi
436+
*.msix
437+
*.msm
438+
*.msp
439+
440+
# Windows shortcuts
441+
*.lnk
442+
443+
# JetBrains Rider
444+
.idea/
445+
*.sln.iml
446+
447+
##
448+
## Visual Studio Code
449+
##
450+
.vscode/*
451+
!.vscode/settings.json
452+
!.vscode/tasks.json
453+
!.vscode/launch.json
454+
!.vscode/extensions.json

.gitmodules

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
[submodule "InnoSetupLogParser"]
2-
path = InnoSetupLogParser
1+
[submodule "ApplyUpdate-Avalonia/Hi3Helper.Http"]
2+
path = ApplyUpdate-Avalonia/Hi3Helper.Http
3+
url = https://github.com/CollapseLauncher/Hi3Helper.Http
4+
[submodule "ApplyUpdate-Avalonia/InnoSetupLogParser"]
5+
path = ApplyUpdate-Avalonia/InnoSetupLogParser
36
url = https://github.com/CollapseLauncher/InnoSetupLogParser

App.xaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

App.xaml.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<!--If you are willing to use Windows/MacOS native APIs you will need to create 3 projects.
5+
One for Windows with net7.0-windows TFM, one for MacOS with net7.0-macos and one with net7.0 TFM for Linux.-->
6+
<TargetFramework>net8.0</TargetFramework>
7+
<Nullable>enable</Nullable>
8+
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
9+
<ApplicationManifest>app.manifest</ApplicationManifest>
10+
<ApplicationIcon>..\ApplyUpdate-Avalonia\Assets\icon.ico</ApplicationIcon>
11+
<Platforms>x64</Platforms>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<DirectPInvoke Include="libHarfBuzzSharp" />
16+
<NativeLibrary Include="nativeLib\libHarfBuzzSharp.lib" Condition="$(RuntimeIdentifier.StartsWith('win'))" />
17+
<DirectPInvoke Include="libSkiaSharp" />
18+
<NativeLibrary Include="nativeLib\libSkiaSharp.lib" Condition="$(RuntimeIdentifier.StartsWith('win'))" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<PackageReference Include="Avalonia.Angle.Windows.Natives" Version="2.1.22087.20231008" />
23+
<PackageReference Include="Avalonia.Skia" Version="11.0.6" />
24+
<PackageReference Include="Avalonia.Win32" Version="11.0.6" />
25+
</ItemGroup>
26+
27+
<ItemGroup>
28+
<ProjectReference Include="..\ApplyUpdate-Avalonia\ApplyUpdate-Avalonia.csproj" />
29+
</ItemGroup>
30+
</Project>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
using Avalonia;
2+
using Avalonia.Rendering;
3+
// using Avalonia.ReactiveUI;
4+
using System;
5+
using System.IO;
6+
using System.IO.Compression;
7+
8+
namespace ApplyUpdate;
9+
10+
class Program
11+
{
12+
// Initialization code. Don't use any Avalonia, third-party APIs or any
13+
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
14+
// yet and stuff might break.
15+
[STAThread]
16+
public static void Main(string[] args)
17+
{
18+
// PInvoke.AllocateConsole();
19+
if (args.Length != 0 && args[0].ToLower() == "compress")
20+
{
21+
#if !DEBUG
22+
PInvoke.AllocateConsole();
23+
#endif
24+
if (CompressMode(args) > 0) Console.ReadLine();
25+
return;
26+
}
27+
28+
if (Directory.GetCurrentDirectory().Trim('\\') != UpdateTask.realExecDir.Trim('\\'))
29+
{
30+
Console.WriteLine($"Moving to the right working directory ({UpdateTask.realExecDir})...");
31+
Directory.SetCurrentDirectory(UpdateTask.realExecDir);
32+
}
33+
34+
#if !DEBUG
35+
// PInvoke.AllocateConsole();
36+
PInvoke.ShowWindow(PInvoke.m_consoleWindow, 0);
37+
#endif
38+
39+
BuildAvaloniaApp()
40+
.StartWithClassicDesktopLifetime(args);
41+
}
42+
43+
// Avalonia configuration, don't remove; also used by visual designer.
44+
public static AppBuilder BuildAvaloniaApp()
45+
=> AppBuilder.Configure<App>()
46+
.UseSkia()
47+
.UseWin32()
48+
#if DEBUG
49+
.LogToTrace()
50+
#endif
51+
// .UseReactiveUI()
52+
;
53+
54+
private static int CompressMode(params string[] args)
55+
{
56+
if (args.Length != 3)
57+
{
58+
Console.WriteLine("Please define Input and Output file path");
59+
return 1;
60+
}
61+
62+
if (!File.Exists(args[1]))
63+
{
64+
Console.WriteLine("Input file doesn't exist!");
65+
Console.WriteLine("Path: " + args[1]);
66+
return 2;
67+
}
68+
69+
if (!Directory.Exists(Path.GetDirectoryName(args[2])))
70+
{
71+
Console.WriteLine("Output directory from given path doesn't exist!");
72+
Console.WriteLine("Path: " + args[2]);
73+
return 2;
74+
}
75+
76+
using (FileStream fsi = new FileStream(args[1], FileMode.Open, FileAccess.Read))
77+
using (FileStream fso = new FileStream(args[2], FileMode.Create, FileAccess.Write))
78+
using (BrotliStream bso = new BrotliStream(fso, CompressionMode.Compress, true))
79+
{
80+
Console.WriteLine("Input path: " + args[1]);
81+
Console.WriteLine("Output path: " + args[2]);
82+
byte[] buffer = new byte[4 << 14];
83+
Console.WriteLine("Input filesize: " + fsi.Length + " bytes");
84+
85+
int read = 0;
86+
long curRead = 0;
87+
long length = fsi.Length;
88+
while ((read = fsi.Read(buffer, 0, buffer.Length)) > 0)
89+
{
90+
curRead += read;
91+
Console.Write($"\rCompressing: {Math.Round(((double)curRead / length) * 100, 4)}%...");
92+
bso.Write(buffer, 0, read);
93+
}
94+
Console.WriteLine(" Completed!");
95+
Console.WriteLine("Output filesize: " + fso.Length + " bytes");
96+
Console.WriteLine($"Compression ratio: {Math.Round((double)fso.Length / fsi.Length * 100, 4)}%");
97+
}
98+
99+
return 0;
100+
}
101+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<Configuration>Release</Configuration>
8+
<Platform>x64</Platform>
9+
<PublishDir>build</PublishDir>
10+
<PublishProtocol>FileSystem</PublishProtocol>
11+
<_TargetId>Folder</_TargetId>
12+
<TargetFramework>net8.0</TargetFramework>
13+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
14+
<Optimize>True</Optimize>
15+
<PublishAot>true</PublishAot>
16+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
17+
<OptimizationPreference>Size</OptimizationPreference>
18+
<TrimmerRemoveSymbols>true</TrimmerRemoveSymbols>
19+
<EventSourceSupport>false</EventSourceSupport>
20+
<StackTraceSupport>false</StackTraceSupport>
21+
<MetadataUpdaterSupport>false</MetadataUpdaterSupport>
22+
<InvariantGlobalization>true</InvariantGlobalization>
23+
<AutoreleasePoolSupport>false</AutoreleasePoolSupport>
24+
<EnableUnsafeBinaryFormatterSerialization>false</EnableUnsafeBinaryFormatterSerialization>
25+
<EnableUnsafeUTF7Encoding>false</EnableUnsafeUTF7Encoding>
26+
<EventSourceSupport>false</EventSourceSupport>
27+
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
28+
<UseSystemResourceKeys>true</UseSystemResourceKeys>
29+
<DebuggerSupport>false</DebuggerSupport>
30+
</PropertyGroup>
31+
</Project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<Configuration>Release</Configuration>
8+
<Platform>x64</Platform>
9+
<PublishDir>build</PublishDir>
10+
<PublishProtocol>FileSystem</PublishProtocol>
11+
<_TargetId>Folder</_TargetId>
12+
<TargetFramework>net8.0</TargetFramework>
13+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
14+
<Optimize>True</Optimize>
15+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
16+
<OptimizationPreference>Size</OptimizationPreference>
17+
<TrimmerRemoveSymbols>true</TrimmerRemoveSymbols>
18+
<EventSourceSupport>false</EventSourceSupport>
19+
<StackTraceSupport>false</StackTraceSupport>
20+
<MetadataUpdaterSupport>false</MetadataUpdaterSupport>
21+
<InvariantGlobalization>true</InvariantGlobalization>
22+
<AutoreleasePoolSupport>false</AutoreleasePoolSupport>
23+
<EnableUnsafeBinaryFormatterSerialization>false</EnableUnsafeBinaryFormatterSerialization>
24+
<EnableUnsafeUTF7Encoding>false</EnableUnsafeUTF7Encoding>
25+
<EventSourceSupport>false</EventSourceSupport>
26+
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
27+
<UseSystemResourceKeys>true</UseSystemResourceKeys>
28+
<DebuggerSupport>false</DebuggerSupport>
29+
<SelfContained>true</SelfContained>
30+
<PublishSingleFile>false</PublishSingleFile>
31+
<PublishReadyToRun>false</PublishReadyToRun>
32+
<PublishTrimmed>true</PublishTrimmed>
33+
</PropertyGroup>
34+
</Project>

0 commit comments

Comments
 (0)