I've added a step to migrate our database to our dev server in Octopus Deploy. I trying to create a powershell script to do this. In the Nuget package for this deployment, my executable migrate.exe
is in \Resources\
.
I've written the script like this:
$dbServer = $OctopusParameters["DBServer"]
$dbUser = $OctopusParameters["DBUser"]
$dbPass = $OctopusParameters["DBPass"]
Write-Host ("Running migration " + $dbServer)
$CMD = ".\Resources\migrate.exe"
$arg1 = '--assembly "Database\bin\Debug\Database.dll" --provider sqlserver2014'
$arg2 = '--connection "data source=$dbServer;initial catalog=MyDB;user id=$dbUser;password=$dbPass;persist security info=true;MultipleActiveResultSets=True" -o'
& $CMD $arg1 $arg2
Write-host("Migration finished " + $dbServer)
But I get this message:
& : The term '.\Resources\migrate.exe --assembly "Database\bin\Debug\Database.dll" --provider sqlserver2014 --connection "data source=$dbServer;initial catalog=ClarkChains;user id=$dbUser;password=$dbPass;persist security info=true;MultipleActiveResultSets=True" -o' is not recognized as the name of a cmdlet, function, script file, or operable program.
I was looking around for examples on how to correctly call an executable.
Write-Host (Get-Location).Path
- will tell you where you are in the octopus deployment target machine. - Alex M