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

Run-AlPipeline, when the source app and test app have the same name, copies the test app to both folders in the build artifacts #3663

Closed KrunoslavPipic closed 6 days ago

KrunoslavPipic commented 6 days ago

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

Describe the issue I'm not sure if the described issue is actually a problem or if it's intentional behavior. Namely, if both the source app and test app have the same name, the RunAl-Pipeline will copy the test app into both the Apps and TestApps folders. In this case, the source app will be overwritten by the test app if the same app name is specified in both app.json files. I would expect the copying process to be based on the appId from the corresponding app.json file, but it appears to operate based on the app name instead.

Scripts used to create container and cause the issue

New-BcContainer `
  Measure-Command {
    $ContainerName = 'test'
    $RepositoryDirectory = "C:\AL\Localization CRO"
    $rulesetFile = Join-Path -ChildPath("source/company.ruleset.json") -Path $RepositoryDirectory

    $versionBuild = Get-Date -Format "yyyyMMdd"
    $versionRevision = Get-Date -Format "HHmmss"
    $appVersion = "{0}.{1}" -f 1, 1

    $stagingDirectory = "C:\NavBiz\temp"
    $AppSourceCop = (Get-Content "C:\AL\Localization CRO\source\AppSourceCop.json" -Encoding UTF8 | ConvertFrom-Json)
    $AppSourceCopMandatoryAffixes = New-Object System.Collections.ArrayList
    $AppSourceCopSupportedCountries = New-Object System.Collections.ArrayList
    foreach ($affix in $AppSourceCop.mandatoryAffixes) {
        $AppSourceCopMandatoryAffixes.Add($affix) | Out-Null
    }
    foreach ($country in $AppSourceCop.supportedCountries) {
        $AppSourceCopSupportedCountries.Add($country) | Out-Null
    }

    $password = ConvertTo-SecureString 'Lozinka123$' -AsPlainText -Force
    $Credential = [PSCredential]::new('admin', $password)
    $artifactUrl = Get-BCArtifactUrl -country W1 -select Latest -type Sandbox
    Measure-Command {
        $Params = @{
            artifact                       = $artifactUrl
            containerName                  = $ContainerName
            baseFolder                     = $RepositoryDirectory
            appFolders                     = "source" 
            testFolders                    = "test"
            AppSourceCopMandatoryAffixes   = $AppSourceCopMandatoryAffixes
            AppSourceCopSupportedCountries = $AppSourceCopSupportedCountries
            enableAppSourceCop             = $true
            enableCodeCop                  = $true
            enableExternalRulesets         = $true
            rulesetFile                    = $rulesetFile
            enableUICop                    = $true
            installTestFramework           = $true
            installTestLibraries           = $true
            installTestRunner              = $true
            keepContainer                  = $true
            reUseContainer                 = $true
            enableTaskScheduler            = $false 
            credential                     = $Credential
            failOn                         = "warning"
            installApps                    = $installApps
            previousApps                   = $previousApps
            buildArtifactFolder            = $stagingDirectory
            appVersion                     = $appVersion
            appBuild                       = $versionBuild
            appRevision                    = $versionRevision
            PreCompileApp                  = $PreCompileApp
        }
        Run-AlPipeline @Params
    } | ForEach-Object { Write-Host "`n##[command]AL Pipeline: $([int]$_.TotalSeconds) seconds" }
} | ForEach-Object { Write-Host "`n##[command]Script duration: $([int]$_.TotalSeconds) seconds" }

Full output of scripts

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

Pipeline name                   
Container name                  test
Image name                      my
ArtifactUrl                     https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/24.4.22295.24055/w1
BcAuthContext                   Not Specified
Environment                     
ReUseContainer                  True
KeepContainer                   True
useCompilerFolder               False
artifactCachePath               
useDevEndpoint                  False
Auth                            UserPassword
CompanyName                     
MemoryLimit                     8G
FailOn                          warning
TreatTestFailuresAsWarnings     False
Enable Task Scheduler           False
Assign Premium Plan             False
Install Test Runner             True
Install Test Framework          True
Install Test Libraries          True
Install Perf. Toolkit           False
InstallOnlyReferencedApps       False
generateDependencyArtifact      False
CopySymbolsFromContainer        False
enableCodeCop                   True
enableAppSourceCop              True
enableUICop                     True
enablePerTenantExtensionCop     False
enableCodeAnalyzersOnTestApps   False
doNotPerformUpgrade             False
doNotPublishApps                False
uninstallRemovedApps            False
escapeFromCops                  False
doNotBuildTests                 False
doNotRunTests                   False
doNotRunBcptTests               False
useDefaultAppSourceRuleSet      False
rulesetFile                     C:\AL\Localization CRO\source\company.ruleset.json
generateErrorLog                False
enableExternalRulesets          True
azureDevOps                     False
gitLab                          False
gitHubActions                   False
vsixFile                        
License file                    CodeSignCertPfxFile             CodeSignCertPfxPassword         CodeSignCertIsSelfSigned        False
KeyVaultCertPfxFile             KeyVaultCertPfxPassword         KeyVaultClientId                
BuildOutputFile                 
ContainerEventLogFile           
TestResultsFile                 C:\AL\Localization CRO\TestResults.xml
BcptTestResultsFile             C:\AL\Localization CRO\bcptTestResults.json
TestResultsFormat               JUnit
AdditionalCountries             
PackagesFolder                  C:\AL\Localization CRO\.packages
OutputFolder                    C:\AL\Localization CRO\.output
BuildArtifactFolder             C:\NavBiz\temp
CreateRuntimePackages           False
AppVersion                      1.1
AppBuild                        20240911
AppRevision                     210724
SourceRepositoryUrl             
SourceCommit                    
BuildBy                         BcContainerHelper,6.0.19
BuildUrl                        
Mandatory Affixes               eve
Supported Countries             hr
ObsoleteTagMinAllowedMajorMinor 
Install Apps
- None
Install Test Apps
- None
Previous Apps
- None
Application folders
- C:\AL\Localization CRO\source
Test application folders
- C:\AL\Localization CRO\test
BCPT Test application folders
- None
BCPT Test suites
- None
Custom CodeCops
- None

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

WARNING: Reusing a container based on https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/24.4.22295.24037/us, should be https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/24.4.22295.24055/w1
Reusing existing docker container

Creating container took 0 seconds

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

Sorted App folders
- C:\AL\Localization CRO\source
External dependencies
- 437dbf0e-84ff-417a-965d-ed2bb9650972:Microsoft_Base Application_23.0.0.0.app
- 63ca2fa4-4f03-4f2b-a480-172fef340d3f:Microsoft_System Application_23.0.0.0.app
Sorted TestApp folders
- C:\AL\Localization CRO\test
External TestApp dependencies
- 437dbf0e-84ff-417a-965d-ed2bb9650972:Microsoft_Base Application_23.0.0.0.app
- 63ca2fa4-4f03-4f2b-a480-172fef340d3f:Microsoft_System Application_23.0.0.0.app

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

Using custom ruleset
Using Version 1.1.20240911.210724
Creating AppSourceCop.json for validation
AppSourceCop.json content:
{
    "mandatoryAffixes":  [
                             "eve"
                         ],
    "supportedCountries":  [
                               "hr"
                           ]
}

Compiling C:\AL\Localization CRO\source
Using Symbols Folder: C:\AL\Localization CRO\.packages
Processing dependency Microsoft_Application_23.0.0.0 ()
Downloading symbols: Microsoft_Application_24.4.22295.24037.app
Url : http://172.18.199.76:7049/BC/dev/packages?publisher=Microsoft&appName=Application&versionText=23.0.0.0&tenant=default
Adding dependency to System Application from Microsoft
Adding dependency to Business Foundation from Microsoft
Adding dependency to Base Application from Microsoft
Processing dependency Microsoft_System_1.0.0.0 ()
Downloading symbols: Microsoft_System_24.0.23996.0.app
Url : http://172.18.199.76:7049/BC/dev/packages?publisher=Microsoft&appName=System&versionText=1.0.0.0&tenant=default
Processing dependency Microsoft_System Application_24.4.0.0 (63ca2fa4-4f03-4f2b-a480-172fef340d3f)
Downloading symbols: Microsoft_System Application_24.4.22295.24037.app
Url : http://172.18.199.76:7049/BC/dev/packages?appId=63ca2fa4-4f03-4f2b-a480-172fef340d3f&versionText=24.4.0.0&tenant=default
Processing dependency Microsoft_Business Foundation_24.4.0.0 (f3552374-a1f2-4356-848e-196002525837)
Downloading symbols: Microsoft_Business Foundation_24.4.22295.24037.app
Url : http://172.18.199.76:7049/BC/dev/packages?appId=f3552374-a1f2-4356-848e-196002525837&versionText=24.4.0.0&tenant=default
Processing dependency Microsoft_Base Application_24.4.0.0 (437dbf0e-84ff-417a-965d-ed2bb9650972)
Downloading symbols: Microsoft_Base Application_24.4.22295.24037.app
Url : http://172.18.199.76:7049/BC/dev/packages?appId=437dbf0e-84ff-417a-965d-ed2bb9650972&versionText=24.4.0.0&tenant=default
Compiling...
.\alc.exe /project:"c:\sources\source" /packagecachepath:"c:\sources\.packages" /out:"c:\sources\.output\NavBiz d.o.o._NavBiz Localization for Croatia_1.1.20240911.210724.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\
source\company.ruleset.json /enableexternalrulesets /BuildBy:"BcContainerHelper,6.0.19" /assemblyprobingpaths:"C:\Program Files\dotnet\shared","C:\ProgramData\BcContainerHelper\Extensions\test\.netPackages\Service"
Microsoft (R) AL Compiler version 13.1.17.13301
Copyright (C) Microsoft Corporation. All rights reserved

Compilation started for project 'NavBiz Localization for Croatia' containing '0' files at '21:10:00.133'.

Compilation ended at '21:10:02.810'.

C:\AL\Localization CRO\.output\NavBiz d.o.o._NavBiz Localization for Croatia_1.1.20240911.210724.app successfully created in 50 seconds
NavBiz d.o.o._NavBiz Localization for Croatia_1.1.20240911.210724.app copied to C:\AL\Localization CRO\.packages
  _____                            _   _               _            _     _              _ _    _ _
 |_   _|                          | | (_)             | |          | |   | |            | | |  (_) |
   | |  _ __ ___  _ __   ___  _ __| |_ _ _ __   __ _  | |_ ___  ___| |_  | |_ ___   ___ | | | ___| |_
   | | | '_ ` _ \| '_ \ / _ \| '__| __| | '_ \ / _` | | __/ _ \/ __| __| | __/ _ \ / _ \| | |/ / | __|
  _| |_| | | | | | |_) | (_) | |  | |_| | | | | (_| | | ||  __/\__ \ |_  | || (_) | (_) | |   <| | |_
 |_____|_| |_| |_| .__/ \___/|_|   \__|_|_| |_|\__, |  \__\___||___/\__|  \__\___/ \___/|_|_|\_\_|\__|
                 | |                            __/ |
                 |_|                           |___/
Skipping app 'C:\Applications.US\Microsoft_Permissions Mock_24.4.22295.24037.app' as it is already installed
Skipping app 'C:\Applications.US\Microsoft_Test Runner_24.4.22295.24037.app' as it is already installed
Skipping app 'C:\Applications.US\Microsoft_Any_24.4.22295.24037.app' as it is already installed
Skipping app 'C:\Applications.US\Microsoft_Library Assert_24.4.22295.24037.app' as it is already installed
Skipping app 'C:\Applications.US\Microsoft_Permissions Mock_24.4.22295.24037.app' as it is already installed
Skipping app 'C:\Applications.US\Microsoft_Library Variable Storage_24.4.22295.24037.app' as it is already installed
Skipping app 'C:\Applications.US\Microsoft_System Application Test Library_24.4.22295.24037.app' as it is already installed
Skipping app 'C:\Applications.US\Microsoft_Business Foundation Test Libraries_24.4.22295.24037.app' as it is already installed
Skipping app 'C:\Applications.US\Microsoft_Tests-TestLibraries_24.4.22295.24037.app' as it is already installed
TestToolkit successfully imported

Importing Test Toolkit took 16 seconds
   _____                      _ _ _               _           _
  / ____|                    (_) (_)             | |         | |
 | |     ___  _ __ ___  _ __  _| |_ _ __   __ _  | |_ ___ ___| |_    __ _ _ __  _ __  ___
 | |    / _ \| '_ ` _ \| '_ \| | | | '_ \ / _` | | __/ _ \ __| __|  / _` | '_ \| '_ \/ __|
 | |____ (_) | | | | | | |_) | | | | | | | (_| | | |_  __\__ \ |_  | (_| | |_) | |_) \__ \
  \_____\___/|_| |_| |_| .__/|_|_|_|_| |_|\__, |  \__\___|___/\__|  \__,_| .__/| .__/|___/
                       | |                 __/ |                         | |   | |
                       |_|                |___/                          |_|   |_|
Using Version 1.1.20240911.210724

Compiling C:\AL\Localization CRO\test
Using Symbols Folder: C:\AL\Localization CRO\.packages
Processing dependency Microsoft_Application_23.0.0.0 ()
Dependency App exists
Processing dependency Microsoft_System_1.0.0.0 ()
Dependency App exists
Compiling...
.\alc.exe /project:"c:\sources\test" /packagecachepath:"c:\sources\.packages" /out:"c:\sources\.output\NavBiz d.o.o._NavBiz Localization for Croatia_1.1.20240911.210724.app" /BuildBy:"BcContainerHelper,6.0.19" /assemblyprobi
ngpaths:"C:\Program Files\dotnet\shared","C:\ProgramData\BcContainerHelper\Extensions\test\.netPackages\Service"
Microsoft (R) AL Compiler version 13.1.17.13301
Copyright (C) Microsoft Corporation. All rights reserved

Compilation started for project 'NavBiz Localization for Croatia' containing '0' files at '21:10:28.003'.

Compilation ended at '21:10:30.074'.

C:\AL\Localization CRO\.output\NavBiz d.o.o._NavBiz Localization for Croatia_1.1.20240911.210724.app successfully created in 10 seconds
NavBiz d.o.o._NavBiz Localization for Croatia_1.1.20240911.210724.app copied to C:\AL\Localization CRO\.packages

Compiling apps, test apps and importing test toolkit took 79 seconds
  _____       _     _ _     _     _
 |  __ \     | |   | (_)   | |   (_)
 | |__) |   _| |__ | |_ ___| |__  _ _ __   __ _    __ _ _ __  _ __  ___
 |  ___/ | | | '_ \| | / __| '_ \| | '_ \ / _` |  / _` | '_ \| '_ \/ __|
 | |   | |_| | |_) | | \__ \ | | | | | | | (_| | | (_| | |_) | |_) \__ \
 |_|    \__,_|_.__/|_|_|___/_| |_|_|_| |_|\__, |  \__,_| .__/| .__/|___/
                                           __/ |       | |   | |
                                          |___/        |_|   |_|
Publishing C:\ProgramData\BcContainerHelper\Extensions\test\d88b4642-aeb1-4b56-a0e0-22b84d29729b\NavBiz d.o.o._NavBiz Localization for Croatia_1.1.20240911.210724.app
Synchronizing NavBiz Localization for Croatia on tenant default
Installing NavBiz Localization for Croatia on tenant default
App NavBiz d.o.o._NavBiz Localization for Croatia_1.1.20240911.210724.app successfully published
Publishing C:\ProgramData\BcContainerHelper\Extensions\test\97258d07-50ad-4722-a3c9-56ea7bc2db8c\NavBiz d.o.o._NavBiz Localization for Croatia_1.1.20240911.210724.app
Synchronizing NavBiz Localization for Croatia on tenant default
Installing NavBiz Localization for Croatia on tenant default
App NavBiz d.o.o._NavBiz Localization for Croatia_1.1.20240911.210724.app successfully published

Publishing apps took 10 seconds
  _____                   _               _            _
 |  __ \                 (_)             | |          | |
 | |__) |   _ _ __  _ __  _ _ __   __ _  | |_ ___  ___| |_ ___
 |  _  / | | | '_ \| '_ \| | '_ \ / _` | | __/ _ \/ __| __/ __|
 | | \ \ |_| | | | | | | | | | | | (_| | | ||  __/\__ \ |_\__ \
 |_|  \_\__,_|_| |_|_| |_|_|_| |_|\__, |  \__\___||___/\__|___/
                                   __/ |
                                  |___/
Running tests for App d3d10650-0f0f-4ace-9375-264f64a828eb in C:\AL\Localization CRO\test
Connecting to http://localhost:80/BC/cs?tenant=default
Setting test codeunit range ''

Running tests took 63 seconds
Copying test results to output
  _____                     _          _           _ _     _              _   _  __           _
 / ____|                   | |        | |         (_) |   | |            | | (_)/ _|         | |
 | |     ___  _ __  _   _  | |_ ___   | |__  _   _ _| | __| |   __ _ _ __| |_ _| |_ __ _  ___| |_ ___
 | |    / _ \| '_ \| | | | | __/ _ \  | '_ \| | | | | |/ _` |  / _` | '__| __| |  _/ _` |/ __| __/ __|
 | |___| (_) | |_) | |_| | | || (_) | | |_) | |_| | | | (_| | | (_| | |  | |_| | || (_| | (__| |_\__ \
 \______\___/| .__/ \__, |  \__\___/  |_.__/ \__,_|_|_|\__,_|  \__,_|_|   \__|_|_| \__,_|\___|\__|___/
             | |     __/ |
             |_|    |___/
Files in build artifacts folder:
TestResults.xml (57 bytes)
Apps\NavBiz d.o.o._NavBiz Localization for Croatia_1.1.20240911.210724.app (10328 bytes)
TestApps\NavBiz d.o.o._NavBiz Localization for Croatia_1.1.20240911.210724.app (10328 bytes)

Copying to Build Artifacts took 0 seconds

AL Pipeline finished in 153 seconds

##[command]AL Pipeline: 154 seconds

##[command]Script duration: 261 seconds
...

Screenshots image image image image

Additional context

freddydk commented 6 days ago

Yeah, that scenario is not supported, and I have no plans of changing things to support it. Recommendation would be to include test in the name of the test app or like.