Describe the issue
After running Restore-DatabasesInBCContainer, Import-TestToolkitToNavContainer generates error:
Publishing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Tests-TestLibraries.app
Extension compilation failed
LibraryHeadlines.Codeunit.al(5,79): error AL0161: 'OnTaskSchedulerUnavailable' is inaccessible due to its protect
ion level
at <ScriptBlock>, <No file>: line 15
Extension compilation failed
LibraryHeadlines.Codeunit.al(5,79): error AL0161: 'OnTaskSchedulerUnavailable' is inaccessible due to its
protection level
Au caract猫re C:\Program
Files\WindowsPowerShell\Modules\BcContainerHelper\1.0.15\ContainerHandling\Invoke-ScriptInNavContainer.ps1:39 :
13
Scripts used to create container and cause the issue
New-NavContainer -Accept_Eula -Accept_Outdated -doNotCheckHealth -containerName CAGNA170-Dev -auth UserPassword -updateHosts -includeCSide:False -memoryLimit 13G -doNotExportObjectsToText:True -enableSymbolLoading:False -includeTestToolkit:True -includeTestLibrariesOnly:True -doNotUseRuntimePackages:True -includeAL:True -assignPremiumPlan:False -isolation process -useBestContainerOS -artifactUrl https://bcartifacts.azureedge.net/onprem/17.1.18256.18792/fr -alwaysPull -licensefile "D:\Sources\DevOps\Git\D365BC CALLIOPACKS\CAGNA\Configs\NAV-DEV-License.flf" -additionalParameters @("--volume "D:\Sources\DevOps\Git\D365BC CALLIOPACKS\CAGNA:C:\Source"")```
$BakFile = "C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\my\CAGNA170-Dev SharedFolder\VM-CAGNAV3_D365BC-TEST_FULL_20201206_230019.bak"
$ContainerName = "CAGNA170-Dev"
Restore-DatabasesInBCContainer -bakFile $BakFile -containerName $ContainerName -databaseName CRONUS
Restart-NavContainer -containerName $ContainerName
Import-TestToolkitToNavContainer -containerName $ContainerName -includeTestLibrariesOnly -doNotUseRuntimePackages
Full output of scripts
Removing container CAGNA170-Dev
Removing CAGNA170-Dev from host hosts file
Removing CAGNA170-Dev-* from host hosts file
Removing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev
Creating container CAGNA170-Dev...
BcContainerHelper is version 1.0.15
BcContainerHelper is running as administrator
Host is Microsoft Windows 10 Entreprise - 2004
Docker Client Version is 19.03.13
Docker Server Version is 19.03.13
Fetching all docker images
Pulling image mcr.microsoft.com/businesscentral:10.0.19041.630
10.0.19041.630: Pulling from businesscentral
Digest: sha256:7cc9c42734bb4bab9a2c7584bc09e6cbd123ef2fe1d81df938684ff70b5686fd
Status: Image is up to date for mcr.microsoft.com/businesscentral:10.0.19041.630
mcr.microsoft.com/businesscentral:10.0.19041.630
Using image mcr.microsoft.com/businesscentral:10.0.19041.630
Disabling Health Check (always report healthy)
Creating Container CAGNA170-Dev
Version: 17.1.18256.18792-fr
Style: onprem
Multitenant: No
Platform: 17.0.18204.18738
Generic Tag: 1.0.1.0
Container OS Version: 10.0.19041.630 (2004)
Host OS Version: 10.0.19041.630 (2004)
Using process isolation
Using locale fr-FR
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Using license file D:\Sources\DevOps\Git\D365BC CALLIOPACKS\CAGNA\Configs\NAV-DEV-License.flf
Additional Parameters:
--volume "D:\Sources\DevOps\Git\D365BC CALLIOPACKS\CAGNA:C:\Source"
Files in C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\my:
- AdditionalOutput.ps1
- license.flf
- MainLoop.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container CAGNA170-Dev from image mcr.microsoft.com/businesscentral:10.0.19041.630
26e85298dbcdc302b822e9459d911642a4a5521d20bf1a7bf88636c9c1d137de
Waiting for container CAGNA170-Dev to be ready
Using artifactUrl https://bcartifacts.azureedge.net/onprem/17.1.18256.18792/fr
Using installer from C:\Run\150-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
Copying PowerShell Scripts
Copying dependencies
Copying ReportBuilder
Importing PowerShell Modules
Determining Database Collation from c:\dl\onprem\17.1.18256.18792\fr\database\Demo Database NAV (17-0).bak
Changing Database Server Collation to French_100_CI_AS
Restoring CRONUS Demo Database
Setting CompatibilityLevel for CRONUS on localhost\SQLEXPRESS
Modifying Business Central Service Tier Config File for Docker
Creating Business Central Service Tier
Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
Copying Web Client Files
Copying Client Files
Copying ModernDev Files
Copying additional files
Copying ConfigurationPackages
Copying Test Assemblies
Copying Applications
Starting Business Central Service Tier
Importing license file
Stopping Business Central Service Tier
Installation took 158 seconds
Installation complete
Initializing...
Setting host.docker.internal to 192.168.1.32 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 192.168.1.32 in container hosts file (copy from host hosts file)
Setting kubernetes.docker.internal to 127.0.0.1 in container hosts file (copy from host hosts file)
Setting host.containerhelper.internal to 172.27.0.1 in container hosts file
Starting Container
Hostname is CAGNA170-Dev
PublicDnsName is CAGNA170-Dev
Using NavUserPassword Authentication
Creating Self Signed Certificate
Self Signed Certificate Thumbprint DA805FB7F61E752F7C83E72D2B66FE42C30BBD7B
Modifying Service Tier Config File with Instance Specific Settings
Starting Service Tier
Registering event sources
Creating DotNetCore Web Server Instance
Using license file 'c:\run\my\license.flf'
Import License
Creating http download site
Setting SA Password and enabling SA
Creating sa as SQL User and add to sysadmin
Creating SUPER user
WARNING: The password that you entered does not meet the minimum requirements.
It should be at least 8 characters long and contain at least one uppercase
letter, one lowercase letter, and one number.
Container IP Address: 172.27.9.43
Container Hostname : CAGNA170-Dev
Container Dns Name : CAGNA170-Dev
Web Client : http://CAGNA170-Dev/BC/
Dev. Server : http://CAGNA170-Dev
Dev. ServerInstance : BC
Setting CAGNA170-Dev to 172.27.9.43 in host hosts file Files:
http://CAGNA170-Dev:8080/ALLanguage.vsix Container Total Physical Memory is 31.8Gb
Container Free Physical Memory is 17.3Gb Initialization took 61 seconds
Ready for connections!
Reading CustomSettings.config from CAGNA170-Dev
Creating Desktop Shortcuts for CAGNA170-Dev
Copy from container CAGNA170-Dev (C:\Applications\TestFramework\TestLibraries\Any\Microsoft_Any.app) to C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Any.app Publishing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Any.app Synchronizing Any on tenant default
Installing Any on tenant default
App successfully published
Copy from container CAGNA170-Dev (C:\Applications\TestFramework\TestLibraries\Assert\Microsoft_Library Assert.app) to C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Library Assert.app
Publishing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Library Assert.app Synchronizing Library Assert on tenant default
Installing Library Assert on tenant default
App successfully published
Copy from container CAGNA170-Dev (C:\Applications\TestFramework\TestLibraries\Variable Storage\Microsoft_Library Variable Storage.app) to C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Library Variable Storage.app Publishing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Library Variable Storage.app Synchronizing Library Variable Storage on tenant default
Installing Library Variable Storage on tenant default
App successfully published
Copy from container CAGNA170-Dev (C:\Applications\TestFramework\TestRunner\Microsoft_Test Runner.app) to C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Test Runner.app Publishing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Test Runner.app Synchronizing Test Runner on tenant default
Installing Test Runner on tenant default
App successfully published
Copy from container CAGNA170-Dev (C:\Applications\System Application\Test\Microsoft_System Application Test Library.app) to C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_System Application Test Library.app Publishing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_System Application Test Library.app Synchronizing System Application Test Library on tenant default
Installing System Application Test Library on tenant default
App successfully published
Copy from container CAGNA170-Dev (C:\Applications\BaseApp\Test\Microsoft_Tests-TestLibraries.app) to C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Tests-TestLibraries.app Publishing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Tests-TestLibraries.app Synchronizing Tests-TestLibraries on tenant default
Installing Tests-TestLibraries on tenant default
App successfully published
TestToolkit successfully imported
Creating .net Assembly Reference Folder for VS Code
Copying DLLs from C:\Windows\assembly to assemblyProbingPath
Copying DLLs from C:\Program Files\Microsoft Dynamics NAV\170\Service to assemblyProbingPath
Copying DLLs from C:\Program Files (x86)\Microsoft Dynamics NAV\170\RoleTailored Client to assemblyProbingPath Copying DLLs from C:\Test Assemblies\Mock Assemblies to assemblyProbingPath
Copying DLLs from C:\Program Files (x86)\Open XML SDK to assemblyProbingPath
Container CAGNA170-Dev successfully created Use:
Get-BcContainerEventLog -containerName CAGNA170-Dev to retrieve a snapshot of the event log from the container
Get-BcContainerDebugInfo -containerName CAGNA170-Dev to get debug information about the container
Enter-BcContainer -containerName CAGNA170-Dev to open a PowerShell prompt inside the container
Remove-BcContainer -containerName CAGNA170-Dev to remove the container again
docker logs CAGNA170-Dev to retrieve information about URL's again
Restarting container CAGNA170-Dev...
Removing Database CRONUS from localhost\SQLEXPRESS
Restoring C:\Run\my\CAGNA170-Dev SharedFolder\VM-CAGNAV3_D365BC-TEST_FULL_20201206_230019.bak to CRONUS
CAGNA170-Dev
Waiting for container CAGNA170-Dev to be ready
Initializing...
Setting host.docker.internal to 192.168.1.32 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 192.168.1.32 in container hosts file (copy from host hosts file)
Setting kubernetes.docker.internal to 127.0.0.1 in container hosts file (copy from host hosts file)
Setting host.containerhelper.internal to 172.27.0.1 in container hosts file
Restarting Container
PublicDnsName unchanged
Hostname is CAGNA170-Dev
PublicDnsName is CAGNA170-Dev
Using NavUserPassword Authentication
Starting Local SQL Server
Starting Internet Information Server
Starting Service Tier
Container IP Address: 172.27.3.237
Container Hostname : CAGNA170-Dev
Container Dns Name : CAGNA170-Dev
Web Client : http://CAGNA170-Dev/BC/
Dev. Server : http://CAGNA170-Dev
Dev. ServerInstance : BC
Setting CAGNA170-Dev to 172.27.3.237 in host hosts file
Files:
http://CAGNA170-Dev:8080/ALLanguage.vsix
Container Total Physical Memory is 31.8Gb
Container Free Physical Memory is 17.5Gb
Initialization took 73 seconds
Ready for connections!
Copy from container CAGNA170-Dev (C:\Applications\TestFramework\TestLibraries\Any\Microsoft_Any.app) to C:\Progra
mData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Any.app
Publishing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Any.app
Synchronizing Any on tenant default
Installing Any on tenant default
App successfully published
Copy from container CAGNA170-Dev (C:\Applications\TestFramework\TestLibraries\Assert\Microsoft_Library Assert.app
) to C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Library Assert.app
Publishing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Library Assert.app
Synchronizing Library Assert on tenant default
Installing Library Assert on tenant default
App successfully published
Copy from container CAGNA170-Dev (C:\Applications\TestFramework\TestLibraries\Variable Storage\Microsoft_Library
Variable Storage.app) to C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Library Variable St
orage.app
Publishing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Library Variable Storage.app
Synchronizing Library Variable Storage on tenant default
Installing Library Variable Storage on tenant default
App successfully published
Copy from container CAGNA170-Dev (C:\Applications\TestFramework\TestRunner\Microsoft_Test Runner.app) to C:\Progr
amData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Test Runner.app
Publishing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Test Runner.app
Synchronizing Test Runner on tenant default
Installing Test Runner on tenant default
App successfully published
Copy from container CAGNA170-Dev (C:\Applications\System Application\Test\Microsoft_System Application Test Libra
ry.app) to C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_System Application Test Library.a
pp
Publishing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_System Application Test Library.a
pp
Synchronizing System Application Test Library on tenant default
Installing System Application Test Library on tenant default
App successfully published
Copy from container CAGNA170-Dev (C:\Applications\BaseApp\Test\Microsoft_Tests-TestLibraries.app) to C:\ProgramDa
ta\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Tests-TestLibraries.app
Publishing C:\ProgramData\NavContainerHelper\Extensions\CAGNA170-Dev\_Microsoft_Tests-TestLibraries.app
Extension compilation failed
LibraryHeadlines.Codeunit.al(5,79): error AL0161: 'OnTaskSchedulerUnavailable' is inaccessible due to its protect
ion level
at <ScriptBlock>, <No file>: line 15
Extension compilation failed
LibraryHeadlines.Codeunit.al(5,79): error AL0161: 'OnTaskSchedulerUnavailable' is inaccessible due to its
protection level
Au caract猫re C:\Program
Files\WindowsPowerShell\Modules\BcContainerHelper\1.0.15\ContainerHandling\Invoke-ScriptInNavContainer.ps1:39 :
13
+ Invoke-Command -Session $session -ScriptBlock $scriptbloc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation : (:) [Publish-NAVApp], InvalidOperationException
+ FullyQualifiedErrorId : MicrosoftDynamicsNavServer$BC/nav-systemapplication,Microsoft.Dynamics.Nav.Apps.M
anagement.Cmdlets.PublishNavApp
+ PSComputerName : 26e85298dbcdc302b822e9459d911642a4a5521d20bf1a7bf88636c9c1d137de
The bakfile you are restoring - is that from the same version of BC?
Yes, it's from 17.1 OnPrem FR version
On container : Version : FR Business Central 17.1 (plateforme 17.0.18204.18738 + application 17.1.18256.18792)
On OnPrem Server (source of backup) : Version : FR Business Central 17.1, (plateforme 17.0.18204.18738 + application 17.1.18256.18792)
Just one thing, the backup contains a modified Base Application...
The source code of Base Application (standard not modified):
codeunit 1441 "RC Headlines Executor"
{
TableNo = "Job Queue Entry";
trigger OnRun()
var
RCHeadlinesUserData: Record "RC Headlines User Data";
RoleCenterPageID: Integer;
begin
Evaluate(RoleCenterPageID, "Parameter String");
RCHeadlinesUserData.Get(UserSecurityId(), RoleCenterPageID);
WorkDate := RCHeadlinesUserData."User workdate";
OnComputeHeadlines(RoleCenterPageID);
end;
procedure ScheduleTask(RoleCenterPageID: Integer)
var
JQE: Record "Job Queue Entry";
Tomorrow: Date;
begin
JQE.SetRange("Object Type to Run", JQE."Object Type to Run"::Codeunit);
JQE.SetRange("Object ID to Run", Codeunit::"RC Headlines Executor");
JQE.SetRange("Parameter String", Format(RoleCenterPageID));
JQE.SetFilter(Status, '%1|%2', JQE.Status::"In Process", JQE.Status::Ready);
if not JQE.IsEmpty() then
exit;
JQE.SetFilter(Status, '%1|%2', JQE.Status::Error, JQE.Status::"On Hold");
if JQE.FindFirst() then begin
// restart the job tomorrow
Tomorrow := CalcDate('<+1d>');
JQE."Earliest Start Date/Time" := CreateDateTime(Tomorrow, Time());
end else begin
// create a new job
JQE.Init();
JQE."Object Type to Run" := JQE."Object Type to Run"::Codeunit;
JQE."Object ID to Run" := Codeunit::"RC Headlines Executor";
JQE."Parameter String" := Format(RoleCenterPageID);
end;
if TaskScheduler.CanCreateTask and JQE.WritePermission then
Codeunit.Run(Codeunit::"Job Queue - Enqueue", JQE)
else
OnTaskSchedulerUnavailable(JQE);
end;
[IntegrationEvent(false, false)]
local procedure OnComputeHeadlines(RoleCenterPageID: Integer)
begin
end;
[InternalEvent(false)]
local procedure OnTaskSchedulerUnavailable(JobQueueEntry: Record "Job Queue Entry")
begin
end;
}
The source code of _Microsoft_Tests-TestLibraries.app:
codeunit 130626 "Library - Headlines"
{
EventSubscriberInstance = Manual;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"RC Headlines Executor", 'OnTaskSchedulerUnavailable', '', false, false)]
local procedure OnTaskSchedulerUnavailable(JobQueueEntry: Record "Job Queue Entry")
begin
Codeunit.Run(Codeunit::"RC Headlines Executor", JobQueueEntry);
end;
}
As you can see, OnTaskSchedulerUnavailable is marked as InternalEvent...
Why it works with standard Base Application?
My assumption is that there is an internalsvisibleto (to the test apps)
I will ask Nikola
I think, it's in the modified Base Application that I must put InternalsVisibleTo to some apps in the app.json. But with what aspps? (InternalsVisibleTo is empty in the NavxManifest.xml of the standard Base Application.app and in the source of the standard Base Application InternalsVisibleTo is not present in the app.json ...)
<InternalsVisibleTo>
<Module Id="5d86850b-0d76-4eca-bd7b-951ad998e997" Name="Tests-TestLibraries" Publisher="Microsoft" />
<Module Id="c49d9d39-1c94-46d2-8bf7-3cce15ba54dc" Name="Tests-SMTP" Publisher="Microsoft" />
<Module Id="7fe10be7-575f-4cce-957b-bcd0df8f9bd7" Name="Tests-Rapid Start" Publisher="Microsoft" />
<Module Id="4564dd2f-e8b2-41ff-9905-9d7a950475a5" Name="Tests-Misc" Publisher="Microsoft" />
<Module Id="8c9fc75f-dc51-40de-a6fa-55e7bbe0c0c2" Name="Tests-What's New Notifier Test" Publisher="Microsoft" />
</InternalsVisibleTo>
Found in c:\applications\baseapp\Microsoft_Base Application.app navxmanifest.xml (from inside a container).
Will fix extract-appfiletofolder to add this to app.json (if you specify -generateappjson) - that was missing
Thank you very much Freddy !!!
I will try and give you feedback
"internalsVisibleTo": [
{
"id": "5d86850b-0d76-4eca-bd7b-951ad998e997",
"publisher": "Microsoft",
"name": "Tests-TestLibraries"
},
{
"id": "c49d9d39-1c94-46d2-8bf7-3cce15ba54dc",
"publisher": "Microsoft",
"name": "Tests-SMTP"
},
{
"id": "7fe10be7-575f-4cce-957b-bcd0df8f9bd7",
"publisher": "Microsoft",
"name": "Tests-Rapid Start"
},
{
"id": "4564dd2f-e8b2-41ff-9905-9d7a950475a5",
"publisher": "Microsoft",
"name": "Tests-Misc"
},
{
"id": "8c9fc75f-dc51-40de-a6fa-55e7bbe0c0c2",
"publisher": "Microsoft",
"name": "Tests-What\u0027s New Notifier Test"
}
],
Fix shipped in 1.0.16