HodorNV / ALOps

ALOps
59 stars 24 forks source link

ALOpsAppLicenseCheck fails now in FLF-Files #625

Closed DanielGoehler closed 1 year ago

DanielGoehler commented 1 year ago

Describe the bug ALOpsAppLicenseCheck with FLF-Files fails now because it uses BC22 DLLs and produces the error message:

An error occurred while reading the license file. Verify the license file is in the correct BCLicense file format and try again. Error Code: Unknown error.

the yaml

- task: ALOpsAppLicenseCheck@1
  inputs:
    licensefile: '$(Build.SourcesDirectory)\CustomerLicence.flf'
    artifact_filter: '*.app'

output last week

##[section]Starting: ALOpsAppLicenseCheck
==============================================================================
Task         : ALOps App License Check
Description  : Check App files agains a license
Version      : 1.455.3577
Author       : Hodor
Help         : Check App files agains a license.
==============================================================================
*** Validate configuration
*** Task Inputs:

name                                                value
----                                                -----
usedocker                                           False
fixed_tag                                                
licensefile      C:\agent\_work\663\s\CustomerLicence.flf
artifact_path                        C:\agent\_work\663\a
artifact_filter                                     *.app
artifact_include                                         
artifact_exclude                              
exclude_ranges                                           

*** For documentation, please visit   : https://www.alops.be/documentation

*** Imported required PS-Functions
*** Parse Task Parameters
*** Load Management DLL's
*** Import NAV/BC Management DLL's [True]
*** ServiceTier not specified, loading default assemblies.
*** Default Assemblies not found. Load via BC-Artifacts
*** Install/Update BCContainerHelper [https://github.com/microsoft/navcontainerhelper]
*** Check BcContainerHelper
*** Load BcContainerHelper
BcContainerHelper version 4.0.14
BC.HelperFunctions emits usage statistics telemetry to Microsoft

ModuleType Version    Name                                ExportedCommands                                             
---------- -------    ----                                ----------------                                             
Script     4.0.14     BcContainerHelper                   {Add-FontsToBcContainer, Add-GitToAlProjectFolder, AddTele...

##[command]"Get-BCArtifactUrl" 
Name                           Value                                                                                   
----                           -----                                                                                   
select                         Latest                                                                                  
type                           OnPrem                                                                                  
country                        W1                                                                                      

 -select: Latest -type: OnPrem -country: W1
*** Platform: C:\bcartifacts.cache\onprem\21.5.53619.53819\platform
*** Localisation: C:\bcartifacts.cache\onprem\21.5.53619.53819\w1
*** BC NCL Management DLL: C:\bcartifacts.cache\onprem\21.5.53619.53819\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Ncl.dll
*** BC Types DLL: C:\bcartifacts.cache\onprem\21.5.53619.53819\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Types.dll
*** Selected module: [C:\bcartifacts.cache\onprem\21.5.53619.53819\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Types.dll]
*** Loading module: [C:\bcartifacts.cache\onprem\21.5.53619.53819\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Types.dll]
*** BC Management DLL: C:\bcartifacts.cache\onprem\21.5.53619.53819\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Management.dll
*** Selected module: [C:\bcartifacts.cache\onprem\21.5.53619.53819\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Management.dll]
*** Loading module: [C:\bcartifacts.cache\onprem\21.5.53619.53819\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Management.dll]
*** BC App Management DLL: C:\bcartifacts.cache\onprem\21.5.53619.53819\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Apps.Management.dll
*** Selected module: [C:\bcartifacts.cache\onprem\21.5.53619.53819\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Apps.Management.dll]
*** Loading module: [C:\bcartifacts.cache\onprem\21.5.53619.53819\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Apps.Management.dll]
*** Load CodeAnalysis from [C:\bcartifacts.cache\onprem\21.5.53619.53819\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service]
*** Loading assemblies from: [C:\bcartifacts.cache\onprem\21.5.53619.53819\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service]
*** Loading: [C:\bcartifacts.cache\onprem\21.5.53619.53819\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.CodeAnalysis.dll]
*** Import BCLicenseReader
*** Get License: [C:\agent\_work\663\s\CustomerLicence.flf]
*** App License Check: [C:\agent\_work\663\a]
*** Resolved Path  : C:\agent\_work\663\a
*** Apps to process:

Name                                                                            
----
Company_Customer-BaseApp_19.4.0.27783.app                             

*** Detect license format
*** Parsing Format: FLF
*** Setup NAV-License Delegate
*** Using 'Microsoft.Dynamics.Nav.Types.ObjectType' signature
*** Load License
*** License Header
Microsoft Software License Information
Copyright (C) 2007-2018 Microsoft Corporation. All rights reserved
****************************************************************************
***Sanitized***
****************************************************************************

*** Checking License against App: Company_Customer-BaseApp_19.4.0.27783.app
  * All Objects are Licensed [252]

*** Cleanup VSTS Environment: True
##[section]Finishing: ALOpsAppLicenseCheck

output today

##[section]Starting: ALOpsAppLicenseCheck
==============================================================================
Task         : ALOps App License Check
Description  : Check App files agains a license
Version      : 1.455.3577
Author       : Hodor
Help         : Check App files agains a license.
==============================================================================
*** Validate configuration
*** Task Inputs:

name                                                value
----                                                -----
usedocker                                           False
fixed_tag                                                
licensefile      C:\agent\_work\507\s\CustomerLicence.flf
artifact_path                        C:\agent\_work\507\a
artifact_filter                                     *.app
artifact_include                                         
artifact_exclude                              
exclude_ranges                                           

*** For documentation, please visit   : https://www.alops.be/documentation

*** Imported required PS-Functions
*** Parse Task Parameters
*** Load Management DLL's
*** Import NAV/BC Management DLL's [True]
*** ServiceTier not specified, loading default assemblies.
*** Default Assemblies not found. Load via BC-Artifacts
*** Install/Update BCContainerHelper [https://github.com/microsoft/navcontainerhelper]
*** Check BcContainerHelper
*** Load BcContainerHelper
BcContainerHelper version 4.0.14
BC.HelperFunctions emits usage statistics telemetry to Microsoft

ModuleType Version    Name                                ExportedCommands                                             
---------- -------    ----                                ----------------                                             
Script     4.0.14     BcContainerHelper                   {Add-FontsToBcContainer, Add-GitToAlProjectFolder, AddTele...

##[command]"Get-BCArtifactUrl" 
Name                           Value                                                                                   
----                           -----                                                                                   
select                         Latest                                                                                  
type                           OnPrem                                                                                  
country                        W1                                                                                      

 -select: Latest -type: OnPrem -country: W1
Downloading application artifact /onprem/22.0.54157.54635/w1
https://bcartifacts.azureedge.net/onprem/22.0.54157.54635/w1
Downloading C:\Users\script-service\AppData\Local\Temp\d469aff3-4a63-4e62-b80f-cb73601bf870.zip
Using WebClient
Unpacking application artifact to tmp folder using Expand-Archive
Downloading platform artifact /onprem/22.0.54157.54635/platform
https://bcartifacts.azureedge.net/onprem/22.0.54157.54635/platform
Downloading C:\Users\script-service\AppData\Local\Temp\88013b50-1a5e-4e5a-91bd-dba7454efc96.zip
Using WebClient
Unpacking platform artifact to tmp folder using Expand-Archive
Downloading Prerequisite Components
Downloading C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\Prerequisite Components\DotNetCore\DotNetCore.1.0.4_1.1.1-WindowsHosting.exe
Using WebClient
Downloading C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\Prerequisite Components\IIS URL Rewrite Module\rewrite_2.0_rtw_x64.msi
Using WebClient
*** Platform: C:\bcartifacts.cache\onprem\22.0.54157.54635\platform
*** Localisation: C:\bcartifacts.cache\onprem\22.0.54157.54635\w1
*** BC NCL Management DLL: C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\ServiceTier\program files\Microsoft Dynamics NAV\220\Service\Management\Microsoft.Dynamics.Nav.Ncl.dll
*** BC Types DLL: C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\ServiceTier\program files\Microsoft Dynamics NAV\220\Service\Management\Microsoft.Dynamics.Nav.Types.dll
*** Selected module: [C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\ServiceTier\program files\Microsoft Dynamics NAV\220\Service\Management\Microsoft.Dynamics.Nav.Types.dll]
*** Loading module: [C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\ServiceTier\program files\Microsoft Dynamics NAV\220\Service\Management\Microsoft.Dynamics.Nav.Types.dll]
*** BC Management DLL: C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\ServiceTier\program files\Microsoft Dynamics NAV\220\Service\Management\Microsoft.Dynamics.Nav.Management.dll
*** Selected module: [C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\ServiceTier\program files\Microsoft Dynamics NAV\220\Service\Management\Microsoft.Dynamics.Nav.Management.dll]
*** Loading module: [C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\ServiceTier\program files\Microsoft Dynamics NAV\220\Service\Management\Microsoft.Dynamics.Nav.Management.dll]
*** BC App Management DLL: C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\ServiceTier\program files\Microsoft Dynamics NAV\220\Service\Management\Microsoft.Dynamics.Nav.Apps.Management.dll
*** Selected module: [C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\ServiceTier\program files\Microsoft Dynamics NAV\220\Service\Management\Microsoft.Dynamics.Nav.Apps.Management.dll]
*** Loading module: [C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\ServiceTier\program files\Microsoft Dynamics NAV\220\Service\Management\Microsoft.Dynamics.Nav.Apps.Management.dll]
*** Load CodeAnalysis from [C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\ServiceTier\program files\Microsoft Dynamics NAV\220\Service\Management]
*** Loading assemblies from: [C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\ServiceTier\program files\Microsoft Dynamics NAV\220\Service\Management]
*** Loading: [C:\bcartifacts.cache\onprem\22.0.54157.54635\platform\ServiceTier\program files\Microsoft Dynamics NAV\220\Service\Management\Microsoft.Dynamics.Nav.CodeAnalysis.dll]
*** Import BCLicenseReader
*** Get License: [C:\agent\_work\507\s\CustomerLicence.flf]
*** App License Check: [C:\agent\_work\507\a]
*** Resolved Path  : C:\agent\_work\507\a
*** Apps to process:

Name                                                                            
----                                                                                              
Company_Customer-BaseApp_19.4.0.28090.app                             

*** Detect license format
*** Parsing Format: FLF
*** Setup NAV-License Delegate
*** Using 'Microsoft.Dynamics.Nav.Types.ObjectType' signature
*** Load License
##[error]Ausnahme beim Aufrufen von "Invoke" mit 2 Argument(en):  "An error occurred while reading the license file. Verify the license file is in the correct BCLicense file format and try again. Error Code: Unknown error."
##[section]Finishing: ALOpsAppLicenseCheck
AdminHodor commented 1 year ago

Dear @DanielGoehler,

BC v22 does not support FLF files anymore, from BC v22 only the BCLICENSE files work. The new DLLs of BC do not include any functionality for FLF files.

Kind regards,

DanielGoehler commented 1 year ago

@AdminHodor Yes, I know. The pipeline creates a BC14 container. How can I tell ALOpsAppLicenseCheck to use the BC21 artefacts as before?

AdminHodor commented 1 year ago

Dear @DanielGoehler ,

I you are already working with containers, you could change the "ALOpsAppLicenseCheck" step so it used the Docker-Container with parameter [usedocker = True]. The LicenseCheck will first try to load existing DLL's on the server (or container), if not found it will download the latest available. Running the check inside the container could solve this issue, as it would the DLLs available for that version.

The downside of this is that de ALOpsAppLicenseCheck can only be run after the DockerWait step and before DockerRemove.

Another solution that could work, is that we provide some parameters for specifying which version of BC should be downloaded if DLLs are not found instead of the latest version. Seems like a small change, so if this would work for you we'll try to hotfix this asap.

Kind regards,

DanielGoehler commented 1 year ago

@AdminHodor If usedocker = true worked, that would be enough for me, but it doesn't at the moment. I get the error message

Could not find a part of the path 'C:\agent_work\1\s\CustomerLicence.flf'.

the yaml

- task: ALOpsAppLicenseCheck@1
  inputs:
    usedocker: true
    licensefile: '$(Build.SourcesDirectory)\CustomerLicence.flf'
    artifact_filter: '*.app'

the output

##[section]Starting: ALOpsAppLicenseCheck
==============================================================================
Task         : ALOps App License Check
Description  : Check App files agains a license
Version      : 1.455.3577
Author       : Hodor
Help         : Check App files agains a license.
==============================================================================
*** Validate configuration
*** Task Inputs:

name                                              value
----                                              -----
usedocker                                          True
fixed_tag                                              
licensefile      C:\agent\_work\1\s\CustomerLicence.flf
artifact_path                        C:\agent\_work\1\a
artifact_filter                                   *.app
artifact_include                                       
artifact_exclude                                       
exclude_ranges                                         

*** For documentation, please visit   : https://www.alops.be/documentation

*** Imported required PS-Functions
*** Parse Task Parameters
*** Initiate Docker Session
*** Set Docker Container ErrorActionPreference = Stop
*** Load Management DLL's
*** Import NAV/BC Management DLL's [True]
*** ServiceTier not specified, loading default assemblies.
*** BC NCL Management DLL: C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Ncl.dll
*** BC Types DLL: C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Types.dll
*** Selected module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Types.dll]
*** Loading module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Types.dll]
*** Load module [Microsoft.Dynamics.Nav.Management]
*** Selected module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Management.dll]
*** Loading module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Management.dll]
*** Load module [Microsoft.Dynamics.Nav.Apps.Management]
*** Selected module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Apps.Management.dll]
*** Loading module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Apps.Management.dll]
*** Load CodeAnalysis from [C:\Program Files\Microsoft Dynamics NAV\140\Service]
*** Loading assemblies from: [C:\Program Files\Microsoft Dynamics NAV\140\Service]
*** Loading: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.CodeAnalysis.dll]

*** Import BCLicenseReader
*** Get License: [C:\agent\_work\1\s\CustomerLicence.flf]
##[error]Could not find a part of the path 'C:\agent\_work\1\s\CustomerLicence.flf'.
##[section]Finishing: ALOpsAppLicenseCheck
AdminHodor commented 1 year ago

Dear @DanielGoehler,

We made a small change that should solve this, could you please try v1.455.3598?

Kind regards

DanielGoehler commented 1 year ago

@AdminHodor Thanks. Now I get a different error message:

*** File not found: [C:\agent_work\1\s\CustomerLicence.flf]

the output

##[section]Starting: ALOpsAppLicenseCheck
==============================================================================
Task         : ALOps App License Check
Description  : Check App files agains a license
Version      : 1.455.3598
Author       : Hodor
Help         : Check App files agains a license.
==============================================================================
*** Validate configuration
*** Task Inputs:

name                                              value
----                                              -----
usedocker                                          True
fixed_tag                                              
licensefile      C:\agent\_work\1\s\CustomerLicence.flf
artifact_path                        C:\agent\_work\1\a
artifact_filter                                   *.app
artifact_include                                       
artifact_exclude                                       
exclude_ranges                                         

*** For documentation, please visit   : https://www.alops.be/documentation

*** Imported required PS-Functions
*** Parse Task Parameters
*** Initiate Docker Session
*** Set Docker Container ErrorActionPreference = Stop
*** Load Management DLL's
*** Import NAV/BC Management DLL's [True]
*** ServiceTier not specified, loading default assemblies.
*** BC NCL Management DLL: C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Ncl.dll
*** BC Types DLL: C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Types.dll
*** Selected module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Types.dll]
*** Loading module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Types.dll]
*** Load module [Microsoft.Dynamics.Nav.Management]
*** Selected module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Management.dll]
*** Loading module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Management.dll]
*** Load module [Microsoft.Dynamics.Nav.Apps.Management]
*** Selected module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Apps.Management.dll]
*** Loading module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Apps.Management.dll]
*** Load CodeAnalysis from [C:\Program Files\Microsoft Dynamics NAV\140\Service]
*** Loading assemblies from: [C:\Program Files\Microsoft Dynamics NAV\140\Service]
*** Loading: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.CodeAnalysis.dll]

*** Import BCLicenseReader
*** Get License: [C:\agent\_work\1\s\CustomerLicence.flf]
*** Read License from disk: [C:\agent\_work\1\s\CustomerLicence.flf]
##[error]*** File not found: [C:\agent\_work\1\s\CustomerLicence.flf]
##[section]Finishing: ALOpsAppLicenseCheck
DanielGoehler commented 1 year ago

I try again with the yaml

- task: ALOpsAppLicenseCheck@1
  inputs:
    usedocker: true
    licensefile: 'CustomerLicence.flf'
    artifact_filter: '*.app'

I hope this works. It takes ~15 Minutes and I will get back to you.

DanielGoehler commented 1 year ago

I also get the error message:

*** File not found: [CustomerLicence.flf]

the output

##[section]Starting: ALOpsAppLicenseCheck
==============================================================================
Task         : ALOps App License Check
Description  : Check App files agains a license
Version      : 1.455.3598
Author       : Hodor
Help         : Check App files agains a license.
==============================================================================
*** Validate configuration
*** Task Inputs:

name                           value
----                           -----
usedocker                       True
fixed_tag                           
licensefile      CustomerLicence.flf
artifact_path     C:\agent\_work\1\a
artifact_filter                *.app
artifact_include                    
artifact_exclude                    
exclude_ranges                      

*** For documentation, please visit   : https://www.alops.be/documentation

*** ALOps License:
  * Licensed To: prisma informatik GmbH (Organisation License)

*** Imported required PS-Functions
*** Parse Task Parameters
*** Initiate Docker Session
*** Set Docker Container ErrorActionPreference = Stop
*** Load Management DLL's
*** Import NAV/BC Management DLL's [True]
*** ServiceTier not specified, loading default assemblies.
*** BC NCL Management DLL: C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Ncl.dll
*** BC Types DLL: C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Types.dll
*** Selected module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Types.dll]
*** Loading module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Types.dll]
*** Load module [Microsoft.Dynamics.Nav.Management]
*** Selected module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Management.dll]
*** Loading module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Management.dll]
*** Load module [Microsoft.Dynamics.Nav.Apps.Management]
*** Selected module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Apps.Management.dll]
*** Loading module: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.Apps.Management.dll]
*** Load CodeAnalysis from [C:\Program Files\Microsoft Dynamics NAV\140\Service]
*** Loading assemblies from: [C:\Program Files\Microsoft Dynamics NAV\140\Service]
*** Loading: [C:\Program Files\Microsoft Dynamics NAV\140\Service\Microsoft.Dynamics.Nav.CodeAnalysis.dll]

*** Import BCLicenseReader
*** Get License: [CustomerLicence.flf]
*** Read License from disk: [CustomerLicence.flf]
##[error]*** File not found: [CustomerLicence.flf]
##[section]Finishing: ALOpsAppLicenseCheck
AdminHodor commented 1 year ago

Dear @DanielGoehler ,

Where is the FLF actually located? Is in the repository, of do you download it during the pipeline. Please note you can also specify an Url for the license parameter, for example a SAS-Blob Url from Azure storage.

If you download/place the license in Workingfolder during the pipeline, please note you have to this BEFORE the DockerStart/DockerWait step. Its the DockerWait step that copies the working folder into the container. If the license is added after the DockerWait it will not be available.

We recommend using Azure Storage Url for the licenses, but local storage should work fine.

We'll keep a close eye on this issue so we can get this resolved quickly.

Kind regards,

DanielGoehler commented 1 year ago

@AdminHodor The license is part of the repo. Import it into the docker works fine. Only the LicenseCheck didn't work.

AdminHodor commented 1 year ago

Dear @DanielGoehler ,

Found something, hopefully this is it. We just released a new hotfix v1.455.3600. Please note it could take couple of pipeline runs before the version is picked up. We found a possible bug whem using local paths instead of Urls.

Kind regards,

DanielGoehler commented 1 year ago

@AdminHodor Now it works. Thank you very much.