58 lines
1.6 KiB
PowerShell
58 lines
1.6 KiB
PowerShell
#Requires -Version 5.0
|
|
$ErrorActionPreference = "Stop"
|
|
$root = $PSScriptRoot
|
|
Set-Location $root
|
|
|
|
$exe = $null
|
|
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
|
|
$exe = "dotnet"
|
|
} else {
|
|
foreach ($c in @(
|
|
"$env:ProgramFiles\dotnet\dotnet.exe",
|
|
"${env:ProgramFiles(x86)}\dotnet\dotnet.exe"
|
|
)) {
|
|
if (Test-Path $c) {
|
|
$exe = $c
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
if (-not $exe) {
|
|
Write-Error "dotnet SDK not found. Install .NET 8 SDK: https://dotnet.microsoft.com/download"
|
|
}
|
|
|
|
function Invoke-Dotnet {
|
|
if ($exe -eq "dotnet") {
|
|
dotnet @args
|
|
} else {
|
|
& $exe @args
|
|
}
|
|
}
|
|
|
|
Write-Host ">> dotnet restore"
|
|
Invoke-Dotnet restore "$root\ChromeboxFanControl.sln"
|
|
|
|
Write-Host ">> dotnet build Release"
|
|
Invoke-Dotnet build "$root\ChromeboxFanControl.sln" -c Release --no-restore
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
|
|
$doPublish = $args -contains "-publish" -or $args -contains "--publish"
|
|
if ($doPublish) {
|
|
$out = Join-Path $root "dist"
|
|
if (Test-Path $out) { Remove-Item $out -Recurse -Force }
|
|
New-Item -ItemType Directory -Path $out | Out-Null
|
|
Write-Host ">> dotnet publish -> $out"
|
|
Invoke-Dotnet publish "$root\ChromeboxFanControl\ChromeboxFanControl.csproj" `
|
|
-c Release `
|
|
-o $out `
|
|
-r win-x64 `
|
|
--self-contained false `
|
|
-p:PublishSingleFile=false `
|
|
--no-restore
|
|
Write-Host "Done: $out\ChromeboxFanControl.exe"
|
|
} else {
|
|
Write-Host "Done: $root\ChromeboxFanControl\bin\Release\net8.0-windows\ChromeboxFanControl.exe"
|
|
Write-Host "(Run .\build.ps1 -publish to output to dist\)"
|
|
}
|