Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile-AppWithBcCompilerFolder, ALTool returns dependencies.appId for older apps #3701

Open
MODUSCarstenScholling opened this issue Oct 4, 2024 · 4 comments

Comments

@MODUSCarstenScholling
Copy link
Contributor

Describe the issue
Compile-AppWithBcCompilerFolder, ALTool returns dependencies.appId for older apps instead of dependencies.id. I have an example from May 2022, a third party app I cannot change.

I cannot say if this is expected from ALTool or a problem there. However, it causes errors when Compile-AppWithBcCompilerFolder is used.

Partial output of scripts

[...]
BcContainerHelper version 6.0.25
BC.HelperFunctions emits usage statistics telemetry to Microsoft
[...]
Getting .app info C:\BuildAgents\MC21\_work\2406\s\.alpackages-8cbe5d9a-64e8-4ad1-b059-fbd52596ae47\cache_AppInfo.json
- Kies Systems GmbH_KS Mobility Suite_21.4.34.0_app.appCompile-AppWithBcCompilerFolder Telemetry Correlation Id: 7f255564-d58b-4fea-b84b-40b6cf5b3b9c
The property 'id' cannot be found on this object. Verify that the property exists. at <ScriptBlock>, C:\Users\mc\Documents\PowerShell\Modules\BcContainerHelper\6.0.24\HelperFunctions.ps1: line 1127
at GetAppInfo, C:\Users\mc\Documents\PowerShell\Modules\BcContainerHelper\6.0.24\HelperFunctions.ps1: line 1127
at Compile-AppWithBcCompilerFolder, C:\Users\mc\Documents\PowerShell\Modules\BcContainerHelper\6.0.24\CompilerFolderHandling\Compile-AppWithBcCompilerFolder.ps1: line 181
at <ScriptBlock>, C:\BcBuild\MC21\execute.ps1: line 1148
at <ScriptBlock>, C:\BcBuild\MC21\execute.ps1: line 1143
at <ScriptBlock>, C:\BcBuild\MC21\execute.ps1: line 782
at <ScriptBlock>, C:\BuildAgents\MC21\_work\_temp\7e677b82-2222-4535-aacf-3ab843a67a87.ps1: line 4
at <ScriptBlock>, <No file>: line 1
##[error]ForEach-Object : The property 'id' cannot be found on this object. Verify that the property exists.
At C:\Users\mc\Documents\PowerShell\Modules\BcContainerHelper\6.0.24\HelperFunctions.ps1:1127 char:136
[...]

Working, compiled in October 2024

{
  "id": "ba5e92a6-b5c1-471d-ad51-1f407e627c27",
[...]
  "runtime": "13.0",
  "target": "Cloud",
  "application": "24.3.0.0",
  "platform": "24.0.0.0",
[...]
  "dependencies": [
    {
      "id": "d78da1d4-e45e-479e-9bb3-c368752fb48f",
      "name": "MODUS M365 Foundation",
      "version": "24.1.24082101.24082101",
      "publisher": "MODUS Consult GmbH"
    }
  ],
[...]
  "build": {
    "by": "AL Language Extension,15.0.1143290",
    "timestamp": "2024-10-01T14:09:57.9681148+02:00",
    "compilerVersion": "15.0.17.29212"
  }
}

NOT working, compiled in May 2022

{
  "id": "99c768dc-ae71-4385-97e8-bcc928d13c64",
  "runtime": "3.0",
  "target": "Internal",
  "application": "14.0.0.0",
  "platform": "14.0.0.0",
[...]
  "dependencies": [
    {
      "appId": "04d84083-a4ae-4051-b22b-5483a70bb119",
      "name": "KS Version Handling",
      "version": "14.0.0.3",
      "publisher": "Kies Systems GmbH"
    }
  ],
[...]
}

Original code in HelperFunctions.ps1

                if ($alToolExists) {
                    $arguments = @('GetPackageManifest', """$path""")
                    if ($alToolDll) {
                        $arguments = @($alToolDll) + $arguments
                    }
                    $manifest = CmdDo -Command $command -arguments $arguments -returnValue -silent | ConvertFrom-Json
                    $appInfo = @{
                        "appId"                 = $manifest.id
                        "publisher"             = $manifest.publisher
                        "name"                  = $manifest.name
                        "version"               = $manifest.version
                        "application"           = "$(if($manifest.PSObject.Properties.Name -eq 'application'){$manifest.application})"
                        "platform"              = "$(if($manifest.PSObject.Properties.Name -eq 'platform'){$manifest.Platform})"
                        "propagateDependencies" = ($manifest.PSObject.Properties.Name -eq 'PropagateDependencies') -and $manifest.PropagateDependencies
                        "dependencies"          = @(if($manifest.PSObject.Properties.Name -eq 'dependencies'){$manifest.dependencies | ForEach-Object { @{ "id" = $_.id; "name" = $_.name; "publisher" = $_.publisher; "version" = $_.version }}})
                    }
                    Write-Host " (succeeded using altool)"
                }
@freddydk
Copy link
Contributor

freddydk commented Oct 4, 2024

ALTool probably just returns what the app was compiled with.
Will investigate

@freddydk
Copy link
Contributor

freddydk commented Oct 4, 2024

If you replace the dependencies line with this:

"dependencies" = @(if($manifest.PSObject.Properties.Name -eq 'dependencies'){$manifest.dependencies | ForEach-Object { if ($_.ContainsKey('id')) { $id = $_.id } else { $id = $_.AppId }; @{ "id" = $id; "name" = $_.name; "publisher" = $_.publisher; "version" = $_.version }}})

does that solve the problem (I don't have an "old" app handy)

@MODUSCarstenScholling
Copy link
Contributor Author

dependencies is not a hashtable but a PSCustomObject. The following code works:

"dependencies" = @(if($manifest.PSObject.Properties.Name -eq 'dependencies'){$manifest.dependencies | ForEach-Object { ($_.PSObject.Properties.Name -icontains 'id') { $id = $_.id } else { $id = $_.appId }; @{ "id" = $id; "name" = $_.name; "publisher" = $_.publisher; "version" = $_.version }}})

freddydk added a commit that referenced this issue Oct 4, 2024
@freddydk
Copy link
Contributor

freddydk commented Oct 6, 2024

Should be fixed in preview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants