johanclasson / vso-agent-tasks

Build and Release Tasks for Visual Studio Online and Team Foundation Server
MIT License
20 stars 16 forks source link

Use powershell task for dbup #45

Closed lekesako closed 5 years ago

lekesako commented 5 years ago

i have trouble to use powershell with dbup. script work in my computer but not in agent (onpremise agent).

have you ever encountered this problem?

powershell : $databaseName = $args[0] $databaseServer = $args[1] $scriptPath = $args[2]: $currentPath = $args[3]

Add-Type -Path (Join-Path -Path $currentPath -ChildPath "dbup-core.dll") Add-Type -Path (Join-Path -Path $currentPath -ChildPath "dbup-sqlserver.dll")

[System.Reflection.Assembly]::LoadFrom("$currentPath\dbup-core.dll");

[System.Reflection.Assembly]::LoadFrom("$currentPath\dbup-sqlserver.dll");

$dbUp = [DbUp.DeployChanges]::To $dbUp = [SqlServerExtensions]::SqlDatabase($dbUp, "server=$databaseServer;database=$databaseName;Trusted_Connection=Yes;Connection Timeout=120;")

2018-09-14T08:20:56.6205737Z ##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\AGENT01_work_temp\aa9a1a08-9280-4e4d-b523-dfce4bbc6b49.ps1'" 2018-09-14T08:20:56.9956534Z 2018-09-14T08:20:57.0112064Z GAC Version Location
2018-09-14T08:20:57.0112064Z --- ------- --------
2018-09-14T08:20:57.0112064Z False v4.0.30319 D:\AGENT01_work\r146\a\TMA - Run-SQL\drop\psTools\pre-release\DbUp\dll\dbup-core.dll
2018-09-14T08:20:57.0112064Z False v2.0.50727 D:\AGENT01_work\r146\a\TMA - Run-SQL\drop\psTools\pre-release\DbUp\dll\dbup-sqlserver.dll
2018-09-14T08:20:57.3393393Z ##[error]Unable to find type [DbUp.DeployChanges].

johanclasson commented 5 years ago

My best guess is that the machine where the on-premise agent is running has not got a recent .Net Framework installation. Does it work if you try with DbUp 3.3.5?

lekesako commented 5 years ago

it works.... but all framework needed are isntalled..(.net 2/3.5/4), i don't understand. it work also with postgresql ? dbup.dll ?

lekesako commented 5 years ago

perhaps i must installed .NET frameword Core ? for .net standard ?

lekesako commented 5 years ago

i have this error.

System.InvalidOperationException: Variable ENV has no value defined 2018-09-17T12:50:09.7549009Z at DbUp.Engine.Preprocessors.VariableSubstitutionPreprocessor.ReplaceToken

what i missed ?

thanks for your help..

lekesako commented 5 years ago

i found my mistake. thanks for your help

johanclasson commented 5 years ago

What did you do to make it work?

lekesako commented 5 years ago

My script has a variable to replace with #variable#, so script powershell want to replace a variable without value.