Refactor run-aspire scripts for improved cross-platform support. Replace run-aspire.cmd with run-aspire.ps1 for Windows and add run-aspire.sh for Ubuntu. Update documentation to reflect these changes and ensure synchronization between build rules across scripts. Enhance Tailscale integration and clarify usage instructions.
This commit is contained in:
+4
-123
@@ -1,127 +1,8 @@
|
||||
@echo off
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
rem Starts the whole app: game server, Vite client and the Aspire dashboard.
|
||||
rem Skips MSBuild when AppHost and Server dlls are newer than C# / csproj / props.
|
||||
rem run-aspire.cmd --launch-profile http
|
||||
rem run-aspire.cmd --rebuild
|
||||
rem run-aspire.cmd --no-tailscale skip `tailscale serve --bg 5173`
|
||||
|
||||
rem Trampoline for Explorer double-click and muscle memory. The launcher is run-aspire.ps1.
|
||||
cd /d "%~dp0"
|
||||
|
||||
where dotnet >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [run-aspire] dotnet SDK not found in PATH.
|
||||
echo Install .NET 10: https://dotnet.microsoft.com/download
|
||||
call :maybe_pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
where node >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [run-aspire] Node.js not found in PATH - the client resource will fail to start.
|
||||
echo Install Node 22.12 or newer: https://nodejs.org
|
||||
echo.
|
||||
)
|
||||
|
||||
set "CONFIG=Debug"
|
||||
set "REBUILD=0"
|
||||
set "TAILSCALE_SERVE=1"
|
||||
set "ARGS="
|
||||
|
||||
:parse
|
||||
if "%~1"=="" goto parsed
|
||||
if /I "%~1"=="--rebuild" (
|
||||
set "REBUILD=1"
|
||||
shift
|
||||
goto parse
|
||||
)
|
||||
if /I "%~1"=="--no-tailscale" (
|
||||
set "TAILSCALE_SERVE=0"
|
||||
shift
|
||||
goto parse
|
||||
)
|
||||
if /I "%~1"=="-c" if not "%~2"=="" set "CONFIG=%~2"
|
||||
if /I "%~1"=="--configuration" if not "%~2"=="" set "CONFIG=%~2"
|
||||
set "ARGS=!ARGS! %1"
|
||||
shift
|
||||
goto parse
|
||||
|
||||
:parsed
|
||||
|
||||
if "%REBUILD%"=="1" (
|
||||
echo [run-aspire] --rebuild: building.
|
||||
goto build
|
||||
)
|
||||
|
||||
where powershell >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [run-aspire] PowerShell not found, building.
|
||||
goto build
|
||||
)
|
||||
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0tools\apphost-uptodate.ps1" -RepoRoot "%CD%" -Configuration "%CONFIG%"
|
||||
if errorlevel 1 (
|
||||
echo [run-aspire] sources changed or binaries missing, building.
|
||||
goto build
|
||||
)
|
||||
|
||||
echo [run-aspire] binaries are up to date, skipping build.
|
||||
goto run
|
||||
|
||||
:build
|
||||
echo.
|
||||
dotnet build "src\HSchool.AppHost\HSchool.AppHost.csproj" -c "%CONFIG%"
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo [run-aspire] build failed.
|
||||
call :maybe_pause
|
||||
exit /b 1
|
||||
)
|
||||
echo.
|
||||
|
||||
:run
|
||||
if "%TAILSCALE_SERVE%"=="1" (
|
||||
where tailscale >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [run-aspire] WARNING: tailscale not found in PATH.
|
||||
echo Friends cannot reach the client over the tailnet.
|
||||
echo Continuing with local access only ^(http://localhost:5173^).
|
||||
) else (
|
||||
tailscale status >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [run-aspire] WARNING: tailscale is not connected or not running.
|
||||
echo Friends cannot reach the client over the tailnet.
|
||||
echo Continuing with local access only ^(http://localhost:5173^).
|
||||
) else (
|
||||
echo [run-aspire] tailscale serve --bg 5173
|
||||
tailscale serve --bg 5173
|
||||
if errorlevel 1 (
|
||||
echo [run-aspire] WARNING: tailscale serve failed.
|
||||
echo Friends cannot reach the client over the tailnet.
|
||||
echo Continuing with local access only ^(http://localhost:5173^).
|
||||
)
|
||||
)
|
||||
)
|
||||
echo.
|
||||
)
|
||||
|
||||
echo [run-aspire] Starting the Aspire AppHost. Press Ctrl+C to shut everything down.
|
||||
echo.
|
||||
|
||||
dotnet run --project "src\HSchool.AppHost\HSchool.AppHost.csproj" --no-build --no-restore !ARGS!
|
||||
set "EXITCODE=!ERRORLEVEL!"
|
||||
|
||||
if not "!EXITCODE!"=="0" (
|
||||
echo.
|
||||
echo [run-aspire] AppHost exited with code !EXITCODE!.
|
||||
)
|
||||
|
||||
call :maybe_pause
|
||||
exit /b !EXITCODE!
|
||||
|
||||
rem Keeps the window open when the file was double-clicked from Explorer.
|
||||
:maybe_pause
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0run-aspire.ps1" %*
|
||||
set "EXITCODE=%ERRORLEVEL%"
|
||||
echo %cmdcmdline% | find /i "%~nx0" >nul
|
||||
if not errorlevel 1 pause
|
||||
exit /b 0
|
||||
exit /b %EXITCODE%
|
||||
|
||||
Reference in New Issue
Block a user