microsoft / navcontainerhelper

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

Error running running Run-TestsInBCContainer for OnPrem BC21.0 #2740

Closed JakobAaen closed 1 year ago

JakobAaen commented 1 year ago

Describe the issue Getting an error when running tests through the powershell script "Run-TestsInBCContainer" on Docker OnPrem BC21.0 DK.

Tests runs fine in the browser.

Scripts used to create container and cause the issue

$additionalParameters = @("--volume ""${AgentPath}:C:\Source""")  
New-BCContainer @parameters `
                       -containerName $containerName `
                       -artifactUrl $artifact `
                       -accept_eula `
                       -accept_outdated `
                       -auth Windows `
                       -Credential $credential `
                       -shortcuts "None" `
                       -updateHosts `
                       -licenseFile $licenseFile `
                       -additionalParameters $additionalParameters `
                       -includetesttoolkit

Full output of scripts

BcContainerHelper version 4.0.5
Setting containerHelperFolder = C:\BcContainerHelper
Setting usePsSession = True
Setting use7zipIfAvailable = True
Setting psSessionTimeout = 0
Setting useSharedEncryptionKeys = True
Setting mapCountryCode = @{ae=w1; br=w1; bd=w1; co=w1; dz=w1; ee=w1; eg=w1; fo=dk; gl=dk; gr=w1; hk=w1; hr=w1; hu=w1; id=w1; ie=w1; jp=w1; ke=w1; kr=w1; lb=w1; lk=w1; lt=w1; lu=w1; lv=w1; ma=w1; mm=w1; mt=w1; my=w1; ng=w1; pe=w1; ph=w1; pl=w1; qa=w1; rs=w1; ro=w1
; sa=w1; sg=w1; si=w1; th=w1; tn=w1; tw=w1; vn=w1; za=w1}
Setting defaultNewContainerParameters = 
Setting digestAlgorithm = SHA256
Setting TraefikUseDnsNameAsHostName = False
Setting hostHelperFolder = E:\BcContainerHelper
Setting bcartifactsCacheFolder = E:\Artifacts.cache
Setting genericImageNameFilesOnly = mcr.microsoft.com/businesscentral:{0}-filesonly
Setting genericImageName = mcr.microsoft.com/businesscentral:{0}
Setting timeStampServer = http://timestamp.digicert.com
Setting TreatWarningsAsErrors = AL1026
Setting defaultContainerName = bcserver
Setting sandboxContainersAreMultitenantByDefault = True
BcContainerHelper emits usage statistics telemetry to Microsoft
c:\Users\ContainerAdministrator\AppData\Local\Temp\ssbzkjpx\ssbzkjpx.0.cs(1) : The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffc
d2ddd51'.

c:\Users\ContainerAdministrator\AppData\Local\Temp\ssbzkjpx\ssbzkjpx.0.cs(1) : >>> public class MyOpenFormInteraction : Microsoft.Dynamics.Framework.UI.Client.Interactions.OpenFormInteraction

c:\Users\ContainerAdministrator\AppData\Local\Temp\ssbzkjpx\ssbzkjpx.0.cs(2) : {

Exception Script Stack Trace:
at <ScriptBlock>, C:\BcContainerHelper\Extensions\onprem210dk\PsTestTool\ClientContext.ps1: line 22
at <ScriptBlock>, C:\BcContainerHelper\Extensions\onprem210dk\PsTestTool\PsTestFunctions.ps1: line 17
at <ScriptBlock>, <No file>: line 46

PowerShell Call Stack:
at Invoke-ScriptInBcContainer, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\4.0.5\ContainerHandling\Invoke-ScriptInNavContainer.ps1: line 71
at Run-TestsInBcContainer, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\4.0.5\AppHandling\Run-TestsInNavContainer.ps1: line 360
at <ScriptBlock>, <No file>: line 14

Container Free Physical Memory: 21.2Gb

Services in container onprem210dk:
- MicrosoftDynamicsNavServer$BC is Running
- MSSQL$SQLEXPRESS is Running

at Invoke-ScriptInBcContainer, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\4.0.5\ContainerHandling\Invoke-ScriptInNavContainer.ps1: line 112
at Run-TestsInBcContainer, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\4.0.5\AppHandling\Run-TestsInNavContainer.ps1: line 360
at <ScriptBlock>, <No file>: line 14
Run-TestsInNavContainer Telemetry Correlation Id: be2d8af9-9b75-4ce1-90e1-633a3cb003ca
c:\Users\ContainerAdministrator\AppData\Local\Temp\ssbzkjpx\ssbzkjpx.0.cs(1) : The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ff
cd2ddd51'.
c:\Users\ContainerAdministrator\AppData\Local\Temp\ssbzkjpx\ssbzkjpx.0.cs(1) : >>> public class MyOpenFormInteraction : Microsoft.Dynamics.Framework.UI.Client.Interactions.OpenFormInteraction
c:\Users\ContainerAdministrator\AppData\Local\Temp\ssbzkjpx\ssbzkjpx.0.cs(2) : {
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\4.0.5\AppHandling\Run-TestsInNavContainer.ps1:483 char:17
+                 throw $_.Exception.Message
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (c:\Users\Contai...x.0.cs(2) : {
:String) [], RuntimeException
    + FullyQualifiedErrorId : c:\Users\ContainerAdministrator\AppData\Local\Temp\ssbzkjpx\ssbzkjpx.0.cs(1) : The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=n 
   eutral, PublicKeyToken=cc7b13ffcd2ddd51'.
c:\Users\ContainerAdministrator\AppData\Local\Temp\ssbzkjpx\ssbzkjpx.0.cs(1) : >>> public class MyOpenFormInteraction : Microsoft.Dynamics.Framework.UI.Client.Interactions.OpenFormInteraction
c:\Users\ContainerAdministrator\AppData\Local\Temp\ssbzkjpx\ssbzkjpx.0.cs(2) : {
...

Additional context Used to work (and still does) with OnPrem BC20 DK Fails every time, started failing in DevOps Pipelines, also fails when running script from powershell.

freddydk commented 1 year ago

Is that the full output? What license file are you using?

JakobAaen commented 1 year ago

I have been using a BC20 license, as I have been trying to get the BC21 developer license for a while, but it is not available to us at the moment. I had a small feeling, that it could be the solution the problem.

freddydk commented 1 year ago

I am pretty sure that this is the problem. Firstly because 21 contains some test objects, which is not in the 20 license Secondly due to the Universal Code Initiative

JakobAaen commented 1 year ago

Great. I'll wait for the BC 21 developer license then.

spookymattress commented 1 year ago

@JakobAaen what was the solution to this issue? We are having the same issue, but importing and using a BC 21 license has not solved the problem for us.

JakobAaen commented 1 year ago

I believe we changed the user and password of the user created in the container to accomodate the password rules of Business Central. We changed it to a real user on the server, yet still using NavUserPassword. This written from memory.