Spike: net48-only launcher (evaluate size vs net8 self-contained)

Converts the Launcher Service + Agent from net8/win-x64 self-contained to net48
framework-dependent, and makes Tesla.Contract net48-only (drops multi-targeting).
Both consumers (Console + Launcher) are now a single TFM.

Code changes for net48 (the only net8/netstandard2.1 APIs in use):
- RandomNumberGenerator.Fill -> RandomNumberGenerator.Create().GetBytes (3x)
- TcpListener.AcceptTcpClientAsync(ct) -> AcceptTcpClientAsync() + stop-on-cancel
- byte[].AsSpan().SequenceEqual -> Linq SequenceEqual (no System.Memory) (2x)
- PipeStream.Write(byte[]) / WriteAsync(byte[],ct) -> explicit (buf,0,len[,ct])
- Math.Clamp -> Math.Max/Min
The generic host (Microsoft.Extensions.Hosting 8.x + UseWindowsService) runs on
net48 unchanged. build.bat/install.bat updated for the folder-of-DLLs deploy;
solution platform reverted x64 -> AnyCPU.

RESULT — package size: ~3.7 MB on disk / 1.58 MB zipped, vs ~213 MB / 91 MB for
the net8 self-contained build (~50-58x smaller). net48 ships in Win10/11 so no
runtime prerequisite. 73 tests green; NOT re-validated on a live pod.

Spike branch for evaluation — do not merge without a pod re-test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-06-30 11:46:00 -05:00
co-authored by Claude Opus 4.8
parent d873b653c7
commit 1e2ec12f11
9 changed files with 79 additions and 73 deletions
+5 -11
View File
@@ -3,11 +3,12 @@
:: TeslaLauncher — Unified Build / Package Script
:: =============================================================================
:: Publishes TeslaLauncherService.exe and TeslaLauncherAgent.exe as
:: self-contained single-file win-x64 executables (net8) and assembles the
:: installable TeslaLauncher\ package next to install.bat.
:: framework-dependent net48 builds and assembles the installable TeslaLauncher\
:: package next to install.bat. The target pod needs .NET Framework 4.8 (built
:: into Windows 10/11) — there is no bundled runtime, so the package is small.
::
:: Requirements:
:: .NET 8 SDK https://dotnet.microsoft.com/download/dotnet/8.0
:: .NET SDK (6.0+) to drive the build https://dotnet.microsoft.com/download
:: Internet access for NuGet restore (first build only)
::
:: Usage:
@@ -31,7 +32,6 @@ setlocal enabledelayedexpansion
set ROOT=%~dp0
set BUILD_DIR=%ROOT%TeslaLauncher
set RID=win-x64
:: -- Parse arguments ----------------------------------------------------------
set BUILD_SERVICE=1
@@ -46,7 +46,7 @@ for %%a in (%*) do (
echo.
echo ============================================================
echo Tesla Launcher v0.1 - Build ^& Package (net8, %RID%)
echo Tesla Launcher v0.1 - Build ^& Package (net48, framework-dependent)
echo Output : %BUILD_DIR%
echo ============================================================
echo.
@@ -75,9 +75,6 @@ echo [1/2] Publishing TeslaLauncherService (Session 0 Windows Service)...
echo.
dotnet publish "%ROOT%TeslaLauncherService.csproj" ^
-c Release ^
-r %RID% ^
--self-contained true ^
-p:PublishSingleFile=true ^
-o "%BUILD_DIR%\Service"
if errorlevel 1 (
echo.
@@ -98,9 +95,6 @@ if %BUILD_SERVICE%==1 (echo [2/2] Publishing TeslaLauncherAgent...) else (echo [
echo.
dotnet publish "%ROOT%TeslaLauncherAgent.csproj" ^
-c Release ^
-r %RID% ^
--self-contained true ^
-p:PublishSingleFile=true ^
"-p:DefineConstants=WINFORMS" ^
-o "%BUILD_DIR%\Agent"
if errorlevel 1 (