d365collaborative / d365fo.tools

Tools used for Dynamics 365 Finance and Operations
MIT License
236 stars 97 forks source link

D365LcsApiToken' command was found in the module 'd365fo.tools', but the module could not be loaded #823

Closed TomH31Git closed 1 month ago

TomH31Git commented 1 month ago

Hi, Since this morning, i have an issue with my DevOps pipelines.

d365fo.tools uses ImportExcel as a dependency. That module released a new version yesterday.

A friendly community member found this solution. You have to add those commands in your script :

Install-Module ImportExcel -Scope CurrentUser -Force -AllowClobber -Verbose -RequiredVersion 7.8.6

Import-Module ImportExcel -Verbose -RequiredVersion 7.8.6

Install-Module d365fo.tools -Scope CurrentUser -Force -AllowClobber -Verbose

If you then call a d365fo.tools cmdlet in a different task then where it was installed, you need to import the ImportExcel module with version 7.8.6 again before the first cmdlet call.

onikolaiev commented 1 month ago

Hi Everyone, Tonight I faced with the below in my pipelines, image It seems like the issue is related to this topic. CC: @Splaxi @FH-Inway

FH-Inway commented 1 month ago

@TomH31Git Thanks for reporting and including the information and workaround I posted in https://www.yammer.com/dynamicsaxfeedbackprograms/#/Threads/show?threadId=2795043495944192

@onikolaiev Also thanks to you for reporting. Yes, that is most likely the same issue. For searchability, the error message from the screenshot is

Import-Module : Could not load file or assembly 'file:///C:\Users\VssAdministrator\Documents\WindowsPowerShell\Modules\ImportExcel\7.8.7\EPPlus.dll' or one of its dependencies. The system cannot find the file specified.

If no explicit Import-Module is being done, the error can also manifest as follows during the first call to a d365fo.tools cmdlet:

Get-D365LcsApiToken : The 'Get-D365LcsApiToken' command was found in the module 'd365fo.tools', but the module could not be loaded. For more information, run 'Import-Module d365fo.tools'.

As was already mentioned, the reason is the ImportExcel dependency of d365fo.tools, which released a defect new version yesterday. See also https://github.com/dfinke/ImportExcel/issues/1597

Hopefully, @dfinke can release a fixed version soon. Fixing ImportExcel to a MaximumVersion could also be a way to resolve this. That would be added in https://github.com/d365collaborative/d365fo.tools/blob/078ad3857183698bc3a8365c0b61ab788af1b0bf/d365fo.tools/d365fo.tools.psd1#L26-L36

FH-Inway commented 1 month ago

New version of ImportExcel has been published, which resolves this issue.