I’m using Deploy.ps1 to trigger entity framework’s migrate.exe to automate the database migrations.
Both deploy.ps1 and migrate.exe is being copied to BIN folder.
I always get the same error no matter what combination or formatting i do in my powershell script
& : The term ‘.\migrate.exe’ is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Octopus\Applications\Development\Imp.Web.Intranet\1.2014.117.738_1\bin\Deploy.ps1:1 char:3
- & ‘.\migrate.exe’ ‘Core.dll’ ‘/startupConfigurationFile=…\web.config’
I can successfully run the script through powershell as well as running it through tentacle.exe
Thanks in advance.
Hi Jeff,
It looks reasonable to me too… Which versions of Octopus and PowerShell are you using (and if 1.x, are you using the legacy PowerShell runner setting)?
Regards,
Nick
Hi Nick,
I’m running Octopus Deploy version 2, not sure about the powershell version but it is running on Windows server 2012
Thanks,
Jeff
Hi Jeff, it might be a problem with our management of the working directory - can you please try adding:
ls
to your Deploy.ps1 file? It might be that you need to use .\bin\migrate.exe
or a similar relative path.
Hope this helps.
Nick
I was able to resolve this issue, its basically due to Deploy.ps1 runs on the root folder instead of .\bin.
I use absolute paths instead which is a lot more predictable.
Here’s my entire powershell script:
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
Write-Output “Script Path is: $($scriptPath)”
if (test-path -Path “$($scriptPath)\migrate.exe”)
{
Write-Output “Running database migrations…”
$webConfigPath = $scriptPath.Replace("bin", "web.config")
$CMD = "$($scriptPath)\migrate.exe"
$arg1 = 'MyEntityFrameworkProj.dll'
$arg2 = "/startupConfigurationFile=$($webConfigPath)"
& $CMD $arg1 $arg2
if ($LastExitCode -ne 0) { throw 'migrate.exe returned a non-zero exit code...' }
}
else
{
throw ‘Cannot find migrate.exe from source, make sure migrate.exe is checked in’
}
Excellent, thanks for closing the loop.