microsoft / navcontainerhelper

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

Run-ALPipeline not installing test apps. Am I missing something? #1686

Closed GreatScott000 closed 3 years ago

GreatScott000 commented 3 years ago

PLEASE DO NOT INCLUDE ANY PASSWORDS OR TOKENS IN YOUR ISSUE!!!

No Tests apps installed Running the local-DevEnv.ps1 script, which basically calls Run-AlPipeline

Scripts used to create container and cause the issue

Param(
    [Parameter(Mandatory=$false)]
    [string] $version = "ci"
)

$baseFolder = (Get-Item (Join-Path $PSScriptRoot "..")).FullName
. (Join-Path $PSScriptRoot "Read-Settings.ps1") -environment 'Local' -version $version
. (Join-Path $PSScriptRoot "Install-BcContainerHelper.ps1") -bcContainerHelperVersion $bcContainerHelperVersion -genericImageName $genericImageName

if (("$vaultNameForLocal" -eq "") -or !(Get-AzKeyVault -VaultName $vaultNameForLocal)) {
    throw "You need to setup a Key Vault for use with local pipelines"
}
Get-AzKeyVaultSecret -VaultName $vaultNameForLocal | ForEach-Object {
    Write-Host "Get Secret $($_.Name)Secret"
    Set-Variable -Name "$($_.Name)Secret" -Value (Get-AzKeyVaultSecret -VaultName $vaultNameForLocal -Name $_.Name -WarningAction SilentlyContinue)
}
$licenseFile = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($licenseFileSecret.SecretValue))
$insiderSasToken = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($insiderSasTokenSecret.SecretValue))
$credential = New-Object pscredential 'admin', $passwordSecret.SecretValue

$allTestResults = "testresults*.xml"
$testResultsFile = Join-Path $baseFolder "TestResults.xml"
$testResultsFiles = Join-Path $baseFolder $allTestResults
if (Test-Path $testResultsFiles) {
    Remove-Item $testResultsFiles -Force
}

Run-AlPipeline `
    -pipelineName $pipelineName `
    -containerName $containerName `
    -imageName $imageName `
    -artifact $artifact.replace('{INSIDERSASTOKEN}',$insiderSasToken) `
    -memoryLimit $memoryLimit `
    -baseFolder $baseFolder `
    -licenseFile $licenseFile `
    -installApps $installApps `
    -previousApps $previousApps `
    -appFolders $appFolders `
    -testFolders $testFolders `
    -testResultsFile $testResultsFile `
    -testResultsFormat 'JUnit' `
    -installTestFramework:$installTestFramework `
    -installTestLibraries:$installTestLibraries `
    -installPerformanceToolkit:$installPerformanceToolkit `
    -enableCodeCop:$enableCodeCop `
    -enableAppSourceCop:$enableAppSourceCop `
    -enablePerTenantExtensionCop:$enablePerTenantExtensionCop `
    -enableUICop:$enableUICop `
    -AppSourceCopMandatoryAffixes $appSourceCopMandatoryAffixes `
    -AppSourceCopSupportedCountries $appSourceCopSupportedCountries `
    -additionalCountries $additionalCountries `
    -credential $credential `
    -doNotRunTests `
    -useDevEndpoint `
    -updateLaunchJson "Local Sandbox" `
    -keepContainer `
    -rulesetFile $rulesetfile `
    -vsixFile (Get-LatestAlLanguageExtensionUrl)

Full output of scripts

=====> PowerShell Preview Integrated Console v2020.9.0 <=====

PS D:\Repos\evolveims\RMS\src> d:\Repos\evolveims\RMS\scripts\Local-DevEnv.ps1
Set artifact = https://bcartifacts.azureedge.net/onprem/17.3.20469.20605/gb
Set pipelineName = rms-ci 
Set containerName = rms-ci
Set installApps = ''
Set previousApps = ''
Set appSourceCopMandatoryAffixes = 'iMS' 
Set appSourceCopSupportedCountries = 'gb'
Set appFolders = 'src'
Set testFolders = 'test'
Set memoryLimit = '6G'
Set additionalCountries = ''
Set genericImageName = ''
Set vaultNameForLocal = 'evolveAppVault'
Set bcContainerHelperVersion = 'Latest' 
Set installTestFramework = True        
Set installTestLibraries = True        
Set installPerformanceToolkit = False  
Set enableCodeCop = True
Set enableAppSourceCop = True
Set enablePerTenantExtensionCop = False
Set enableUICop = True
Set doNotSignApps = True
Set doNotRunTests = False
Set cacheImage = True
Set CreateRuntimePackages = True
Set rulesetfile = '_RuleSets\ims.ruleset.json'
Set appPackages = '.packages'
Setting hostHelperFolder = d:\bccontainerhelper
Setting bcartifactsCacheFolder = d:\bcartifacts.cache
BcContainerHelper version 2.0.4
Get Secret CodeSignPfxFileSecret
Get Secret CodeSignPfxPasswordSecret
Get Secret insiderSasTokenSecret
Get Secret LicenseFileSecret
Get Secret PasswordSecret
Get Secret StorageConnectionStringSecret
Get Secret UsernameSecret

[DBG]: PS D:\Repos\evolveims\RMS\scripts> 
  _____                               _
 |  __ \                             | |
 | |__) |_ _ _ __ __ _ _ __ ___   ___| |_ ___ _ __ ___
 |  ___/ _` | '__/ _` | '_ ` _ \ / _ \ __/ _ \ '__/ __|
 | |  | (_| | | | (_| | | | | | |  __/ |_  __/ |  \__ \
 |_|   \__,_|_|  \__,_|_| |_| |_|\___|\__\___|_|  |___/

Pipeline name               rms-ci
Container name              rms-ci
Image name
ArtifactUrl                 https://bcartifacts.azureedge.net/onprem/17.3.20469.20605/gb
SasToken                    Not Specified
BcAuthContext               Not Specified
Environment
Credential                  Specified
MemoryLimit                 6G
Enable Task Scheduler       False
Assign Premium Plan         False
Install Test Runner         False
**Install Test Framework      True
Install Test Libraries      True**
Install Perf. Toolkit       False
CopySymbolsFromContainer    False
enableCodeCop               True
enableAppSourceCop          True
enableUICop                 True
enablePerTenantExtensionCop False
escapeFromCops              False
useDefaultAppSourceRuleSet  False
rulesetFile                 D:\Repos\evolveims\RMS\_RuleSets\ims.ruleset.json
azureDevOps                 False
License file                Specified
CodeSignCertPfxFile         Not specified
TestResultsFile             D:\Repos\evolveims\RMS\TestResults.xml
TestResultsFormat           JUnit
AdditionalCountries
PackagesFolder
OutputFolder
BuildArtifactFolder
CreateRuntimePackages       False
AppBuild                    0
AppRevision                 0
Mandatory Affixes           iMS
Supported Countries         gb
Install Apps
- None
Previous Apps
- None
Application folders
- D:\Repos\evolveims\RMS\src
Test application folders
- D:\Repos\evolveims\RMS\test

  _____       _ _ _                                          _        _
 |  __ \     | | (_)                                        (_)      (_)
 | |__) |   _| | |_ _ __   __ _    __ _  ___ _ __   ___ _ __ _  ___   _ _ __ ___   __ _  __ _  ___
 |  ___/ | | | | | | '_ \ / _` |  / _` |/ _ \ '_ \ / _ \ '__| |/ __| | | '_ ` _ \ / _` |/ _` |/ _ \
 | |   | |_| | | | | | | | (_| | | (_| |  __/ | | |  __/ |  | | (__  | | | | | | | (_| | (_| |  __/
 |_|    \__,_|_|_|_|_| |_|\__, |  \__, |\___|_| |_|\___|_|  |_|\___| |_|_| |_| |_|\__,_|\__, |\___|
                           __/ |   __/ |                                                 __/ |
                          |___/   |___/                                                 |___/

Pulling mcr.microsoft.com/businesscentral:10.0.19042.746

Pulling generic image took 2 seconds

   _____                _   _                               _        _
  / ____|              | | (_)                             | |      (_)
 | |     _ __ ___  __ _| |_ _ _ __   __ _    ___ ___  _ __ | |_ __ _ _ _ __   ___ _ __
 | |    | '__/ _ \/ _` | __| | '_ \ / _` |  / __/ _ \| '_ \| __/ _` | | '_ \ / _ \ '__|
 | |____| | |  __/ (_| | |_| | | | | (_| | | (__ (_) | | | | |_ (_| | | | | |  __/ |
  \_____|_|  \___|\__,_|\__|_|_| |_|\__, |  \___\___/|_| |_|\__\__,_|_|_| |_|\___|_|
                                     __/ |
                                    |___/

BcContainerHelper is version 2.0.4
BcContainerHelper is running as administrator
Host is Microsoft Windows 10 Pro - 20H2
Docker Client Version is 20.10.2
Docker Server Version is 20.10.2
Removing container rms-ci
Removing rms-ci from host hosts file
Removing rms-ci-* from host hosts file
Removing d:\bccontainerhelper\Extensions\rms-ci
Fetching all docker images
Using image mcr.microsoft.com/businesscentral:10.0.19042.746
Creating Container rms-ci
Version: 17.3.20469.20605-gb
Style: onprem
Multitenant: No
Platform: 17.0.20458.20517
Generic Tag: 1.0.1.3
Container OS Version: 10.0.19042.746 (20H2)
Host OS Version: 10.0.19042.746 (20H2)
Using process isolation
Using locale en-GB
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Downloading d:\bccontainerhelper\Extensions\rms-ci\Microsoft.VisualStudio.Services.VSIXPackage.vsix
Using license file https://evolveapp.blob.core.windows.net/app/BC17License.flf
Downloading d:\bccontainerhelper\Extensions\rms-ci\my\license.flf
Additional Parameters:
--volume "D:\Repos\evolveims\RMS:c:\sources"
--env customNavSettings=EnableTaskScheduler=False
Files in d:\bccontainerhelper\Extensions\rms-ci\my:
- AdditionalOutput.ps1
- license.flf
- MainLoop.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container rms-ci from image mcr.microsoft.com/businesscentral:10.0.19042.746
f32e4c05e72afa77d47f523a3424dc48ff74b64f798f748858337c8e7a28a3c9
Waiting for container rms-ci to be ready
Using artifactUrl https://bcartifacts.azureedge.net/onprem/17.3.20469.20605/gb
Using installer from C:\Run\150-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to
start...
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.3.20469.20605\gb\database\Demo Database NAV (17-0).bak
Changing Database Server Collation to Latin1_General_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 191 seconds
Installation complete
Initializing...
Setting host.docker.internal to 192.168.0.11 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 192.168.0.11 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 dbserver.containerhelper.internal to 192.168.0.11 in container hosts file (copy from host hosts file)
Setting host.containerhelper.internal to 172.18.32.1 in container hosts file
Starting Container
Hostname is rms-ci
PublicDnsName is rms-ci
Using NavUserPassword Authentication
Creating Self Signed Certificate
Self Signed Certificate Thumbprint 0169E9F4AAFAB23319070C2FED64D3C56EC5692C
Modifying Service Tier Config File with Instance Specific Settings
Modifying Service Tier Config File with settings from environment variable
Setting EnableTaskScheduler to False
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 admin as SQL User and add to sysadmin
Creating SUPER user
Container IP Address: 172.18.43.179
Container Hostname  : rms-ci
Container Dns Name  : rms-ci
Web Client          : http://rms-ci/BC/
Dev. Server         : http://rms-ci
Dev. ServerInstance : BC
Setting rms-ci to 172.18.43.179 in host hosts file

Files:
http://rms-ci:8080/Microsoft.VisualStudio.Services.VSIXPackage.vsix

Container Total Physical Memory is 15.7Gb
Container Free Physical Memory is 2.1Gb

Initialization took 89 seconds
Ready for connections!
Reading CustomSettings.config from rms-ci
Creating Desktop Shortcuts for rms-ci
Container rms-ci successfully created

Use:
Get-BcContainerEventLog -containerName rms-ci to retrieve a snapshot of the event log from the container
Get-BcContainerDebugInfo -containerName rms-ci to get debug information about the container
Enter-BcContainer -containerName rms-ci to open a PowerShell prompt inside the container
Remove-BcContainer -containerName rms-ci to remove the container again
docker logs rms-ci to retrieve information about URL's again

Creating container took 341 seconds

   _____                      _ _ _
  / ____|                    (_) (_)
 | |     ___  _ __ ___  _ __  _| |_ _ __   __ _    __ _ _ __  _ __  ___
 | |    / _ \| '_ ` _ \| '_ \| | | | '_ \ / _` |  / _` | '_ \| '_ \/ __|
 | |____ (_) | | | | | | |_) | | | | | | | (_| | | (_| | |_) | |_) \__ \
  \_____\___/|_| |_| |_| .__/|_|_|_|_| |_|\__, |  \__,_| .__/| .__/|___/
                       | |                 __/ |       | |   | |
                       |_|                |___/        |_|   |_|

Using custom ruleset
Creating AppSourceCop.json for validation
Using Symbols Folder: D:\Repos\evolveims\RMS\src\.alPackages
Compiling...
.\alc.exe /project:"c:\sources\src" /packagecachepath:"c:\sources\src\.alPackages" /out:"c:\sources\src\Evolve iMS Ltd._Rental Management System_17.3.0.0.app" /analyzer:C:\build\vsix\extension\bin\Analyzers\Microsoft.Dynamics.Nav.CodeCop.dll /analyzer:C:\build\vsix\extension\bin\Analyzers\Microsoft.Dynamics.Nav.AppSourceCop.dll /analyzer:C:\build\vsix\extension\bin\Analyzers\Microsoft.Dynamics.Nav.UICop.dll /ruleset:c:\sources\_RuleSets\ims.ruleset.json /assemblyprobingpaths:"C:\Program Files (x86)\Microsoft Dynamics NAV\170\RoleTailored Client","C:\Program Files\Microsoft Dynamics NAV\170\Service","C:\Program Files (x86)\Open XML SDK\V2.5\lib","c:\Windows\Microsoft.NET\Assembly","C:\Test Assemblies\Mock Assemblies"
Microsoft (R) AL Compiler version 6.1.6.3960
Copyright (C) Microsoft Corporation. All rights reserved

Compilation started for project 'Rental Management System' containing '96' files at '16:28:55.236'.

c:\sources\src\Query\iMSReservationEntry.Query.al(86,46): warning AL0432: Field 'Cross-Reference Type' is marked for removal. Reason: Cross-Reference replaced by Item Reference feature.. Tag: 17.0.
c:\sources\src\Query\iMSRentalLineCertification.Query.al(74,46): warning AL0432: Field 'Cross-Reference Type' is marked for removal. Reason: Cross-Reference replaced by Item Reference feature.. Tag: 17.0.
c:\sources\src\Query\iMSRentalLineSNLot.Query.al(64,42): warning AL0432: Field 'Cross-Reference Type' is marked for removal. Reason: Cross-Reference replaced by Item Reference feature.. Tag: 17.0.
c:\sources\src\Page\iMSRentalOrderSubform.Page.al(49,50): warning AL0432: Field 'Cross-Reference No.' is marked for removal. Reason: Cross-Reference replaced by Item Reference feature.. Tag: 17.0.
c:\sources\src\TableExtension\iMSSalesHeader.TableExt.al(291,34): warning AL0432: Table 'Customer Template' is marked for removal. Reason: Deprecate mini and customer templates. Use table "Customer Templ." instead and for extensions.. Tag: 18.0.
c:\sources\src\Codeunit\iMSRMSActRegMgmt.Codeunit.al(290,28): warning AL0432: Method 'SetNewSerialLotNo' is marked for removal. Reason: Replaced by SetNewTrackingFrom() procedures.. Tag: 17.0.
c:\sources\src\Page\iMSRentalOrderSubform.Page.al(1055,33): warning AL0432: Method 'ShowItemSub' is marked for removal. Reason: Function scope will be changed to OnPrem. Tag: 15.1.
c:\sources\src\TableExtension\iMSLotNoInformation.TableExt.al(74,24): info AA0232: The FlowField "Entry No." of "Warehouse Entry" should be added to the SIFT key.
c:\sources\src\Table\iMSReservationEntryArchive.Table.al(170,19): info AA0232: The FlowField Quantity of "Action Message Entry" should be added to the SIFT key.
c:\sources\src\TableExtension\iMSReturnReason.TableExt.al(12,24): info AA0232: The FlowField Quantity of "Item Ledger Entry" should be added to the SIFT key.
c:\sources\src\Table\iMSRMSItemLedgerEntry.Table.al(169,19): info AA0232: The FlowField "Quantity (Base)" of "Reservation Entry" should be added to the SIFT key.
c:\sources\src\Page\iMSRentalLines.Page.al(1,14): info AW0006: The page 'iMS Rental Lines' should use the UsageCategory and ApplicationArea properties to be searchable.
c:\sources\src\Table\iMSSerialLotNoInformat.Table.al(44,19): info AA0232: The FlowField "Entry No." of "Warehouse Entry" should be added to the SIFT key.
c:\sources\src\TableExtension\iMSSalesArchiveHeader.TableExt.al(59,24): info AA0232: The FlowField Quantity of "Sales Line" should be added to the SIFT key.
c:\sources\src\TableExtension\iMSItem.TableExt.al(104,24): info AA0232: The FlowField "Outstanding Qty. (Base)" of "Sales Line" should be added to the SIFT key.
c:\sources\src\TableExtension\iMSSerialNoInformation.TableExt.al(63,24): info AA0232: The FlowField "Entry No." of "Warehouse Entry" should be added to the SIFT key.
c:\sources\src\TableExtension\iMSSalesHeader.TableExt.al(133,24): info AA0232: The FlowField Quantity of "Sales Line" should be added to the SIFT key.
c:\sources\src\TableExtension\iMSSalesLine.TableExt.al(12,24): info AA0232: The FlowField Quantity of "iMS Rental Article" should be added to the SIFT key.
c:\sources\src\app.json(29,5): warning AS0053: The compilation target is set to 'OnPrem', but it must be set to 'Cloud' or 'Extension'.
c:\sources\src\app.json(1,1): warning AS0092: The 'applicationInsightsKey' property must specify the instrumentation key of the Azure Application Insights resource for monitoring operations related to this extension. 
See https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/telemetry-overview for additional information.
c:\sources\src\Page\iMSItemArticleSelection.Page.al(743,14): warning AA0175: Variable 'RentalArticle' queries the database in 'BufferEntryExists' but does not use the queried record. Only find or get record if you need to access the values. Consider using ISEMPTY.
c:\sources\src\extensionsPermissionSet.xml(1,1): info AL1027: The file at location 'c:\sources\src\extensionsPermissionSet.xml' matches the definition for 'PermissionSet'.

Compilation ended at '16:29:25.518'.

D:\Repos\evolveims\RMS\src\Evolve iMS Ltd._Rental Management System_17.3.0.0.app successfully created in 51 seconds
Publishing Evolve iMS Ltd._Rental Management System_17.3.0.0.app to http://172.18.43.179:7049/BC/dev/apps?SchemaUpdateMode=synchronize&tenant=default
App Evolve iMS Ltd._Rental Management System_17.3.0.0.app successfully published
Modifying D:\Repos\evolveims\RMS\src\.vscode\launch.json
{
    "type":  "al",
    "request":  "launch",
    "name":  "Local Sandbox",
    "server":  "http://rms-ci",
    "serverInstance":  "BC",
    "port":  "7049",
    "tenant":  "default",
    "authentication":  "UserPassword"
}
PS D:\Repos\evolveims\RMS\scripts> ConvertFrom-Json : Invalid object passed in, ':' or '}' expected. (344): {
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Your own server",
            "request": "launch",
            "type": "al",
            "environmentType": "OnPrem",
            "server": "http://rms-ci",
            "serverInstance": "BC",
            "authentication": "UserPassword",
            // "startupObjectId": 22,
            // "startupObjectType": "Page",
            "breakOnError": true,
            "launchBrowser": true,
            "enableLongRunningSqlStatements": true,
            "enableSqlInformationDebugger": true,
            "tenant": "default"
        }
    ]
}
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.4\AppHandling\Run-AlPipeline.ps1:235 char:53
+         $launchJson = Get-Content $LaunchJsonFile | ConvertFrom-Json
+                                                     ~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [ConvertFrom-Json], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand

Screenshots If applicable, add screenshots to help explain your problem. Installing tests is enabled in the parameters. image image

Additional context

GreatScott000 commented 3 years ago

Is it because of the error writing the launch file? I guess it must be. Don't know the order of things. Don't understand the launch file error.

GreatScott000 commented 3 years ago

Yes, that was the problem. I had commented out these lines and the blew up the script. It is after this that the tests are installed.

        // "startupObjectId": 22,
        // "startupObjectType": "Page",
freddydk commented 3 years ago

Yeah, it looks like an error reading the launch.json, not writing it - that breaks the pipeline.

GreatScott000 commented 3 years ago

Is there a way to install all tests?

freddydk commented 3 years ago

Not in Run-AlPipeline