Skip to content

Commit bbd1d3f

Browse files
appveyor fixes
1 parent 37c3903 commit bbd1d3f

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cache:
1212
- C:\ProgramData\chocolatey\lib -> appveyor.yml
1313
- C:\Program Files\WindowsPowerShell\Modules\PSScriptAnalyzer -> appveyor.yml
1414
- C:\Program Files\WindowsPowerShell\Modules\Pester -> appveyor.yml
15-
- C:\Program Files\WindowsPowerShell\Modules\dbatools.library -> dbatools.psd1
15+
- C:\Program Files\WindowsPowerShell\Modules\dbatools.library -> .github/dbatools-library-version.json
1616

1717
#shallow_clone: true
1818
clone_depth: 100
@@ -78,7 +78,7 @@ before_test:
7878
# turn tests directory (at least) to CRLF, as it's faster to do this on the zipball rather than checking out the repo
7979
- cmd: pushd C:\github\dbatools\tests & unix2dos -q *.ps1 & popd
8080
# don't clown -- for some reason it's just not installing the library
81-
- ps: if (-not(Test-Path 'C:\Program Files\WindowsPowerShell\Modules\dbatools.library')) { Install-Module -Name dbatools.library -AllowPrerelease -Force | Out-Null }
81+
# dbatools.library is now installed via centralized method in appveyor.prep.ps1
8282
# grab appveyor lab files and needed requirements for tests in CI
8383
- ps: .\Tests\appveyor.prep.ps1
8484

tests/appveyor.prep.ps1

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,24 @@ if (-not(Test-Path 'C:\Program Files\WindowsPowerShell\Modules\PSScriptAnalyzer\
3030
#Get dbatools.library
3131
Write-Host -Object "appveyor.prep: Install dbatools.library" -ForegroundColor DarkGreen
3232
# Use centralized version management for dbatools.library installation
33-
& "$PSScriptRoot\..\github\scripts\install-dbatools-library.ps1" | Out-Null
33+
& "$PSScriptRoot\..\.github\scripts\install-dbatools-library.ps1"
34+
# Validate that the correct version was installed
35+
$expectedVersion = (Get-Content '.github/dbatools-library-version.json' | ConvertFrom-Json).version
36+
$installedModule = Get-Module dbatools.library -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1
37+
38+
if (-not $installedModule) {
39+
throw "dbatools.library module was not installed successfully"
40+
}
41+
42+
Write-Host -Object "appveyor.prep: Expected version: $expectedVersion" -ForegroundColor Green
43+
Write-Host -Object "appveyor.prep: Installed version: $($installedModule.Version)" -ForegroundColor Green
44+
45+
# Verify the version matches (allowing for version format differences)
46+
if ($installedModule.Version.ToString() -notmatch [regex]::Escape($expectedVersion.Split('-')[0])) {
47+
Write-Warning "Installed version $($installedModule.Version) may not match expected version $expectedVersion"
48+
} else {
49+
Write-Host -Object "appveyor.prep: Version validation successful" -ForegroundColor Green
50+
}
3451

3552
#Get Pester (to run tests) - choco isn't working onall scenarios, weird
3653
Write-Host -Object "appveyor.prep: Install Pester4" -ForegroundColor DarkGreen

0 commit comments

Comments
 (0)