microsoft / navcontainerhelper

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

Sort-AppFoldersByDependencies breaks without a dependency object in app.json #2921

Closed LDoege closed 1 year ago

LDoege commented 1 year ago

Hi Freddy, we use the sort appfolders function to build multiple apps for our customer releases and never really had issues with it as there was alsways atleast a Microsoft dependency present in the app.json. With plattform and application moving to their own tokens it might be the case now that some apps will have no dependency at all.

This will break the function with either

##[error]ForEach-Object : Exception setting "dependencies": "The property 'dependencies' cannot be found on this object. Verify 
that the property exists and can be set."

if there is no dependencies object or for the missing dependencies.Name property if adding "dependencies": [{}],

##[error]% : The property 'Name' cannot be found on this object. Verify that the property exists.
At C:\Program 
Files\WindowsPowerShell\Modules\BcContainerHelper\4.0.14\AppHandling\Sort-AppFoldersByDependencies.ps1:55 char:71
+ ...                 $appJson.dependencies = @($appJson.dependencies | % {
+                                                                       ~~~
    + CategoryInfo          : InvalidOperation: (:) [ForEach-Object], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFoundStrict,Microsoft.PowerShell.Commands.ForEachObjectCommand

For now we could get around adding the Microsoft dependencies back in and getting a warning but it´s still an issue i guess.

Thanks for your work! Makes our life easier every day

edit: "dependencies": [], works too.

freddydk commented 1 year ago

Should not fail without dependencies:-)

freddydk commented 1 year ago

Sorry for the very late reply here, but I cannot make this fail. Not with an app.json without dependencies or with empty dependencies. If you still have this issue, any chance you can send me the app.json file(s) which provokes the problem to freddyk at microsoft dot com, thanks