Repository navigation
Expand file tree
/
Copy pathTest-BuildScripts.ps1
More file actions
53 lines (51 loc) · 3.05 KB
/
Copy pathTest-BuildScripts.ps1
File metadata and controls
53 lines (51 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
$ErrorActionPreference = "Stop"
$testRoot = [IO.Path]::Combine($PSScriptRoot, 'bin', 'script-tests')
$caller = Join-Path $testRoot 'caller'
New-Item -ItemType Directory -Force -Path $caller | Out-Null
[IO.File]::WriteAllText((Join-Path $caller 'global.json'),
'{"sdk":{"version":"99.0.100","rollForward":"disable","allowPrerelease":false}}')
[xml] $project = Get-Content ([IO.Path]::Combine($PSScriptRoot, 'Guan', 'Guan.csproj')) -Raw
$packageId = $project.Project.PropertyGroup.PackageId
$version = $project.Project.PropertyGroup.Version
if (!$packageId -or !$version) { throw "Guan package identity is missing." }
$dotnet = (Get-Command dotnet -CommandType Application | Select-Object -First 1).Source
$probe = Start-Process $dotnet -ArgumentList '--version' -WorkingDirectory $caller -Wait -PassThru `
-RedirectStandardOutput (Join-Path $testRoot 'caller-sdk.stdout.log') `
-RedirectStandardError (Join-Path $testRoot 'caller-sdk.stderr.log')
if ($probe.ExitCode -eq 0) { throw "The conflicting caller SDK pin did not reject SDK selection." }
Push-Location $caller
try {
$location = (Get-Location).ProviderPath
foreach ($configuration in @("Release", "Debug")) {
& (Join-Path $PSScriptRoot 'Build-Guan.ps1') -Configuration $configuration
if ((Get-Location).ProviderPath -ne $location) { throw "Publishing did not restore the caller's directory." }
& (Join-Path $PSScriptRoot 'Build-NugetPackage.ps1') -Configuration $configuration
if ((Get-Location).ProviderPath -ne $location) { throw "Packaging did not restore the caller's directory." }
$outputRoot = [IO.Path]::Combine($PSScriptRoot, 'bin', $configuration.ToLowerInvariant())
$assembly = [IO.Path]::Combine($outputRoot, 'netstandard2.0', 'Guan.dll')
$package = [IO.Path]::Combine($outputRoot, 'Guan', 'Nugets', "$packageId.$version.nupkg")
if (!(Test-Path -LiteralPath $assembly) -or !(Test-Path -LiteralPath $package)) {
throw "$configuration artifacts are missing from the configuration-specific output."
}
if ($configuration -eq "Release") {
$releaseAssembly = $assembly
$releasePackage = $package
$assemblyHash = (Get-FileHash -LiteralPath $assembly).Hash
$packageHash = (Get-FileHash -LiteralPath $package).Hash
$assemblyTime = (Get-Item -LiteralPath $assembly).LastWriteTimeUtc
$packageTime = (Get-Item -LiteralPath $package).LastWriteTimeUtc
}
else {
if ((Get-FileHash -LiteralPath $releaseAssembly).Hash -ne $assemblyHash -or
(Get-FileHash -LiteralPath $releasePackage).Hash -ne $packageHash -or
(Get-Item -LiteralPath $releaseAssembly).LastWriteTimeUtc -ne $assemblyTime -or
(Get-Item -LiteralPath $releasePackage).LastWriteTimeUtc -ne $packageTime) {
throw "Debug build scripts modified Release artifacts."
}
}
Write-Host "PASS $configuration publish/pack: repository SDK, isolated output, caller directory restored."
}
}
finally {
Pop-Location
}