Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
492 changes: 246 additions & 246 deletions Build/Agent/FwBuildEnvironment.psm1

Large diffs are not rendered by default.

552 changes: 276 additions & 276 deletions Build/Agent/FwBuildHelpers.psm1

Large diffs are not rendered by default.

146 changes: 73 additions & 73 deletions Build/Agent/Preprocess-WixIncludes.ps1
Original file line number Diff line number Diff line change
@@ -1,107 +1,107 @@
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$InputPath,
[Parameter(Mandatory = $true)]
[string]$InputPath,

[Parameter(Mandatory = $true)]
[string]$OutputPath,
[Parameter(Mandatory = $true)]
[string]$OutputPath,

[string]$BaseDirectory
[string]$BaseDirectory
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

function Resolve-IncludePath {
param(
[Parameter(Mandatory = $true)]
[string]$Path,
param(
[Parameter(Mandatory = $true)]
[string]$Path,

[Parameter(Mandatory = $true)]
[string]$CurrentDirectory
)
[Parameter(Mandatory = $true)]
[string]$CurrentDirectory
)

if ([System.IO.Path]::IsPathRooted($Path)) {
return $Path
}
if ([System.IO.Path]::IsPathRooted($Path)) {
return $Path
}

return [System.IO.Path]::Combine($CurrentDirectory, $Path)
return [System.IO.Path]::Combine($CurrentDirectory, $Path)
}

function Expand-File {
param(
[Parameter(Mandatory = $true)]
[string]$Path,

[Parameter(Mandatory = $true)]
[hashtable]$Vars
)

$currentDir = Split-Path -Parent $Path
if (-not (Test-Path -LiteralPath $Path)) {
throw "Input/include file not found: $Path"
}

$outLines = New-Object System.Collections.Generic.List[string]

foreach ($line in (Get-Content -LiteralPath $Path)) {
$defineMatch = [regex]::Match($line, '^\s*<\?define\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*?)\s*\?>\s*$')
if ($defineMatch.Success) {
$name = $defineMatch.Groups[1].Value
$value = $defineMatch.Groups[2].Value
$Vars[$name] = $value
continue
}

$includeMatch = [regex]::Match($line, '^\s*<\?include\s+(.+?)\s*\?>\s*$')
if ($includeMatch.Success) {
$raw = $includeMatch.Groups[1].Value.Trim()
$inc = $raw.Trim('"', "'")
$resolved = Resolve-IncludePath -Path $inc -CurrentDirectory $currentDir
$expanded = Expand-File -Path $resolved -Vars $Vars
$outLines.AddRange([string[]]$expanded)
continue
}

$expandedLine = [regex]::Replace(
$line,
'\$\(var\.([A-Za-z_][A-Za-z0-9_]*)\)',
{
param($m)
$key = $m.Groups[1].Value
if ($Vars.ContainsKey($key)) { return $Vars[$key] }
return $m.Value
}
)

$outLines.Add($expandedLine)
}

return $outLines
param(
[Parameter(Mandatory = $true)]
[string]$Path,

[Parameter(Mandatory = $true)]
[hashtable]$Vars
)

$currentDir = Split-Path -Parent $Path
if (-not (Test-Path -LiteralPath $Path)) {
throw "Input/include file not found: $Path"
}

$outLines = New-Object System.Collections.Generic.List[string]

foreach ($line in (Get-Content -LiteralPath $Path)) {
$defineMatch = [regex]::Match($line, '^\s*<\?define\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*?)\s*\?>\s*$')
if ($defineMatch.Success) {
$name = $defineMatch.Groups[1].Value
$value = $defineMatch.Groups[2].Value
$Vars[$name] = $value
continue
}

$includeMatch = [regex]::Match($line, '^\s*<\?include\s+(.+?)\s*\?>\s*$')
if ($includeMatch.Success) {
$raw = $includeMatch.Groups[1].Value.Trim()
$inc = $raw.Trim('"', "'")
$resolved = Resolve-IncludePath -Path $inc -CurrentDirectory $currentDir
$expanded = Expand-File -Path $resolved -Vars $Vars
$outLines.AddRange([string[]]$expanded)
continue
}

$expandedLine = [regex]::Replace(
$line,
'\$\(var\.([A-Za-z_][A-Za-z0-9_]*)\)',
{
param($m)
$key = $m.Groups[1].Value
if ($Vars.ContainsKey($key)) { return $Vars[$key] }
return $m.Value
}
)

$outLines.Add($expandedLine)
}

return $outLines
}

$inputFullPath = $InputPath
if (-not [System.IO.Path]::IsPathRooted($inputFullPath)) {
if ([string]::IsNullOrWhiteSpace($BaseDirectory)) {
$BaseDirectory = (Get-Location).Path
}
$inputFullPath = [System.IO.Path]::Combine($BaseDirectory, $InputPath)
if ([string]::IsNullOrWhiteSpace($BaseDirectory)) {
$BaseDirectory = (Get-Location).Path
}
$inputFullPath = [System.IO.Path]::Combine($BaseDirectory, $InputPath)
}

$outputFullPath = $OutputPath
if (-not [System.IO.Path]::IsPathRooted($outputFullPath)) {
if ([string]::IsNullOrWhiteSpace($BaseDirectory)) {
$BaseDirectory = (Get-Location).Path
}
$outputFullPath = [System.IO.Path]::Combine($BaseDirectory, $OutputPath)
if ([string]::IsNullOrWhiteSpace($BaseDirectory)) {
$BaseDirectory = (Get-Location).Path
}
$outputFullPath = [System.IO.Path]::Combine($BaseDirectory, $OutputPath)
}

$vars = @{}
$expandedLines = Expand-File -Path $inputFullPath -Vars $vars

$outDir = Split-Path -Parent $outputFullPath
if (-not (Test-Path -LiteralPath $outDir)) {
[void](New-Item -ItemType Directory -Path $outDir -Force)
[void](New-Item -ItemType Directory -Path $outDir -Force)
}

$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
Expand Down
116 changes: 58 additions & 58 deletions Build/Agent/Rebuild-TestProjects.ps1
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
<#
.SYNOPSIS
Rebuild test projects to ensure binding redirects are generated.
Rebuild test projects to ensure binding redirects are generated.

.DESCRIPTION
After changes to Directory.Build.props (like adding DependencyModel reference),
test projects need to be rebuilt to regenerate their .dll.config binding redirects.
This script identifies test projects without the required redirects and rebuilds them.
After changes to Directory.Build.props (like adding DependencyModel reference),
test projects need to be rebuilt to regenerate their .dll.config binding redirects.
This script identifies test projects without the required redirects and rebuilds them.

.PARAMETER Force
Rebuild all test projects, not just those missing binding redirects.
Rebuild all test projects, not just those missing binding redirects.

.PARAMETER DryRun
Show which projects would be rebuilt without actually rebuilding.
Show which projects would be rebuilt without actually rebuilding.

.EXAMPLE
.\Rebuild-TestProjects.ps1
Rebuilds only test projects missing binding redirects.
.\Rebuild-TestProjects.ps1
Rebuilds only test projects missing binding redirects.

.EXAMPLE
.\Rebuild-TestProjects.ps1 -Force
Rebuilds all test projects.
.\Rebuild-TestProjects.ps1 -Force
Rebuilds all test projects.

.EXAMPLE
.\Rebuild-TestProjects.ps1 -DryRun
Shows which projects need rebuilding without doing it.
.\Rebuild-TestProjects.ps1 -DryRun
Shows which projects need rebuilding without doing it.
#>
[CmdletBinding()]
param(
[switch]$Force,
[switch]$DryRun
[switch]$Force,
[switch]$DryRun
)

$ErrorActionPreference = 'Stop'

# Find repo root
$repoRoot = $PSScriptRoot
while ($repoRoot -and -not (Test-Path (Join-Path $repoRoot "FieldWorks.sln"))) {
$repoRoot = Split-Path $repoRoot -Parent
$repoRoot = Split-Path $repoRoot -Parent
}
if (-not $repoRoot) {
Write-Error "Could not find repository root (FieldWorks.sln)"
exit 1
Write-Error "Could not find repository root (FieldWorks.sln)"
exit 1
}

$outputDir = Join-Path $repoRoot "Output\Debug"
Expand All @@ -52,32 +52,32 @@ Write-Host "Checking test assemblies for binding redirects..." -ForegroundColor
$needsRebuild = @()

if ($Force) {
# Rebuild all
$testConfigs = Get-ChildItem $outputDir -Filter "*Tests.dll.config" -ErrorAction SilentlyContinue
$needsRebuild = $testConfigs | ForEach-Object { $_.Name -replace '\.dll\.config$', '' }
# Rebuild all
$testConfigs = Get-ChildItem $outputDir -Filter "*Tests.dll.config" -ErrorAction SilentlyContinue
$needsRebuild = $testConfigs | ForEach-Object { $_.Name -replace '\.dll\.config$', '' }
} else {
# Check which ones are missing DependencyModel redirect
$testConfigs = Get-ChildItem $outputDir -Filter "*Tests.dll.config" -ErrorAction SilentlyContinue
foreach ($config in $testConfigs) {
$hasRedirect = (Get-Content $config.FullName | Select-String "DependencyModel").Count -gt 0
if (-not $hasRedirect) {
$needsRebuild += $config.Name -replace '\.dll\.config$', ''
}
}
# Check which ones are missing DependencyModel redirect
$testConfigs = Get-ChildItem $outputDir -Filter "*Tests.dll.config" -ErrorAction SilentlyContinue
foreach ($config in $testConfigs) {
$hasRedirect = (Get-Content $config.FullName | Select-String "DependencyModel").Count -gt 0
if (-not $hasRedirect) {
$needsRebuild += $config.Name -replace '\.dll\.config$', ''
}
}
}

if ($needsRebuild.Count -eq 0) {
Write-Host "All test assemblies have proper binding redirects." -ForegroundColor Green
exit 0
Write-Host "All test assemblies have proper binding redirects." -ForegroundColor Green
exit 0
}

Write-Host "Found $($needsRebuild.Count) test project(s) needing rebuild:" -ForegroundColor Yellow
$needsRebuild | ForEach-Object { Write-Host " $_" -ForegroundColor Gray }

if ($DryRun) {
Write-Host ""
Write-Host "Dry run - no changes made." -ForegroundColor Cyan
exit 0
Write-Host ""
Write-Host "Dry run - no changes made." -ForegroundColor Cyan
exit 0
}

Write-Host ""
Expand All @@ -87,25 +87,25 @@ $succeeded = 0
$failed = 0

foreach ($projectName in $needsRebuild) {
$csproj = Get-ChildItem -Path $srcDir -Recurse -Filter "$projectName.csproj" | Select-Object -First 1
$csproj = Get-ChildItem -Path $srcDir -Recurse -Filter "$projectName.csproj" | Select-Object -First 1

if (-not $csproj) {
Write-Warning "Could not find $projectName.csproj"
$failed++
continue
}
if (-not $csproj) {
Write-Warning "Could not find $projectName.csproj"
$failed++
continue
}

Write-Host " Building $($csproj.Name)..." -ForegroundColor Gray -NoNewline
Write-Host " Building $($csproj.Name)..." -ForegroundColor Gray -NoNewline

$buildOutput = dotnet build $csproj.FullName -c Debug --no-incremental -v q 2>&1
$buildOutput = dotnet build $csproj.FullName -c Debug --no-incremental -v q 2>&1

if ($LASTEXITCODE -eq 0) {
Write-Host " OK" -ForegroundColor Green
$succeeded++
} else {
Write-Host " FAILED" -ForegroundColor Red
$failed++
}
if ($LASTEXITCODE -eq 0) {
Write-Host " OK" -ForegroundColor Green
$succeeded++
} else {
Write-Host " FAILED" -ForegroundColor Red
$failed++
}
}

Write-Host ""
Expand All @@ -117,20 +117,20 @@ Write-Host "Verifying binding redirects..." -ForegroundColor Cyan

$stillMissing = @()
foreach ($projectName in $needsRebuild) {
$configPath = Join-Path $outputDir "$projectName.dll.config"
if (Test-Path $configPath) {
$hasRedirect = (Get-Content $configPath | Select-String "DependencyModel").Count -gt 0
if (-not $hasRedirect) {
$stillMissing += $projectName
}
}
$configPath = Join-Path $outputDir "$projectName.dll.config"
if (Test-Path $configPath) {
$hasRedirect = (Get-Content $configPath | Select-String "DependencyModel").Count -gt 0
if (-not $hasRedirect) {
$stillMissing += $projectName
}
}
}

if ($stillMissing.Count -gt 0) {
Write-Warning "Still missing binding redirects: $($stillMissing -join ', ')"
exit 1
Write-Warning "Still missing binding redirects: $($stillMissing -join ', ')"
exit 1
} else {
Write-Host "All rebuilt projects now have proper binding redirects." -ForegroundColor Green
Write-Host "All rebuilt projects now have proper binding redirects." -ForegroundColor Green
}

exit 0
Loading
Loading