![]() |
VOOZH | about |
dotnet add package Galdr --version 1.1.2
NuGet\Install-Package Galdr -Version 1.1.2
<PackageReference Include="Galdr" Version="1.1.2" />
<PackageVersion Include="Galdr" Version="1.1.2" />Directory.Packages.props
<PackageReference Include="Galdr" />Project file
paket add Galdr --version 1.1.2
#r "nuget: Galdr, 1.1.2"
#:package Galdr@1.1.2
#addin nuget:?package=Galdr&version=1.1.2Install as a Cake Addin
#tool nuget:?package=Galdr&version=1.1.2Install as a Cake Tool
Galdr is a framework for building multi-platform desktop applications using C#. It's powered by webview and compatible with any frontend web framework of your choice.
Features:
The setup is pretty straight forward and steps are outlined below - or you can use the proof-of-concept example project here as a template.
<OutputType>WinExe</OutputType> instead of Exe to make sure the console window is hidden.src directory inside your C# project.index.html and package.json just like you normally would when setting up a front end project.dist directory path to your csrpoj so it will be included as an emeded resource.Main.
[STAThread] attribute on Windows.Linux support requires webkit2gtk and gtk3.
With a distribution using apt:
sudo apt install -y libwebkit2gtk-4.1-dev libgtk-3-dev
With a distribution using dnf:
sudo dnf install webkit2gtk4.1-devel gtk3-devel
internal class Program
{
// Single-threaded apartment is required for COM on Windows
[STAThread]
static void Main(string[] args)
{
using Galdr.Galdr galdr = new GaldrBuilder()
.SetTitle("Galdr + C# + Vue 3 App")
.SetSize(1024, 768)
.SetMinSize(800, 600)
.AddSingleton<SingletonExample>()
.AddService<TransientExample>()
.SetPort(1313)
.Build()
.Run();
}
}
The front end should be included as an embedded resource.
<ItemGroup>
<EmbeddedResource Include="dist\**\*.*">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
Any method tagged with the [Command] attribute in the Command namespace will be added for use on the frontend. The namespace can be customized by calling SetCommandNamespace on the builder. The command attribute optionally takes in a command name (it uses the method name by default).
[Command]
public static string Greet(string name)
{
return $"Hello, {name}! You've been greeted from C#!";
}
Then you can use the command anywhere on the frontend with galdrInvoke. The command names are made camelCase in js.
galdrInvoke("greet", { name: name.value })
.then(name => greetMsg.value = name)
.catch(e => console.error(e));
// or using async/await
greetMsg.value = await galdrInvoke("greet", { name: name.value });
Any additional parameters can be added to the galdrInvoke call after the command name. The parameters will automatically be deserialized and passed into the C# method. Parameters not passed in by the frontend will be evaluated via dependency injection. The command's class can also contain dependencies in the constructor.
To debug the application with hot-reload, open a terminal and start the server.
npm install
npm run dev
Then just hit F5 and you can start and debug the application like normal.
The frontend is served from files embedded into the assembly in the dist directory on build, so the first step is to build the frontend.
npm install
npm run build
Then you can build the app as a single file using dotnet publish - just be sure to update to the platform.
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
To reduce the binary size you can optionally trim the code.
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:PublishTrimmed=True -p:TrimMode=link
Note that trimming can break reflection when classes aren't statically referenced. This can be fixed by setting the trimmer root assembly in the csproj.
<ItemGroup>
<TrimmerRootAssembly Include="$(AssemblyName)" />
</ItemGroup>
Galdr.Native is designed for native AOT support. It has all the same features as Galdr with a couple small differences:
Additional Features:
Commands are no longer added using Attributes or a namespace due to AOT constraints. Instead commands are added using the AddAction and AddFunction methods on GaldrBuilder.
Actions and functions support up to 16 parameters. There are no changes to the way commands are called from the frontend code.
// Actions are used for void return types
builder.AddAction("commandTest1", () =>
{
Debug.WriteLine("Command Test 1!");
});
// Functions are used when you need to return something from the command
builder.AddFunction("commandTest3", (int x) =>
{
Debug.WriteLine($"Command Test 3 {x}!");
return new TestResult { };
});
// Dependency injection is fully supported
builder.AddSingleton<PrintService>();
builder.AddFunction("commandTest4", (int count, PrintRequest request, PrintService printService) =>
{
for (int i = 0; i < count; ++i)
{
printService.Print(request.Id, request.Name);
}
return new PrintResponse
{
Success = true,
};
});
Any classes that appear as a return type or parameters for actions/functions are detected on build. Source generation is used to create the needed JSON serializers for these classes. This was designed to be simple and automatic - there is no need for a JsonSerializerContext like with minimal APIs.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.2 | 140 | 12/28/2025 |
| 1.1.1 | 312 | 12/16/2025 |
| 1.1.0 | 162 | 12/11/2025 |
| 1.0.8 | 227 | 12/3/2025 |
| 1.0.7 | 437 | 11/19/2025 |
| 1.0.6 | 356 | 8/25/2025 |
| 1.0.5 | 216 | 8/19/2025 |
| 1.0.4 | 241 | 8/8/2025 |
| 1.0.3 | 298 | 8/7/2025 |
| 1.0.2 | 283 | 8/7/2025 |
| 1.0.0 | 241 | 4/23/2024 |
| 0.0.7 | 338 | 3/1/2024 |
| 0.0.6 | 219 | 2/29/2024 |
| 0.0.5 | 228 | 2/28/2024 |
| 0.0.4 | 230 | 2/28/2024 |
| 0.0.3 | 237 | 2/26/2024 |