DbUpMigration - Reflection issue during power shell script execution. New in 1.3.0
Redno-Pnomis opened this issue · 13 comments
Thanks for reporting this. Are you running on a hosted build agent or on a private VM?
I cannot reproduce this, but for your convenience I rolled back the task to the previous version. Hopefully version 1.3.1 will work for you again!
Private VM and the rollback did fix this.
I haven't had the time to isolate which library it was looking for and having an issue finding. Thank you for the quick response, I was actually in the process of finding the location on the app server it executes the task on, to do replace the dbup core to use the last version.
I have released the task using DbUp version 4.* again, but this time i increased the mayor version of the Azure DevOps task so that your pipelines will not get affected as they were last time.
If or when you upgrade to the 2.* version you will likely experience the same reflection issue as before. Please contact me through this issue if you do! Hopefully we can sort this out together then.
I currently am having this issue:
2019-04-17T07:54:56.1512215Z ##[error]System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
2019-04-17T07:54:56.1520333Z at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
2019-04-17T07:54:56.1520463Z at System.Reflection.Assembly.GetTypes()
2019-04-17T07:54:56.1520565Z at Microsoft.PowerShell.Commands.AddTypeCommand.LoadAssemblyFromPathOrName(List`1 generatedTypes)
2019-04-17T07:54:56.1520636Z at Microsoft.PowerShell.Commands.AddTypeCommand.EndProcessing()
2019-04-17T07:54:56.1520872Z at System.Management.Automation.CommandProcessorBase.Complete()
Running on Private VM
Do you need more information?
Thanks for reporting this!
- Can you try to delete the folder %LOCALAPPDATA%\DatabaseMigration?
- Which version of the task do your build agent use?
- What is the output of the following powershell command:
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\' | Get-ItemPropertyValue -Name Release
Can you try to delete the folder %LOCALAPPDATA%\DatabaseMigration?
- Cannot find the folder. Tried the admin account on the server, the build user and my local user.
Which version of the task do your build agent use?
- 2.* is the task version i use. Did you want this?
What is the output of the following powershell command: Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' | Get-ItemPropertyValue -Name Release
- 394271
A workaround for you is to downgrade to the version 1.*.
Hm... .NET Framework 4.6.1 and no old DbUp dlls in AppData\Local\DatabaseMigration. What PowerShell version is installed?
What does executing $PSVersionTable
in a PowerShell prompt give you?
Name Value
PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I have now tried to run the task on both an old Windows Server 2016 that I use for development and on a newly provisioned Windows Server 2016, both hosted in Azure, without any problems.
Would you be so kind as to run the following PowerShell? It tries to load the dlls in the same order as the task does it.
$taskPath = 'C:\agent\_work\_tasks\UpdateDatabaseWithDbUp_4182dbda-71db-4d18-89b3-75255b7802eb\2.1.0'
function Get-ResolvedPaths {
param($rootDir)
$patterns = @()
$patterns += 'dbup-core*\lib\net35\*.dll'
$patterns += 'dbup-sqlserver*\lib\net35\*.dll'
$patterns += 'System.Data.SqlClient.*\lib\netstandard1.3\*.dll'
$patterns | ForEach-Object { Resolve-Path (Join-Path $rootDir $_) -ErrorAction SilentlyContinue } | Select-Object -ExpandProperty Path
}
try {
$Error.Clear()
Push-Location $taskPath
Write-Host "Trying to load..."
Get-ResolvedPaths lib | Foreach {
Write-Host " - $_"
Add-Type -Path $_
}
}
catch {
Write-Host -ForegroundColor yellow "LoadException"
$Error | Format-List -Force
Write-Host -foreground red $Error[0].Exception.LoaderExceptions;
}
Write-Host "Complete."
Pop-Location
Please update the $taskPath
to point to the correct folder on your machine.
Sorry for taking so long. I did not get a notification and forgot about it.
Got the result here: https://gist.github.com/jorismathijssen/c72c7e6fbb1bbbadbfc8e8feec6ea805
Nice. Thank you so much!
I have just published a new version (2.1.1) to the marketplace which I think will fix your problem. Please let me know if it does!