[Windows] Change mongodb installation from choco to .msi download (#8032)

This commit is contained in:
sergei-pyshnoi
2023-08-09 14:28:33 +02:00
committed by GitHub
parent 4780184e3d
commit ba97109526
3 changed files with 21 additions and 4 deletions

View File

@@ -5,8 +5,25 @@
# Install mongodb package
$toolsetVersion = (Get-ToolsetContent).mongodb.version
$latestChocoPackage = Get-LatestChocoPackageVersion -TargetVersion $toolsetVersion -PackageName "mongodb"
Choco-Install -PackageName mongodb -ArgumentList "--version=$latestChocoPackage"
$getMongoReleases = Invoke-WebRequest -Uri "https://www.mongodb.com/docs/upcoming/release-notes/$toolsetVersion" -UseBasicParsing
$TargetReleases = $getMongoReleases.Links.href | Where-Object {$_ -like "*std-label-$toolsetVersion*"}
$MinorVersions = @()
foreach ($release in $TargetReleases) {
$pattern = '\d+\.\d+\.\d+'
$version = $release | Select-String -Pattern $pattern -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }
$MinorVersions += $version
}
$LatestVersion = $MinorVersions[0]
$installDir = "c:\PROGRA~1\MongoDB"
$binaryName = "mongodb-windows-x86_64-$LatestVersion-signed.msi"
$downloadURL = "https://fastdl.mongodb.org/windows/$BinaryName"
$installArg = "INSTALLLOCATION=$installDir ADDLOCAL=all"
Install-Binary -Url $downloadURL -Name $binaryName -ArgumentList ("/q","/i","${env:Temp}\$binaryName", $installArg)
# Add mongodb to the PATH
$mongodbService = "mongodb"