Assembly error while importing PartnerCenter module in Azure DevOps - Azure Powershell task (Core)
Steps to reproduce
Azure DevOps task: steps:
- task: AzurePowerShell@5 displayName: 'Azure PowerShell script: InlineScript' inputs: azureSubscription: 'test' ScriptType: InlineScript Inline: | Install-Module -Name "PartnerCenter" -AllowClobber -Force Get-Module -ListAvailable -Name Partner Import-Module PartnerCenter -Verbose New-PartnerAccessToken azurePowerShellVersion: LatestVersion pwsh: true
Expected behavior
PartnerCenter module imported and being able to use its commands such as New-PartnerAccessToken
Actual behavior
Getting error: [error]Assembly with same name is already loaded
Diagnostic logs
tasklog_5.log 2021-01-25T17:04:11.7715333Z 2021-01-25T17:04:11.7766198Z Directory: C:\Users\VssAdministrator\Documents\PowerShell\Modules 2021-01-25T17:04:11.7767514Z 2021-01-25T17:04:11.7771296Z ModuleType Version PreRelease Name PSEdition ExportedCommands 2021-01-25T17:04:11.7775242Z ---------- ------- ---------- ---- --------- ---------------- 2021-01-25T17:04:11.7787077Z Script 3.0.10 PartnerCenter Core,Desk {Add-PartnerCustomerCartLineItem, Add-P… 2021-01-25T17:04:11.7818268Z VERBOSE: Loading module from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\PartnerCenter.psd1'. 2021-01-25T17:04:11.7927276Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Store.PartnerCenter.PowerShell.dll'. 2021-01-25T17:04:11.8107488Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Store.PartnerCenter.PowerShell.dll'. 2021-01-25T17:04:11.8167479Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Store.PartnerCenter.Azure.Billing.dll'. 2021-01-25T17:04:11.8169650Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Store.PartnerCenter.Azure.Billing.dll'. 2021-01-25T17:04:11.8269057Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Store.PartnerCenter.Azure.Subscription.dll'. 2021-01-25T17:04:11.8286972Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Store.PartnerCenter.Azure.Subscription.dll'. 2021-01-25T17:04:11.9149828Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Graph.Beta.dll'. 2021-01-25T17:04:11.9168752Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Graph.Beta.dll'. 2021-01-25T17:04:11.9229726Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Graph.Core.dll'. 2021-01-25T17:04:11.9253816Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Graph.Core.dll'. 2021-01-25T17:04:11.9363924Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Extensions.Caching.Abstractions.dll'. 2021-01-25T17:04:11.9389552Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Extensions.Caching.Abstractions.dll'. 2021-01-25T17:04:11.9446638Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Extensions.Caching.Memory.dll'. 2021-01-25T17:04:11.9537161Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Extensions.Caching.Memory.dll'. 2021-01-25T17:04:11.9578644Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Extensions.DependencyInjection.Abstractions.dll'. 2021-01-25T17:04:11.9595762Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Extensions.DependencyInjection.Abstractions.dll'. 2021-01-25T17:04:11.9738852Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Extensions.Options.dll'. 2021-01-25T17:04:11.9784487Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Extensions.Options.dll'. 2021-01-25T17:04:11.9941093Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Extensions.Primitives.dll'. 2021-01-25T17:04:11.9943043Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Extensions.Primitives.dll'. 2021-01-25T17:04:12.0142442Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Identity.Client.dll'. 2021-01-25T17:04:12.0174848Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Identity.Client.dll'. 2021-01-25T17:04:12.0364676Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Identity.Client.Extensions.Msal.dll'. 2021-01-25T17:04:12.0389063Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Identity.Client.Extensions.Msal.dll'. 2021-01-25T17:04:12.0434104Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.IdentityModel.JsonWebTokens.dll'. 2021-01-25T17:04:12.0541493Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.IdentityModel.JsonWebTokens.dll'. 2021-01-25T17:04:12.0692086Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.IdentityModel.Logging.dll'. 2021-01-25T17:04:12.0706316Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.IdentityModel.Logging.dll'. 2021-01-25T17:04:12.0738732Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.IdentityModel.Tokens.dll'. 2021-01-25T17:04:12.0758597Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.IdentityModel.Tokens.dll'. 2021-01-25T17:04:12.0949059Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Rest.ClientRuntime.dll'. 2021-01-25T17:04:12.0970746Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Rest.ClientRuntime.dll'. 2021-01-25T17:04:12.1184729Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Store.PartnerCenter.dll'. 2021-01-25T17:04:12.1201289Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Store.PartnerCenter.dll'. 2021-01-25T17:04:12.1318182Z VERBOSE: Loading 'Assembly' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\System.Runtime.CompilerServices.Unsafe.dll'. 2021-01-25T17:04:12.1363985Z VERBOSE: Loading 'Executable' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\System.Runtime.CompilerServices.Unsafe.dll'. 2021-01-25T17:04:12.1380115Z VERBOSE: Loading 'FormatsToProcess' from path 'C:\Users\VssAdministrator\Documents\PowerShell\Modules\PartnerCenter\3.0.9\Microsoft.Store.PartnerCenter.PowerShell.format.ps1xml'. 2021-01-25T17:04:12.4824161Z ##[error]Assembly with same name is already loaded
Environment
Agent pools used:
- Azure Pipelines: windows-2019
- Azure Pipelines: ubuntu-20.04
I got a similar experience on my machine:
Get-InstalledModule PartnerCenter, Az.Accounts | Select Name, Version
Name Version
---- -------
PartnerCenter 3.0.10
Az.Accounts 2.2.4
(latest version of both packages as of today)
PS >Login-AzAccount
Account SubscriptionName TenantId Environment
------- ---------------- -------- -----------
[email protected] name <guid> AzureCloud
PS > Import-Module PartnerCenter
Import-Module: Assembly with same name is already loaded
PS > Import-Module PartnerCenter
PS > Login-AzAccount
WARNING: INITIALIZATION: Fallback context save mode to process because of error during checking token cache persistence: Could not load file or assembly 'Microsoft.Identity.Client.Extensions.Msal, Version=2.16.2.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. Das System kann die angegebene Datei nicht finden..
Connect-AzAccount: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.21.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. Das System kann die angegebene Datei nicht finden.
So if a load both modules, the later loaded has some kind of dependency problem.
On the Az Module there is https://github.com/Azure/azure-powershell/issues/14004 with a similar error message.
I downgraded to Az.Accounts below 2 (1.9.5) and I am able to load both modules. A downgrade of PartnerCenter did not help.
I think it is possible that issue #335 is caused by the same underlaying Problem
I think it is possible that issue #335 is caused by the same underlaying Problem
Yes, this is the same thing. It's also been discussed in #323 and Azure/azure-powershell#13423.
Fundamentally it's an issue that needs to be resolved in the PartnerCenter module. However, the dev from Microsoft that was working on this seems to have moved on now, so it's solely relying on community support to fix this issue.
The only workarounds at the moment are to either use the modules in PowerShell 5, or downgrade the Az.Accounts module (as you mentioned) to an older version.
Thank you very much for your answers. I will downgrade the Az.Accounts module as workaround.