Files
h-school/tools/apphost-uptodate.ps1
T
Leonid PershinandCursor 9bd1b8eea0 Skip MSBuild on run-aspire.cmd when binaries are still newer than sources.
dotnet run always evaluates the Aspire graph. A second launch after Ctrl+C should not wait on that.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-20 08:45:44 +03:00

81 lines
2.0 KiB
PowerShell

# Same rules as tests/HSchool.AppHost.Tests/LaunchBuildStamp.cs. Keep the two in sync.
# Exit 0: AppHost and Server dlls are newer than inputs. Exit 1: need a build.
param(
[Parameter(Mandatory = $true)]
[string] $RepoRoot,
[string] $Configuration = "Debug"
)
$ErrorActionPreference = "Stop"
$tfm = "net10.0"
$outputs = @(
Join-Path $RepoRoot "src\HSchool.AppHost\bin\$Configuration\$tfm\HSchool.AppHost.dll"
Join-Path $RepoRoot "src\HSchool.Server\bin\$Configuration\$tfm\HSchool.Server.dll"
)
foreach ($dll in $outputs) {
if (-not (Test-Path -LiteralPath $dll)) {
exit 1
}
}
$oldest = $null
foreach ($dll in $outputs) {
$written = (Get-Item -LiteralPath $dll).LastWriteTimeUtc
if ($null -eq $oldest -or $written -lt $oldest) {
$oldest = $written
}
}
$named = @(
"global.json"
"Directory.Build.props"
"Directory.Packages.props"
)
foreach ($name in $named) {
$path = Join-Path $RepoRoot $name
if ((Test-Path -LiteralPath $path) -and (Get-Item -LiteralPath $path).LastWriteTimeUtc -gt $oldest) {
exit 1
}
}
$src = Join-Path $RepoRoot "src"
if (-not (Test-Path -LiteralPath $src)) {
exit 1
}
$extensions = @{
".cs" = $true
".csproj" = $true
".props" = $true
}
$skip = @{
"bin" = $true
"obj" = $true
"node_modules" = $true
}
$stack = New-Object System.Collections.Stack
$stack.Push($src)
while ($stack.Count -gt 0) {
$dir = [string]$stack.Pop()
foreach ($child in [System.IO.Directory]::EnumerateDirectories($dir)) {
$leaf = Split-Path -Path $child -Leaf
if ($skip.ContainsKey($leaf.ToLowerInvariant())) {
continue
}
$stack.Push($child)
}
foreach ($file in [System.IO.Directory]::EnumerateFiles($dir)) {
$ext = [System.IO.Path]::GetExtension($file).ToLowerInvariant()
if (-not $extensions.ContainsKey($ext)) {
continue
}
if ((Get-Item -LiteralPath $file).LastWriteTimeUtc -gt $oldest) {
exit 1
}
}
}
exit 0