ps/Modules/Alkami.PowerShell.Database/Public/Get-MigrationRunnerExe.ps1
2023-05-30 22:51:22 -07:00

46 lines
2.2 KiB
PowerShell

function Get-MigrationRunnerExe {
<#
.SYNOPSIS
Returns path to the appropriate MigrationRunner utility for the Runtime provided
.PARAMETER Runtime
Runtime or framework of the package that the MigrationRunner will be running Migrations for
.OUTPUTS
Returns the Path to the appropriate MigrationRunner utility
#>
[CmdletBinding()]
[OutputType([string])]
Param (
[Parameter(Mandatory = $true)]
[ValidateSet("framework","dotnetcore")]
[string]$Runtime
)
# SRE-16977 - This is overkill on Write-Hosts and safety valves.
# Leave them in until all the moving parts of the new Migration pipeline are in.
$loglead = Get-LogLeadName
Write-Host "$loglead : running on $($env:COMPUTERNAME) by $($env:USERNAME) started at $(Get-Date)"
if ((Test-StringIsNullOrEmpty (Get-EnvironmentVariable -StoreName Process -Name "sre_migrationUtility_tool")) -eq $true) {
$migrationUtilityParentPath = "C:\ProgramData\Alkami\SRE\MigrationUtility"
} else {
$migrationUtilityParentPath = Join-Path -Path (Get-EnvironmentVariable -StoreName Process -Name "sre_migrationUtility_tool") -ChildPath "dist"
}
$migrationRunnerExePath = ""
$NETFX_MIGRATIONRUNNER_PATH = Join-Path -Path $migrationUtilityParentPath -ChildPath "\Framework\Alkami.TeamCity.MigrationRunnerFramework.exe"
$DOTNETCORE_MIGRATIONRUNNER_PATH = Join-Path -Path $migrationUtilityParentPath -ChildPath "\Core\Alkami.TeamCity.MigrationRunnerCore.exe"
switch ($Runtime) {
"framework" { $migrationRunnerExePath = $NETFX_MIGRATIONRUNNER_PATH }
"dotnetcore" { $migrationRunnerExePath = $DOTNETCORE_MIGRATIONRUNNER_PATH }
default { throw "$loglead : Could not find an appropriate MigrationRunner utility" }
}
if (-not (Test-Path -Path $migrationRunnerExePath)) {
throw "$loglead : Runtime $Runtime Migration Runner path not found at $migrationRunnerPath. Please install Alkami.SRE.MigrationUtility in the target environment."
}
Write-Host "$loglead : For Runtime $Runtime, the following MigrationRunner was found"
Write-Host "$loglead : $migrationRunnerExePath"
Write-Host "$loglead : finished at $(Get-Date)"
return $migrationRunnerExePath
}