microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
379 stars 243 forks source link

Issue with copying add-ins to container #1761

Closed gntpet closed 3 years ago

gntpet commented 3 years ago

Hey @freddydk, Did something change recently in a way we are handling Addins folder? I suddenly have my build failings on: C:\Run\SetupAddIns.ps1: line 13

For some reason it tries to copy Addins for multiple times (my guestimate), and it fails.

Scripts used to create container and cause the issue


$additionalParameters = @("--volume ""$($addInsFolder):c:\run\Add-ins""")

    if ($containerExist) {
        Start-BcContainer -containerName $containerName
    } 
    else {
        New-BcContainer -containerName $containerName `
            -accept_eula `
            -accept_outdated `
            -artifactUrl (Get-BCArtifactUrl -type OnPrem -country 'w1' -version $setttings.platformBuildVersion) `
            -auth NavUserPassword `
            -Credential $Credential `
            -databaseName $dbName `
            -databaseServer $dbServer  `
            -doNotExportObjectsToText `
            -doNotCheckHealth `
            -databaseCredential $databaseCredential `
            -licenseFile $licenseFilePath `
            -locale "nl-NL" `
            -additionalParameters $additionalParameters 
    }

Full output of scripts

2021-03-02T11:09:08.2760373Z ##[section]Starting: CreateBldContainer
2021-03-02T11:09:08.2855333Z ==============================================================================
2021-03-02T11:09:08.2855630Z Task         : PowerShell
2021-03-02T11:09:08.2855891Z Description  : Run a PowerShell script on Linux, macOS, or Windows
2021-03-02T11:09:08.2856177Z Version      : 2.180.1
2021-03-02T11:09:08.2856389Z Author       : Microsoft Corporation
2021-03-02T11:09:08.2856696Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2021-03-02T11:09:08.2857041Z ==============================================================================
2021-03-02T11:09:08.9547678Z Generating script.
2021-03-02T11:09:08.9845725Z ========================== Starting Command Output ===========================
2021-03-02T11:09:09.0043348Z ##[command]"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\agent\_work\_temp\661edbb7-4491-4b72-a244-ed8753922509.ps1'"
2021-03-02T11:09:09.3449867Z WARNING: The names of some imported commands from the module 'imvcicd' include unapproved verbs that might make them 
2021-03-02T11:09:09.3450626Z less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose 
2021-03-02T11:09:09.3451096Z parameter. For a list of approved verbs, type Get-Verb.
2021-03-02T11:09:09.5485857Z BcContainerHelper version 2.0.6
2021-03-02T11:09:13.5572209Z BcContainerHelper is version 2.0.6
2021-03-02T11:09:13.5578039Z BcContainerHelper is running as ***istrator
2021-03-02T11:09:13.5596089Z Host is Microsoft Windows Server 2019 Datacenter - ltsc2019
2021-03-02T11:09:13.6974762Z Docker Client Version is 19.03.4
2021-03-02T11:09:13.6993221Z Docker Server Version is 19.03.4
2021-03-02T11:09:14.0482684Z Fetching all docker images
2021-03-02T11:09:14.3459224Z Fetching all docker volumes
2021-03-02T11:09:14.7238331Z Using image mcr.microsoft.com/businesscentral:10.0.17763.1757
2021-03-02T11:09:14.8544906Z Disabling Health Check (always report healthy)
2021-03-02T11:09:14.8732158Z Creating Container bld-release123
2021-03-02T11:09:14.8738233Z Version: 14.18.45015.0-w1
2021-03-02T11:09:14.8743465Z Style: onprem
2021-03-02T11:09:14.8749413Z Multitenant: No
2021-03-02T11:09:14.8754945Z Platform: 14.0.45012.0
2021-03-02T11:09:14.8761052Z Generic Tag: 1.0.1.3
2021-03-02T11:09:14.8791902Z Container OS Version: 10.0.17763.1757 (ltsc2019)
2021-03-02T11:09:14.8797827Z Host OS Version: 10.0.17763.1757 (ltsc2019)
2021-03-02T11:09:14.8831310Z Using process isolation
2021-03-02T11:09:14.8837147Z Using locale nl-NL
2021-03-02T11:09:14.8851006Z Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
2021-03-02T11:09:14.8896354Z Using license file C:\agent\_work\482\mylicense\fin.flf
2021-03-02T11:09:14.9059302Z Additional Parameters:
2021-03-02T11:09:14.9079008Z --volume "C:\agent\_work\482\code\DLLs:c:\run\Add-ins"
2021-03-02T11:09:14.9084296Z Files in C:\ProgramData\BcContainerHelper\Extensions\bld-release123\my:
2021-03-02T11:09:14.9114048Z - AdditionalOutput.ps1
2021-03-02T11:09:14.9119986Z - license.flf
2021-03-02T11:09:14.9125499Z - MainLoop.ps1
2021-03-02T11:09:14.9131354Z - SetupVariables.ps1
2021-03-02T11:09:14.9137039Z - updatecontainerhosts.ps1
2021-03-02T11:09:14.9142551Z Creating container bld-release123 from image mcr.microsoft.com/businesscentral:10.0.17763.1757
2021-03-02T11:09:14.9380764Z Using Shared Encryption Key file
2021-03-02T11:09:15.1391528Z c1d0ab9cb89d37d0f15906756cb140676e2e9a0adb252e59817f6320ac8023e7
2021-03-02T11:09:16.5669410Z Waiting for container bld-release123 to be ready
2021-03-02T11:09:18.8549132Z Using artifactUrl https://bcartifacts.azureedge.net/onprem/14.18.45015.0/w1
2021-03-02T11:09:18.8549853Z Using installer from C:\Run\130
2021-03-02T11:09:23.4079277Z Copying Platform Artifacts
2021-03-02T11:09:23.4079665Z Copying Application Artifacts
2021-03-02T11:09:23.4079913Z Installing Business Central
2021-03-02T11:09:27.9663809Z Installing Url Rewrite
2021-03-02T11:09:29.1092040Z Installing OpenXML
2021-03-02T11:09:32.5273952Z Installing DotNetCore
2021-03-02T11:09:35.9522399Z Starting Local SQL Server
2021-03-02T11:09:35.9522850Z Starting Internet Information Server
2021-03-02T11:09:37.0889241Z Copying Service Tier Files
2021-03-02T11:09:37.0889629Z Copying Web Client Files
2021-03-02T11:09:38.2282877Z Copying Windows Client Files
2021-03-02T11:09:38.2283259Z Copying PowerShell Scripts
2021-03-02T11:09:38.2283447Z Copying ConfigurationPackages
2021-03-02T11:09:38.2283647Z Copying Test Assemblies
2021-03-02T11:09:38.2283829Z Copying TestToolKit
2021-03-02T11:09:38.2284931Z Copying UpgradeToolKit
2021-03-02T11:09:38.2285194Z Copying Extensions
2021-03-02T11:09:39.3680467Z Copying ClientUserSettings
2021-03-02T11:09:58.0579645Z Copying ReportBuilder
2021-03-02T11:09:58.0580151Z Skipping restore of Cronus database
2021-03-02T11:09:58.0580416Z Modifying Business Central Service Tier Config File for Docker
2021-03-02T11:09:58.0580714Z Creating Business Central Service Tier
2021-03-02T11:09:58.0580996Z Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
2021-03-02T11:09:58.0581255Z Installation took 35 seconds
2021-03-02T11:09:58.0581447Z Installation complete
2021-03-02T11:09:59.1989428Z Initializing...
2021-03-02T11:09:59.1989799Z Setting host.containerhelper.internal to 172.21.80.1 in container hosts file
2021-03-02T11:09:59.1990110Z Starting Container
2021-03-02T11:09:59.1990298Z Hostname is bld-release123
2021-03-02T11:09:59.1990505Z PublicDnsName is bld-release123
2021-03-02T11:09:59.1990722Z Using NavUserPassword Authentication
2021-03-02T11:10:00.3362435Z Import Encryption Key
2021-03-02T11:10:02.6153436Z Stopping local SQL Server
2021-03-02T11:10:03.7592590Z Creating Self Signed Certificate
2021-03-02T11:10:03.7593130Z Self Signed Certificate Thumbprint 9213C91FA2BBBB03542DDB2343D50667F62A9E35
2021-03-02T11:10:04.9120625Z Modifying Service Tier Config File with Instance Specific Settings
2021-03-02T11:10:04.9121208Z An item with the specified name C:\Program Files (x86)\Microsoft Dynamics NAV\140\RoleTailored Client\Add-ins\FTP already exists.
2021-03-02T11:10:04.9121645Z at <ScriptBlock>, C:\Run\SetupAddIns.ps1: line 13
2021-03-02T11:10:04.9121925Z at <ScriptBlock>, C:\Run\navstart.ps1: line 147
2021-03-02T11:10:04.9122206Z at <ScriptBlock>, C:\Run\start.ps1: line 359
2021-03-02T11:10:04.9127042Z at <ScriptBlock>, <No file>: line 1Error
2021-03-02T11:10:04.9131421Z Using artifactUrl https://bcartifacts.azureedge.net/onprem/14.18.45015.0/w1
2021-03-02T11:10:04.9131875Z Using installer from C:\Run\130
2021-03-02T11:10:04.9132213Z Copying Platform Artifacts
2021-03-02T11:10:04.9132499Z Copying Application Artifacts
2021-03-02T11:10:04.9132786Z Installing Business Central
2021-03-02T11:10:04.9133098Z Installing Url Rewrite
2021-03-02T11:10:04.9133349Z Installing OpenXML
2021-03-02T11:10:04.9133610Z Installing DotNetCore
2021-03-02T11:10:04.9133955Z Starting Local SQL Server
2021-03-02T11:10:04.9134232Z Starting Internet Information Server
2021-03-02T11:10:04.9134457Z Copying Service Tier Files
2021-03-02T11:10:04.9134766Z Copying Web Client Files
2021-03-02T11:10:04.9135052Z Copying Windows Client Files
2021-03-02T11:10:04.9135341Z Copying PowerShell Scripts
2021-03-02T11:10:04.9135555Z Copying ConfigurationPackages
2021-03-02T11:10:04.9135823Z Copying Test Assemblies
2021-03-02T11:10:04.9136005Z Copying TestToolKit
2021-03-02T11:10:04.9136183Z Copying UpgradeToolKit
2021-03-02T11:10:04.9136348Z Copying Extensions
2021-03-02T11:10:04.9136527Z Copying ClientUserSettings
2021-03-02T11:10:04.9136715Z Copying ReportBuilder
2021-03-02T11:10:04.9136913Z Skipping restore of Cronus database
2021-03-02T11:10:04.9137158Z Modifying Business Central Service Tier Config File for Docker
2021-03-02T11:10:04.9137428Z Creating Business Central Service Tier
2021-03-02T11:10:04.9137707Z Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
2021-03-02T11:10:04.9138700Z Installation took 35 seconds
2021-03-02T11:10:04.9138880Z Installation complete
2021-03-02T11:10:04.9139052Z Initializing...
2021-03-02T11:10:04.9139302Z Setting host.containerhelper.internal to 172.21.80.1 in container hosts file
2021-03-02T11:10:04.9139546Z Starting Container
2021-03-02T11:10:04.9139720Z Hostname is bld-release123
2021-03-02T11:10:04.9139922Z PublicDnsName is bld-release123
2021-03-02T11:10:04.9140139Z Using NavUserPassword Authentication
2021-03-02T11:10:04.9140340Z Import Encryption Key
2021-03-02T11:10:04.9140508Z Stopping local SQL Server
2021-03-02T11:10:04.9140706Z Creating Self Signed Certificate
2021-03-02T11:10:04.9140974Z Self Signed Certificate Thumbprint 9213C91FA2BBBB03542DDB2343D50667F62A9E35
2021-03-02T11:10:04.9141285Z Modifying Service Tier Config File with Instance Specific Settings
2021-03-02T11:10:04.9141785Z An item with the specified name C:\Program Files (x86)\Microsoft Dynamics NAV\140\RoleTailored Client\Add-ins\FTP already exists.
2021-03-02T11:10:04.9142164Z at <ScriptBlock>, C:\Run\SetupAddIns.ps1: line 13
2021-03-02T11:10:04.9142452Z at <ScriptBlock>, C:\Run\navstart.ps1: line 147
2021-03-02T11:10:04.9142731Z at <ScriptBlock>, C:\Run\start.ps1: line 359
2021-03-02T11:10:04.9142986Z at <ScriptBlock>, <No file>: line 1
2021-03-02T11:10:04.9624064Z Initialization of container bld-release123 failed
2021-03-02T11:10:04.9624721Z At C:\Program Files\WindowsPowerShell\Modules\bccontainerhelper\2.0.6\ContainerHandling\Wait-NavContainerReady.ps1:43 c
2021-03-02T11:10:04.9625064Z har:17
2021-03-02T11:10:04.9625313Z + ...             throw "Initialization of container $containerName failed" ...
2021-03-02T11:10:04.9625634Z +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-03-02T11:10:04.9626025Z     + CategoryInfo          : OperationStopped: (Initialization ...lease123 failed:String) [], RuntimeException
2021-03-02T11:10:04.9626462Z     + FullyQualifiedErrorId : Initialization of container bld-release123 failed
2021-03-02T11:10:04.9626706Z  
2021-03-02T11:10:05.0455432Z ##[error]PowerShell exited with code '1'.
2021-03-02T11:10:05.0737615Z ##[section]Finishing: CreateBldContainer

Screenshots addins folder within container looks like this:

image

image

image

As you can see, all addins folder are succesfully copied from C:\Run\add-ins to Service & RTC folders

gntpet commented 3 years ago

It was my fault. I copied the same Addins on Bcartifacsts.cache folder manually while testing. When new container is created it's copying artifacts from those folders, so here we get double files.