# MRCC Launcher 构建脚本 # 用法: .\build.ps1 [-Run] param( [switch]$Run ) $ErrorActionPreference = "Stop" # 设置 .NET SDK 环境变量(本地安装的 SDK) $DotnetRoot = "D:\Code\MRCC\.dotnet" $env:DOTNET_ROOT = $DotnetRoot $env:DOTNET_MULTILEVEL_LOOKUP = "0" $env:APPDATA = "D:\Code\MRCC\.userdata\AppData\Roaming" $env:LOCALAPPDATA = "D:\Code\MRCC\.userdata\AppData\Local" $env:NUGET_PACKAGES = "D:\Code\MRCC\.nuget\packages" $env:NUGET_HTTP_CACHE_PATH = "D:\Code\MRCC\.nuget\v3-cache" $env:DOTNET_CLI_TELEMETRY_OPTOUT = "1" $DotnetExe = Join-Path $DotnetRoot "dotnet.exe" $SolutionPath = Join-Path $PSScriptRoot "MRCC.Launcher.sln" Write-Host "Building MRCC.Launcher..." -ForegroundColor Cyan & $DotnetExe build $SolutionPath if ($LASTEXITCODE -ne 0) { Write-Host "Build failed!" -ForegroundColor Red exit 1 } Write-Host "Build succeeded!" -ForegroundColor Green if ($Run) { Write-Host "Launching MRCC.Launcher..." -ForegroundColor Cyan $exePath = Join-Path $PSScriptRoot "MRCC.Launcher\bin\Debug\net10.0-windows\MRCC.Launcher.exe" if (Test-Path $exePath) { & $exePath } else { Write-Host "Executable not found: $exePath" -ForegroundColor Red Write-Host "Try building with Release configuration." -ForegroundColor Yellow } }