Open kasajian opened 5 months ago
This proposal is different enough that it may make sense to have it be entirely different project to this, but probably many of the bindings can be reused.
I've been trimming my projects to reduce the binary size. It works pretty well, and I can usually get a single executable between 20 and 50 MB depending on the project and trim mode.
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:PublishTrimmed=True -p:TrimMode=link
If using things like reflection that don't play well with trimming you can use partial mode or do something like this in the csproj.
<ItemGroup>
<TrimmerRootAssembly Include="$(AssemblyName)" />
</ItemGroup>
Currently, you have to ensure that .NET is installed on the target computer. You can't simple deliver the EXE, unless you do a self-contained EXE, in which case it'll be closer to a 100 MB. I tried the basic example, and it produced a stand-alone exe that's 94,175KB (not counting the 1,544KB webview.dll)
However, .NET AOT can produce tiny DLLs that just a few KB. The result DLLs are not .NET assemblies, but they are standard Windows DLLs that can be P/Invoked from any programming language that can call C functions in a DLL (i.e. every language)
This means, there can be an alternate version of webview_csharp which uses a very simple C++ based "Window" applications so that when it's launched it doesn't create a console, which then loads the webview_csharp created AOT DLL with the user's code. The resulting distributable will be relatively small. One would only need to distribute webview.dll, the shell EXE, and the user's AOT DLL(s), enabling a system where a user can write GUI applications with C# that have a very small distribution.