microsoft / navcontainerhelper

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

The property 'Name' cannot be found on this object. Verify that the property exists. #1677

Closed andreassallstrom closed 3 years ago

andreassallstrom commented 3 years ago

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

Describe the issue The compiling part of my pipeline script fails.

Scripts used to create container and cause the issue

Here's my Pipeline-script:

Param(    
    [Parameter(Mandatory=$true)]
    [string] $BuildFolder,
    [Parameter(Mandatory=$true)]
    [string] $ArtifactsBuildFolder
)

$settings = (Get-Content (Join-Path $PSScriptRoot "\settings.json") | ConvertFrom-Json)
$currentArtifactUrl = Get-BcArtifactUrl -type $settings.CurrentVersionArtifactURLType -version $settings.CurrentVersionArtifactURLVersion -country $settings.CurrentVersionArtifactURLCountry -select $settings.CurrentVersionArtifactURLSelect

$bcContainerHelperVersion = "latest"
if ($settings.PSObject.Properties.Name -eq 'bcContainerHelperVersion' -and $settings.bcContainerHelperVersion) {
    $bcContainerHelperVersion = $settings.bcContainerHelperVersion
}
Write-Host "Use bcContainerHelper Version: $bcContainerHelperVersion"
. (Join-Path $PSScriptRoot "Install-BcContainerHelper.ps1") -bcContainerHelperVersion $bcContainerHelperVersion

$testResultsFile = Join-Path $BuildFolder "CurrentTestResults.xml"
if (Test-Path $testResultsFile) {
    Remove-Item $testResultsFile -Force
}

Write-Host "Running pipeline for current version ($($settings.CurrentVersionArtifactURLVersion))"
Run-AlPipeline `
    -pipelineName $settings.CurrentVersionPipelineName `
    -artifact $currentArtifactUrl `
    -licenseFile $settings.CurrentVersionLicenseFile `
    -baseFolder $BuildFolder `
    -appFolders @("app") `
    -testFolders @("test") `
    -installTestFramework `
    -testResultsFile $testResultsFile `
    -buildArtifactFolder $ArtifactsBuildFolder `
    -testResultsFormat 'JUnit' `
    -enableCodeCop `
    -enablePerTenantExtensionCop `
    -enableUICop `
    -azureDevOps

Write-Host "##vso[task.setvariable variable=TestResults]$testResultsFile"

Full output of scripts And this is the failing part:

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

Creating container took 134 seconds

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

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

Removing container currentversion-bld
Removing currentversion-bld from host hosts file
Removing currentversion-bld-* from host hosts file
Removing C:\ProgramData\BcContainerHelper\Extensions\currentversion-bld

Removing container took 3 seconds
##[error]Where-Object : The property 'Name' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.5\AppHandling\Sort-AppFoldersByDependencies.ps1:103
 char:13

+     $apps | Where-Object { $_.Name -eq "Application" } | ForEach-Obje ...

+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Where-Object], PropertyNotFoundException

    + FullyQualifiedErrorId : PropertyNotFoundStrict,Microsoft.PowerShell.Commands.WhereObjectCommand

##[error]PowerShell exited with code '1'.

Screenshots Here's a part of the app.json file. bild

Additional context I'm guessing the problem is that "Application" has been moved out of the dependencies section so it doesn't have any child node called "Name" anymore. I tried adding back Application as a dependency even though the CodeCop advised me not to, but it still fails since it hits the outer Application first.

Thoughts on how to get past this?

freddydk commented 3 years ago

It sounds like there is an app.json file without a name property. Could you include or email me the full app.json?

andreassallstrom commented 3 years ago

This problem was that no app.json existed inside the app and test folders.