From 78b1978cb7a075104fe8b4469c687a7129815743 Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Thu, 4 Jun 2026 10:50:13 +0200 Subject: [PATCH] Switch production server from dotnet run to published standalone exe Replace 'dotnet run -c Release' with 'dotnet publish' + launch Treemon.exe directly. The production process is now named Treemon.exe instead of dotnet.exe, so dotnet build/test operations cannot accidentally kill it via name-based process matching. - Set AssemblyName to Treemon in Server.fsproj - Add publish step to Start-ProductionServer (dotnet publish -c Release) - Launch .publish/Treemon.exe instead of dotnet run - Add .publish/ to .gitignore --- .gitignore | 1 + src/Server/Server.fsproj | 1 + treemon.ps1 | 10 ++++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ccd7feb..360f457 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ src/Client/output/ # Production deployment wwwroot/ +.publish/ .treemon.pid .treemon.config diff --git a/src/Server/Server.fsproj b/src/Server/Server.fsproj index bd1a59c..8851d36 100644 --- a/src/Server/Server.fsproj +++ b/src/Server/Server.fsproj @@ -2,6 +2,7 @@ Exe + Treemon net9.0 LatestMajor diff --git a/treemon.ps1 b/treemon.ps1 index fdb8753..6e7c756 100644 --- a/treemon.ps1 +++ b/treemon.ps1 @@ -15,6 +15,7 @@ $PidFile = Join-Path $ScriptDir ".treemon.pid" $ConfigFile = Join-Path $ScriptDir ".treemon.config" $LogDir = Join-Path $ScriptDir "logs" $LogFile = Join-Path $LogDir "treemon-prod.log" +$PublishDir = Join-Path $ScriptDir ".publish" $WwwRoot = Join-Path $ScriptDir "wwwroot" $DefaultPort = 5000 if ($env:TREEMON_PORT) { @@ -149,11 +150,16 @@ function Start-ProductionServer([string[]]$Roots) { Save-Config $Roots + Write-Host "Publishing server..." -ForegroundColor Cyan + dotnet publish -c Release -o $PublishDir src/Server/Server.fsproj + if ($LASTEXITCODE -ne 0) { throw "dotnet publish failed" } + + $serverExe = Join-Path $PublishDir "Treemon.exe" $rootArgs = ($Roots | ForEach-Object { "`"$($_.TrimEnd('\', '/'))`"" }) -join " " Write-Host "Starting production server on port $DefaultPort..." -ForegroundColor Cyan - $process = Start-Process -FilePath "dotnet" ` - -ArgumentList "run -c Release --project `"$(Join-Path $ScriptDir "src/Server")`" -- $rootArgs --port $DefaultPort" ` + $process = Start-Process -FilePath $serverExe ` + -ArgumentList "$rootArgs --port $DefaultPort" ` -WorkingDirectory $ScriptDir ` -RedirectStandardOutput $LogFile ` -RedirectStandardError (Join-Path $LogDir "treemon-prod-stderr.log") `