Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ jobs:
- name: Verify published files
shell: pwsh
run: |
$required = @('${{ matrix.executable }}', 'ui/index.html', 'ui/app.js', 'team-saves/Start/about.txt')
if ($IsWindows) {
$required += @('libSkiaSharp.dll', 'libHarfBuzzSharp.dll')
$required = @('${{ matrix.executable }}')
if ($IsLinux) {
$required += @('ui/index.html', 'ui/app.js', 'team-saves/Start/about.txt')
} else {
$extra = @(Get-ChildItem -LiteralPath dist/publish | Where-Object { $_.Name -notin @('VISaveManager.exe', 'VISaveManager.pdb') })
if ($extra.Count) { throw "Windows publish contains unexpected sidecar files: $($extra.Name -join ', ')" }
}
foreach ($path in $required) {
if (!(Test-Path -LiteralPath "dist/publish/$path" -PathType Leaf)) {
Expand All @@ -72,9 +75,7 @@ jobs:
- name: Package Windows build
if: runner.os == 'Windows'
shell: pwsh
run: |
$files = Get-ChildItem -LiteralPath dist/publish | Where-Object Extension -ne '.pdb'
Compress-Archive -LiteralPath $files.FullName -DestinationPath 'dist/VISaveManager-win-x64.zip'
run: Compress-Archive -LiteralPath 'dist/publish/VISaveManager.exe' -DestinationPath 'dist/VISaveManager-win-x64.zip'

- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
Expand Down Expand Up @@ -105,4 +106,6 @@ jobs:
- name: Test Windows WebView2 save load
if: runner.os == 'Windows'
timeout-minutes: 3
run: node tests/windows-nativeaot-smoke.mjs dist/publish
run: |
Expand-Archive -LiteralPath dist/VISaveManager-win-x64.zip -DestinationPath dist/windows-smoke
node tests/windows-nativeaot-smoke.mjs dist/windows-smoke
10 changes: 6 additions & 4 deletions NativeWindowsHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ namespace VISM;
// WebView2 owns the content surface inside the form.
sealed class NativeWindowsHost : Form, IDesktopHost
{
readonly Uri page = new(Path.Combine(AppContext.BaseDirectory, "ui", "index.html"));
readonly Uri page;
readonly NativeWebView view = new();
readonly SaveManager controller;
bool closing;
bool handlingMessage;

NativeWindowsHost(bool test)
NativeWindowsHost(bool test, string assetsDirectory)
{
controller = new SaveManager(this, test, null);
page = new Uri(Path.Combine(assetsDirectory, "ui", "index.html"));
controller = new SaveManager(this, test, null, assetsDirectory);
Directory.CreateDirectory(controller.ProfileDirectory);

Text = test ? "VI Save Manager (test profile)" : "VI Save Manager";
Expand Down Expand Up @@ -65,11 +66,12 @@ public static int Start(bool test)
try
{
if (test) Console.Error.WriteLine("Starting the compatibility host");
string assetsDirectory = WindowsBundle.Unpack(new SaveLocations(test, null).ProfileDirectory);
Platform.Backend = new AvaloniaPlatformBackend();
Platform.Backend.Initialize();
if (!WebViewAdapterInfo.GetAdapterInfo(WebViewAdapterType.WebView2).IsSupported)
throw new InvalidOperationException("Install the Microsoft Edge WebView2 Runtime to start VI Save Manager.");
using var host = new NativeWindowsHost(test);
using var host = new NativeWindowsHost(test, assetsDirectory);
Majorsilence.Forms.Application.Run(host);
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ interface IDesktopHost
void RevealExport(string path);
}

sealed class SaveManager(IDesktopHost host, bool test, string? saveDirectory)
sealed class SaveManager(IDesktopHost host, bool test, string? saveDirectory, string? assetsDirectory = null)
{
const string TitleId = SaveLocations.TitleId;
readonly SaveLocations locations = new(test, saveDirectory);
public string ProfileDirectory => locations.ProfileDirectory;
string SnapsRoot => Path.Combine(ProfileDirectory, "saves");
string SkippedVersionFile => Path.Combine(ProfileDirectory, "skipped-version.txt");
static string TeamRoot => Path.Combine(AppContext.BaseDirectory, "team-saves");
string TeamRoot => Path.Combine(assetsDirectory ?? AppContext.BaseDirectory, "team-saves");

// ---- updates: the only thing this app asks the internet. One anonymous request to GitHub's
// public API for the newest release of this repo; nothing about the user is sent. ----
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Kept saves and backups are in `~/.local/share/VISaveManager/saves` (or under `$X

Download the Windows zip from **Releases**, extract it, and run `VISaveManager.exe`. Windows 10 or later and the Microsoft Edge WebView2 Runtime are required. The game folder is `%LOCALAPPDATA%\victory\data\7952987A\saves`. Kept saves and backups are in `%LOCALAPPDATA%\VISaveManager\saves`.

To build a Windows NativeAOT ZIP from source, install the .NET 10 SDK and Visual Studio Build Tools with **Desktop development with C++**. Run `release.ps1` on Windows x64. The NativeAOT build uses the Majorsilence.Forms compatibility layer with its Avalonia backend and ships the Windows x64 SkiaSharp and HarfBuzzSharp libraries alongside the EXE.
To build a Windows NativeAOT ZIP from source, install the .NET 10 SDK and Visual Studio Build Tools with **Desktop development with C++**. Run `release.ps1` on Windows x64. The NativeAOT build uses the Majorsilence.Forms compatibility layer with its Avalonia backend. The ZIP contains only `VISaveManager.exe`. On first launch it unpacks the embedded UI, team saves, native libraries, and third-party notices into a versioned cache under `%LOCALAPPDATA%\VISaveManager\runtime`. The EXE can run from any folder.

```powershell
powershell -ExecutionPolicy Bypass -File build.ps1 # build and add shortcuts
Expand All @@ -64,4 +64,4 @@ The **Build VISM** workflow compiles both platforms on pull requests into `main`
- `VISaveManager-linux-x64` contains `VISaveManager-linux-x64.tar.gz`. Extract it to a folder and run `./VISaveManager`. GTK3 and WebKitGTK are required.
- `VISaveManager-win-x64` contains `VISaveManager-win-x64.zip`. Extract it to a folder and run `VISaveManager.exe`. The WebView2 Runtime is required.

Both archives contain a NativeAOT executable, the application interface, and the bundled team saves. An installed .NET runtime is unnecessary.
Both archives include the application interface and team saves. Neither requires a .NET installation.
45 changes: 37 additions & 8 deletions VISaveManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<Compile Remove="LinuxHost.cs" />
</ItemGroup>
<PropertyGroup Condition="'$(VismWindows)' == 'true' and '$(PublishAot)' == 'true'">
<VismWindowsBundle>true</VismWindowsBundle>
<DefineConstants>$(DefineConstants);VISM_NATIVE_WINDOWS</DefineConstants>
<OutputType>WinExe</OutputType>
<ApplicationIcon>vism.ico</ApplicationIcon>
Expand All @@ -36,21 +37,49 @@
<ItemGroup Condition="'$(VismWindows)' == 'true' and '$(PublishAot)' == 'true'">
<Compile Remove="LinuxHost.cs" />
<PackageReference Include="Majorsilence.Forms.Avalonia" Version="26.11.19" />
<PackageReference Include="SkiaSharp.NativeAssets.Win32" Version="3.119.4" GeneratePathProperty="true" />
<PackageReference Include="Avalonia.Angle.Windows.Natives" Version="2.1.27548.20260419" GeneratePathProperty="true" ExcludeAssets="native" />
<PackageReference Include="SkiaSharp.NativeAssets.Win32" Version="3.119.4" GeneratePathProperty="true" ExcludeAssets="native" />
<PackageReference Include="SkiaSharp.HarfBuzz" Version="3.119.4" />
<PackageReference Include="HarfBuzzSharp.NativeAssets.Win32" Version="8.3.1.5" GeneratePathProperty="true" />
<None Include="$(PkgSkiaSharp_NativeAssets_Win32)/LICENSE.txt;$(PkgSkiaSharp_NativeAssets_Win32)/THIRD-PARTY-NOTICES.txt"
Link="THIRD-PARTY/SkiaSharp-%(Filename)%(Extension)" CopyToPublishDirectory="PreserveNewest" />
<None Include="$(PkgHarfBuzzSharp_NativeAssets_Win32)/LICENSE.txt;$(PkgHarfBuzzSharp_NativeAssets_Win32)/THIRD-PARTY-NOTICES.txt"
Link="THIRD-PARTY/HarfBuzzSharp-%(Filename)%(Extension)" CopyToPublishDirectory="PreserveNewest" />
<PackageReference Include="HarfBuzzSharp.NativeAssets.Win32" Version="8.3.1.5" GeneratePathProperty="true" ExcludeAssets="native" />
</ItemGroup>
<ItemGroup Condition="'$(VismWindows)' != 'true' or '$(PublishAot)' != 'true'">
<Compile Remove="NativeWindowsHost.cs" />
<Compile Remove="NativeWindowsHost.cs;WindowsBundle.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net8.0-windows'">
<Compile Remove="WindowsHost.cs" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(VismWindowsBundle)' != 'true'">
<None Update="vism.ico;ui/**/*;team-saves/**/*" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
</ItemGroup>
<Target Name="BuildVismWindowsBundle" BeforeTargets="AssignTargetPaths"
Condition="'$(VismWindowsBundle)' == 'true'">
<Error Condition="'$(RuntimeIdentifier)' != 'win-x64'" Text="The VISM Windows NativeAOT bundle requires win-x64." />
<PropertyGroup>
<BundleStaging>$(IntermediateOutputPath)windows-bundle/</BundleStaging>
<BundleArchive>$(IntermediateOutputPath)windows-bundle.zip</BundleArchive>
</PropertyGroup>
<ItemGroup>
<VismUiFile Include="ui/**/*" Exclude="ui/rvil.png" />
<VismTeamSave Include="team-saves/**/*" />
<VismNativeDll Include="$(PkgSkiaSharp_NativeAssets_Win32)/runtimes/win-x64/native/libSkiaSharp.dll;
$(PkgHarfBuzzSharp_NativeAssets_Win32)/runtimes/win-x64/native/libHarfBuzzSharp.dll;
$(PkgAvalonia_Angle_Windows_Natives)/runtimes/win-x64/native/av_libglesv2.dll" />
<VismNotice Include="notices/windows/*.txt" />
<VismSkiaNotice Include="$(PkgSkiaSharp_NativeAssets_Win32)/LICENSE.txt;$(PkgSkiaSharp_NativeAssets_Win32)/THIRD-PARTY-NOTICES.txt" />
<VismHarfBuzzNotice Include="$(PkgHarfBuzzSharp_NativeAssets_Win32)/LICENSE.txt;$(PkgHarfBuzzSharp_NativeAssets_Win32)/THIRD-PARTY-NOTICES.txt" />
<EmbeddedResource Include="$(BundleArchive)" LogicalName="VISM.WindowsBundle.zip" />
</ItemGroup>
<RemoveDir Directories="$(BundleStaging)" />
<Copy SourceFiles="@(VismUiFile)" DestinationFiles="@(VismUiFile->'$(BundleStaging)ui/%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(VismTeamSave)" DestinationFiles="@(VismTeamSave->'$(BundleStaging)team-saves/%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(VismNativeDll)" DestinationFolder="$(BundleStaging)" />
<Copy SourceFiles="@(VismNotice)" DestinationFolder="$(BundleStaging)THIRD-PARTY" />
<Copy SourceFiles="$(PkgAvalonia_Angle_Windows_Natives)/LICENSE"
DestinationFiles="$(BundleStaging)THIRD-PARTY/ANGLE-LICENSE.txt" />
<Copy SourceFiles="@(VismSkiaNotice)" DestinationFiles="@(VismSkiaNotice->'$(BundleStaging)THIRD-PARTY/SkiaSharp-%(Filename)%(Extension)')" />
<Copy SourceFiles="@(VismHarfBuzzNotice)" DestinationFiles="@(VismHarfBuzzNotice->'$(BundleStaging)THIRD-PARTY/HarfBuzzSharp-%(Filename)%(Extension)')" />
<Copy SourceFiles="$(NetCoreRoot)LICENSE.txt;$(NetCoreRoot)ThirdPartyNotices.txt;$(PkgMicrosoft_DotNet_ILCompiler)/THIRD-PARTY-NOTICES.TXT"
DestinationFiles="$(BundleStaging)THIRD-PARTY/dotnet-LICENSE.txt;$(BundleStaging)THIRD-PARTY/dotnet-THIRD-PARTY-NOTICES.txt;$(BundleStaging)THIRD-PARTY/ILCompiler-THIRD-PARTY-NOTICES.txt" />
<ZipDirectory SourceDirectory="$(BundleStaging)" DestinationFile="$(BundleArchive)" Overwrite="true" />
</Target>
</Project>
63 changes: 63 additions & 0 deletions WindowsBundle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System.ComponentModel;
using System.IO.Compression;
using System.Runtime.InteropServices;
using System.Security.Cryptography;

namespace VISM;

static class WindowsBundle
{
const string ResourceName = "VISM.WindowsBundle.zip";
const uint SearchDllDirectory = 0x100;
const uint SearchSystem32 = 0x800;
static readonly string[] Libraries = ["libSkiaSharp.dll", "libHarfBuzzSharp.dll", "av_libglesv2.dll"];

public static string Unpack(string profileDirectory)
{
using var payload = typeof(WindowsBundle).Assembly.GetManifestResourceStream(ResourceName)
?? throw new InvalidOperationException("The executable has no embedded Windows assets.");
string revision = Convert.ToHexString(SHA256.HashData(payload));
payload.Position = 0;
using var archive = new ZipArchive(payload, ZipArchiveMode.Read);
string cache = Path.Combine(profileDirectory, "runtime");
string root = Path.Combine(cache, revision);

if (!Directory.Exists(root))
Install(archive, cache, root);

foreach (string library in Libraries)
{
string path = Path.Combine(root, library);
using var embedded = archive.GetEntry(library)!.Open();

// Keep the verified file open while the loader maps it, so it cannot be replaced.
using var extracted = File.OpenRead(path);
if (!SHA256.HashData(embedded).AsSpan().SequenceEqual(SHA256.HashData(extracted)))
throw new InvalidDataException($"The cached {library} is damaged. Remove the runtime cache at {root} and restart.");

if (LoadLibraryExW(path, IntPtr.Zero, SearchDllDirectory | SearchSystem32) == IntPtr.Zero)
throw new Win32Exception(Marshal.GetLastWin32Error(), $"Could not load {library}.");
}
return root;
}

static void Install(ZipArchive archive, string cache, string root)
{
Directory.CreateDirectory(cache);
string staging = Path.Combine(cache, Guid.NewGuid().ToString("N"));
try
{
archive.ExtractToDirectory(staging);
try { Directory.Move(staging, root); }
catch (IOException) when (Directory.Exists(root)) { } // Another launch installed the same bundle.
}
finally
{
if (Directory.Exists(staging))
Directory.Delete(staging, recursive: true);
}
}

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
static extern IntPtr LoadLibraryExW(string fileName, IntPtr file, uint flags);
}
22 changes: 22 additions & 0 deletions notices/windows/Avalonia-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) AvaloniaUI OÜ
All Rights Reserved

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
21 changes: 21 additions & 0 deletions notices/windows/Avalonia.Controls.WebView-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 AvaloniaUI OÜ

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
41 changes: 41 additions & 0 deletions notices/windows/Majorsilence.Forms-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## MIT License

Copyright (c) Jonathan Pobst
Copyright (c) Peter Gill (Majorsilence)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

## Attribution

Majorsilence.Forms began as a fork of [Modern.Forms](https://github.com/modern-forms/Modern.Forms)
by Jonathan Pobst, whose copyright notice above covers that original work and continues to apply to
the substantial portions of this codebase derived from it. Subsequent work — including the Avalonia,
Uno and headless backends, the `Majorsilence.Forms.Drawing` layer, the Telerik and WinForms
compatibility shims, and the `majorsilence-migrate` tool — is copyright Peter Gill (Majorsilence)
and is released under the same MIT terms.

Portions of that subsequent work were written with the assistance of Anthropic's Claude. Those
contributions were directed, reviewed and accepted by the human authors named above, are covered by
the copyright notices above, and carry the same MIT license as the rest of the project. This note is
an acknowledgement of how the work was produced, not a separate grant or reservation of rights: an
AI tool is not a copyright holder, and Anthropic's terms assign whatever interest it may have in
model output to the person who prompted it.

Third-party code vendored into this repository is listed separately in
[`third-party-licenses.md`](third-party-licenses.md), under its own licenses.
3 changes: 1 addition & 2 deletions release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dotnet publish -c Release -r win-x64 -p:PublishAot=true -o $out
if ($LASTEXITCODE -ne 0) { throw "Build failed (exit code $LASTEXITCODE)" }
$zip = Join-Path $PSScriptRoot "dist\VISaveManager-$version.zip"
if (Test-Path $zip) { Remove-Item $zip -Force }
$files = Get-ChildItem -LiteralPath $out | Where-Object Extension -ne '.pdb'
Compress-Archive -LiteralPath $files.FullName -DestinationPath $zip
Compress-Archive -LiteralPath (Join-Path $out 'VISaveManager.exe') -DestinationPath $zip
Write-Host "Zip to share: $zip" -ForegroundColor Green
explorer.exe "/select,`"$zip`""
Loading