This guide explains how to build Read Zen as a single self-contained executable.
-
Single executable: All .NET dependencies are bundled into one
.exefile -
No .NET runtime required: Users don't need to install .NET 8.0
-
Portable: Can be copied to any Windows machine and run
- .NET 8.0 SDK (for building only)
- Visual Studio 2022 or VS Code (optional)
# Run the build script
.\build-selfcontained.batThis will create the executable in bin\SelfContained\
# Clean previous builds
dotnet clean -c Release
# Build self-contained single file
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:EnableCompressionInSingleFile=true -o bin\SelfContained- Right-click the project → Publish
- Select Folder target
- Choose win-x64 runtime
- Set Deployment mode to Self-contained
- Enable Produce single file
- Click Publish
After building, you'll have:
bin\SelfContained\
├── ReadZen.App.exe # ~46MB single executable
├── Assets\
│ └── Dict\
│ └── cedict_ts.u8 # Dictionary file (embedded)
The self-contained executable does NOT include the CBETA XML database. You must also provide:
- ReadZen folder (~500MB+)
- Contains 4,990 XML files in
xml-p5/subfolder - Translation files in
xml-p5t/andmd-p5t/ - Index files and metadata
- Must be placed in same directory as the exe
- Contains 4,990 XML files in
[Application Directory]\
├── ReadZen.App.exe # ~46MB self-contained exe
└── ReadZen\ # ~500MB+ CBETA database
├── xml-p5\ # Original XML files
├── xml-p5t\ # Translated XML files
├── md-p5t\ # Markdown translations
├── canons.json # Canon metadata
└── index.cache.json # Search index
- Size: The XML database is ~500MB+ vs 46MB exe
- Updates: Database can be updated independently of app
- Flexibility: Users can choose which canons to include
- Build time: Including 5,000+ files would make builds extremely slow
The project file (ReadZen.App.csproj) includes these key settings:
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>false</PublishTrimmed>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>- Avalonia compatibility: Trimming can break Avalonia UI frameworks
- Reflection-heavy code: Buddhist metadata service uses reflection
- Stability: Full framework inclusion prevents runtime issues
- Copy the entire
bin\SelfContained\folder - The application will run without any .NET runtime installation
- Single exe: ~46MB (compressed with all dependencies)
- Dictionary: ~9.3MB (embedded)
- Total: ~55MB
-
Build fails with warnings
- Warnings are expected (nullable reference warnings)
- Build should still succeed despite warnings
-
Application won't start
- Verify Windows version compatibility (Windows 10+)
- Check antivirus isn't blocking the executable
To verify the build worked:
# Check file size (should be ~46MB)
dir bin\SelfContained\ReadZen.App.exe
# Check embedded assets
dir bin\SelfContained\Assets\Dict\cedict_ts.u8- Development: Use regular Debug/Release builds for faster iteration
- Production: Use self-contained builds for distribution
- Testing: Test self-contained builds before distribution
- The self-contained build includes the Chinese dictionary (
cedict_ts.u8) automatically - Build time is longer due to framework bundling (~20-30 seconds)
- Startup time may be slightly slower due to decompression
- Memory usage is comparable to regular builds