HodorNV / ALOps

ALOps
59 stars 24 forks source link

ALOpsAppCompiler V1 and NextMajor: You must install or update .NET to run this application. #709

Closed DanielGoehler closed 11 months ago

DanielGoehler commented 11 months ago

Describe the bug When you compile your application with ALOpsAppCompiler version 1 in the NextMajor Container, you get the error message You must install or update .NET to run this application.

For ALOpsAppCompiler version 2, where NextMajor also failed, we installed .NET 8.0 Runtime on each build agent, but I guess it is also missing in Docker Container.

the used yaml please provide the yaml that you used. It helps you put the yaml like this:

name: $(Build.BuildId)

# trigger:
#  branches:
#    include:
#      - master
#      - main

variables:
- group: 'Secrets'  # link to a variable group that has secret variables, like URL to license file, or sasToken for insider builds

pool: HOD-DOCKER

steps:
- checkout: self
  clean: true 

- task: ALOpsDockerCreate@1
  displayName: 'Create Docker Image' # It will reuse the image if already exists, or build one if it doesn't.
  inputs:
    artifactcountry: 'de'
    artifacttype: Sandbox
    versionselect: NextMajor
    accept_insider_eula: true

- task: ALOpsDockerStart@1
  displayName: 'Start Docker Container' # No need to provide any details - it will get the details from previous step

- task: ALOpsDockerWait@1
  displayName: 'Wait for Docker Container to start'
  inputs:
    search_string: 'Ready for connections!'

- task: ALOpsAppCompiler@1
  displayName: 'App Compiler'
  inputs:
    usedocker: true
    targetproject: 'MainApp/app.json'
    al_analyzer: 'AppSourceCop,CodeCop,PerTenantExtensionCop,UICop'
    nav_app_version: '?.?.*.0'
    publish_artifact: false

- task: ALOpsDockerRemove@1
  displayName: 'Remove Docker Container'
  enabled: true
  condition: always()

the output Also the complete output is necessary for us to see what is going on. Also use backtics:

##[section]Starting: App Compiler
==============================================================================
Task         : ALOps App Compiler
Description  : Compile AL Extensions for Business Central
Version      : 1.461.5079
Author       : Hodor
Help         : Compile a Business Central extension from AL code.
==============================================================================
*** Validate configuration
*** Task Inputs:

name                                                                                        value
----                                                                                        -----
usedocker                                                                                    True
fixed_tag                                                                                        
targetproject                                               C:\agent\_work\708\s\MainApp\app.json
nav_computername                                                                                 
nav_serverinstance                                                                          BC140
nav_tenant                                                                                default
nav_ports_dev                                                                                7049
bc_username                                                                                      
bc_password                                                                                      
al_compiler_version                                                                    0.12.15355
ruleset                                                                                          
suppresswarnings                                                                             KEEP
al_analyzer                                      AppSourceCop,CodeCop,PerTenantExtensionCop,UICop
ignorepragmas                                                                                    
nav_app_version                                                                           ?.?.*.0
vsix_download_path                                                                               
use_ssl                                                                                     False
download_test_symbols                                                                       False
usecompression                                                                               True
publish_artifact                                                                            False
publishxlif                                                                                 False
failed_on_warnings                                                                          False
app_file_suffix                                                                                  
updatebuildnumber                                                                            True
setup_working_folder                                                                        False
showmycode                                                                                   Keep
resourceexposurepolicy_allowdebugging                                                        Keep
resourceexposurepolicy_allowdownloadingsource                                                Keep
resourceexposurepolicy_includesourceinsymbolfile                                             Keep
internalsvisibleto                                                                           Keep
preprocessorsymbols                                                                              
applicationinsightskey                                                                           
printappmanifest                                                                             True
output_alc_logs                                                                              True
additionalprobingpaths                                                                           
enable_external_rulesets                                                                    False
allowed_publisher_names                                                              Some Company
allowed_publisher_names_separator                                                               ,

*** For documentation, please visit   : https://www.alops.be/documentation

*** ALOps License:
  * Licensed To: Some Company (Organisation License)

*** Importing required PS-Functions
*** Initiate Docker Session
*** Set Docker Container ErrorActionPreference = Stop
*** Import NAV/BC Management DLL's [False]
*** Loading assemblies for ServiceTier [BC].
*** Loading assemblies from: [C:\program files\microsoft dynamics nav\240\service]
*** Selected module: [C:\program files\microsoft dynamics nav\240\service\Management\Microsoft.Dynamics.Nav.Management.dll]
*** Loading module: [C:\program files\microsoft dynamics nav\240\service\Management\Microsoft.Dynamics.Nav.Management.dll]
*** Selected module: [C:\program files\microsoft dynamics nav\240\service\Management\Microsoft.Dynamics.Nav.Apps.Management.dll]
*** Loading module: [C:\program files\microsoft dynamics nav\240\service\Management\Microsoft.Dynamics.Nav.Apps.Management.dll]
*** Setting up AL Compiler [ALLanguage]
*** Downloading AL Compiler [ALLanguage]
*** Get Extension from Local-Disk...[C:\Run\ALLanguage.vsix]
*** Resolving Path [C:\Run\ALLanguage.vsix]
*** VSIX Path Resolved: [C:\Run\ALLanguage.vsix]
*** Unpacking Extension to folder...
*** Loading Json Object: [c:\Run\Microsoft.al\al-ALLanguage\extension\package.json]
*** Using AL Compiler [vALLanguage] located [C:\Run\Microsoft.al\al-ALLanguage\extension\bin\win32\alc.exe]
***
*** Working folder: C:\agent\_work\708\s
***
*** Copy Working folder to Docker Container: 0bf41dc0d8d2bc0578647867bccfb923b2dc7b2fe32a79f8c156d28dc606f390
*** Docker Working Folder: c:\Run\DevOps\
*** Copy from [C:\agent\_work\708\s] to [c:\Run\DevOps\]
*** Source File setup completed
*** Target Project: \MainApp\app.json
*** Check for app.json files: c:\Run\DevOps\
*** Multiple projects found:
   - C:\Run\DevOps\MainApp
   - C:\Run\DevOps\TestApp
*** Retrieving App-Info [\MainApp\app.json]
*** Loading Json Object: [c:\Run\DevOps\MainApp\app.json]
  * App.ID          = e69679ff-2237-491c-bf45-17a4693c4a73
  * App.Name        = XXX-BaseApp
  * App.Publisher   = Some Company
  * App.Version     = 1.0.0.0
  * App.Platform    = 1.0.0.0
  * App.Application = 22.0.0.0
*** Check for Allowed Publishers: Some Company
*** Check Runtime: [11.0]
***
*** Retaining original [Major] from version (?.0.0.0)
*** Retaining original [Minor] from version (0.?.0.0)
*** Setting Managed App Version [c:\Run\DevOps\MainApp\app.json] =>  1.0.42281.0
*** Final app.json:
{
    "id":  "e69679ff-2237-491c-bf45-17a4693c4a73",
    "name":  "XXX-BaseApp",
    "publisher":  "Some Company",
    "version":  "1.0.42281.0",
    "brief":  "XXX BaseApp",
    "description":  "XXX für die Entwicklung einer App",
    "privacyStatement":  "https://www.prisma-informatik.de/impressum",
    "EULA":  "https://www.prisma-informatik.de/impressum",
    "help":  "https://www.prisma-informatik.de/support",
    "url":  "https://www.prisma-informatik.de",
    "logo":  "./res/Logo.jpg",
    "dependencies":  [

                     ],
    "screenshots":  [

                    ],
    "platform":  "1.0.0.0",
    "application":  "22.0.0.0",
    "idRanges":  [
                     {
                         "from":  50000,
                         "to":  50999
                     }
                 ],
    "resourceExposurePolicy":  {
                                   "allowDebugging":  true,
                                   "allowDownloadingSource":  false,
                                   "includeSourceInSymbolFile":  false
                               },
    "runtime":  "11.0",
    "target":  "Cloud",
    "contextSensitiveHelpUrl":  "https://support.prisma-informatik.de/{0}/",
    "supportedLocales":  [
                             "de-DE",
                             "en-US"
                         ],
    "features":  [
                     "NoImplicitWith",
                     "TranslationFile"
                 ]
}

***
*** Working Direcotry: [c:\Run\DevOps\]
*** Target Project: [\MainApp\app.json]
*** Project Directory: [c:\Run\DevOps\MainApp]
*** VSCode Settings: [c:\Run\DevOps\MainApp\.vscode\settings.json]
*** VSCode-Settings json found.
*** Loading Json Object: [c:\Run\DevOps\MainApp\.vscode\settings.json]
*** Using Ruleset: [c:\Run\DevOps\MainApp\.vscode\ruleset.json]
***
*** Resolve Docker Credentials
*** Setup BC Username/Password from Container info
*** Download Symbols
*** Working Dir: c:\Run\DevOps\
*** Load Code-Analysis from VSIX Folder
*** Loading assemblies from: [C:\Run\Microsoft.al\al-ALLanguage\extension\bin]
*** Loading: [C:\Run\Microsoft.al\al-ALLanguage\extension\bin\Analyzers\Microsoft.Dynamics.Nav.CodeAnalysis.dll]
*** PackageCache path created [c:\Run\DevOps\PackageCache]
***
*** Download System-Symbols for [1.0.0.0]
*** Downloading NAV Symbols for [System v1.0.0.0]
*** Downloading NAV Symbols from [https://0bf41dc0d8d2:7049/BC/dev/packages?publisher=Microsoft&appName=System&versionText=1.0.0.0&tenant=default]
*** Downloading NAV Symbols with BasicAuthentication [admin]
##[command]Invoke-RestMethod -Method Get -Uri https://0bf41dc0d8d2:7049/BC/dev/packages?publisher=Microsoft&appName=System&versionText=1.0.0.0&tenant=default
*** Content-Disposition: attachment; filename=Microsoft_System_24.0.14715.0.app; filename*=UTF-8''Microsoft_System_24.0.14715.0.app
*** Saving symbol file [Microsoft_System_24.0.14715.0.app] to [c:\Run\DevOps\PackageCache]
*** Read App Manifest: [c:\Run\DevOps\PackageCache\Microsoft_System_24.0.14715.0.app].
***
*** Download Application-Symbols for [22.0.0.0]
*** Downloading NAV Symbols for [Application v22.0.0.0]
*** Downloading NAV Symbols from [https://0bf41dc0d8d2:7049/BC/dev/packages?publisher=Microsoft&appName=Application&versionText=22.0.0.0&tenant=default]
*** Downloading NAV Symbols with BasicAuthentication [admin]
##[command]Invoke-RestMethod -Method Get -Uri https://0bf41dc0d8d2:7049/BC/dev/packages?publisher=Microsoft&appName=Application&versionText=22.0.0.0&tenant=default
*** Content-Disposition: attachment; filename=Microsoft_Application_24.0.14731.0.app; filename*=UTF-8''Microsoft_Application_24.0.14731.0.app
*** Saving symbol file [Microsoft_Application_24.0.14731.0.app] to [c:\Run\DevOps\PackageCache]
*** Read App Manifest: [c:\Run\DevOps\PackageCache\Microsoft_Application_24.0.14731.0.app].
*** Propagated Dependency: Microsoft - System Application - 24.0.0.0
*** Propagated Dependency: Microsoft - Base Application - 24.0.0.0
***
*** Check for Depency Apps 2
*** Download Application-Symbols for [System Application v24.0.0.0]
*** Downloading NAV Symbols for [System Application v24.0.0.0]
*** Downloading NAV Symbols from [https://0bf41dc0d8d2:7049/BC/dev/packages?publisher=Microsoft&appName=System+Application&versionText=24.0.0.0&tenant=default&appid=63ca2fa4-4f03-4f2b-a480-172fef340d3f]
*** Downloading NAV Symbols with BasicAuthentication [admin]
##[command]Invoke-RestMethod -Method Get -Uri https://0bf41dc0d8d2:7049/BC/dev/packages?publisher=Microsoft&appName=System+Application&versionText=24.0.0.0&tenant=default&appid=63ca2fa4-4f03-4f2b-a480-172fef340d3f
*** Content-Disposition: attachment; filename="Microsoft_System Application_24.0.14731.0.app"; filename*=UTF-8''Microsoft_System%20Application_24.0.14731.0.app
*** Saving symbol file [Microsoft_System Application_24.0.14731.0.app] to [c:\Run\DevOps\PackageCache]
*** Read App Manifest: [c:\Run\DevOps\PackageCache\Microsoft_System Application_24.0.14731.0.app].
***
*** Download Application-Symbols for [Base Application v24.0.0.0]
*** Downloading NAV Symbols for [Base Application v24.0.0.0]
*** Downloading NAV Symbols from [https://0bf41dc0d8d2:7049/BC/dev/packages?publisher=Microsoft&appName=Base+Application&versionText=24.0.0.0&tenant=default&appid=437dbf0e-84ff-417a-965d-ed2bb9650972]
*** Downloading NAV Symbols with BasicAuthentication [admin]
##[command]Invoke-RestMethod -Method Get -Uri https://0bf41dc0d8d2:7049/BC/dev/packages?publisher=Microsoft&appName=Base+Application&versionText=24.0.0.0&tenant=default&appid=437dbf0e-84ff-417a-965d-ed2bb9650972
*** Content-Disposition: attachment; filename="Microsoft_Base Application_24.0.14731.0.app"; filename*=UTF-8''Microsoft_Base%20Application_24.0.14731.0.app
*** Saving symbol file [Microsoft_Base Application_24.0.14731.0.app] to [c:\Run\DevOps\PackageCache]
*** Read App Manifest: [c:\Run\DevOps\PackageCache\Microsoft_Base Application_24.0.14731.0.app].
***
*** Starting AL Compiler...
*** App.Name         = XXX-BaseApp
*** App.Publisher    = Some Company
*** App.Compiler Path= C:\Run\Microsoft.al\al-ALLanguage\extension\bin\win32\alc.exe
*** Checking for Assemblies in App
*** Add Windows Assembly Path [C:\Windows\assembly]
*** Searching CodeCop: AppSourceCop
*** Codecop found: C:\run\microsoft.al\al-allanguage\extension\bin\Analyzers\Microsoft.Dynamics.Nav.AppSourceCop.dll
*** Searching CodeCop: CodeCop
*** Codecop found: C:\run\microsoft.al\al-allanguage\extension\bin\Analyzers\Microsoft.Dynamics.Nav.CodeCop.dll
*** Searching CodeCop: PerTenantExtensionCop
*** Codecop found: C:\run\microsoft.al\al-allanguage\extension\bin\Analyzers\Microsoft.Dynamics.Nav.PerTenantExtensionCop.dll
*** Searching CodeCop: UICop
*** Codecop found: C:\run\microsoft.al\al-allanguage\extension\bin\Analyzers\Microsoft.Dynamics.Nav.UICop.dll
*** Detect ALC.EXE Features.
##[command]& C:\Run\Microsoft.al\al-ALLanguage\extension\bin\win32\alc.exe /?
##[error]You must install or update .NET to run this application.
##[section]Async Command Start: Add Build Tag
Build '42281' has following tags now: AL.Compiler.ALLanguage, AL.Analyzer.PerTenantExtensionCop, AL.Analyzer.UICop, AL.Analyzer.CodeCop, AL.Analyzer.AppSourceCop, myimage-sandbox-24.0.14731.0-de-10.0.17763.5122-ltsc2019, BC.Version.24.0.14731.0, BC.Platform.24.0.14715.0
##[section]Async Command End: Add Build Tag
##[section]Async Command Start: Update Build Number
Update build number to 1.0.42281.0 for build 42281
##[section]Async Command End: Update Build Number
##[section]Async Command Start: Add Build Tag
Build '42281' has following tags now: AL.Compiler.ALLanguage, AL.Analyzer.PerTenantExtensionCop, AL.Analyzer.UICop, AL.Analyzer.CodeCop, AL.Analyzer.AppSourceCop, myimage-sandbox-24.0.14731.0-de-10.0.17763.5122-ltsc2019, BC.Version.24.0.14731.0, BC.Platform.24.0.14715.0
##[section]Async Command End: Add Build Tag
##[section]Async Command Start: Add Build Tag
Build '42281' has following tags now: AL.Compiler.ALLanguage, AL.Analyzer.PerTenantExtensionCop, AL.Analyzer.UICop, AL.Analyzer.CodeCop, AL.Analyzer.AppSourceCop, myimage-sandbox-24.0.14731.0-de-10.0.17763.5122-ltsc2019, BC.Version.24.0.14731.0, BC.Platform.24.0.14715.0
##[section]Async Command End: Add Build Tag
##[section]Async Command Start: Add Build Tag
Build '42281' has following tags now: AL.Compiler.ALLanguage, AL.Analyzer.PerTenantExtensionCop, AL.Analyzer.UICop, AL.Analyzer.CodeCop, AL.Analyzer.AppSourceCop, myimage-sandbox-24.0.14731.0-de-10.0.17763.5122-ltsc2019, BC.Version.24.0.14731.0, BC.Platform.24.0.14715.0
##[section]Async Command End: Add Build Tag
##[section]Async Command Start: Add Build Tag
Build '42281' has following tags now: AL.Compiler.ALLanguage, AL.Analyzer.PerTenantExtensionCop, AL.Analyzer.UICop, AL.Analyzer.CodeCop, AL.Analyzer.AppSourceCop, myimage-sandbox-24.0.14731.0-de-10.0.17763.5122-ltsc2019, BC.Version.24.0.14731.0, BC.Platform.24.0.14715.0
##[section]Async Command End: Add Build Tag
##[section]Finishing: App Compiler
waldo1001 commented 11 months ago

We analyzed BCCH. Yet another "hardcoded exception" .. one of many 🤔.
image

And it also seems solved with new generic image, but that doesn't exist yet.

Is it ok for you to wait for the new generic? meanwhile, you could add a "DockerExec" step to install it, something like:

Write-Host "Patching container to install dotnet 8.0.0"
Invoke-WebRequest -Uri "[https://download.visualstudio.microsoft.com/download/pr/2a7ae819-fbc4-4611-a1ba-f3b072d4ea25/32f3b931550f7b315d9827d564202eeb/dotnet-hosting-8.0.0-win.exe"](https://download.visualstudio.microsoft.com/download/pr/2a7ae819-fbc4-4611-a1ba-f3b072d4ea25/32f3b931550f7b315d9827d564202eeb/dotnet-hosting-8.0.0-win.exe%22) `
                  -UseBasicParsing `
                  -OutFile "c:\run\my\dotnet-win8.exe"    
Start-Process -Wait -FilePath "c:\run\my\dotnet-win8.exe" -ArgumentList /quiet
Remove-Item "c:\run\my\dotnet-win8.exe" -Confirm:$false -Force:$true
DanielGoehler commented 11 months ago

Thank you! :-) Sure, this temporary solution is enough for us. We added it after creating the Docker container. The compiler works fine now.

We also expect that .NET 8 is added to the generic image.

[...]
- task: ALOpsDockerStart@1
  displayName: 'Start Docker Container'
  inputs:
    memory_gb: '8'

- task: ALOpsDockerWait@1
  displayName: 'Wait for Docker Container'
  inputs:
    search_string: 'Ready for connections!'

- template: InstallNet8.yml # Temp. Fix: Install .NET 8 in Docker Container
  parameters:
    selectVersion: '${{selectVersion}}'

- task: ALOpsAppCompiler@1
  displayName: 'App Compiler'
  inputs:
    usedocker: true
    targetproject: 'MainApp/app.json'
    al_analyzer: '${{parameters.alcodeanalyzer}}'
    nav_app_version: '${{parameters.appversiontemplate}}'
    publish_artifact: false
[...]

InstallNet8.yml

parameters:
  selectVersion: ''

steps:
  - task: ALOpsDockerExec@1
    displayName: 'Install DotNet 8 in Docker Container'
    condition: eq('${{parameters.selectVersion}}', 'NextMajor')
    inputs:
      inline_script: |
        Write-Host "Patching container to install dotnet 8.0.0"
        Invoke-WebRequest -Uri "https://download.visualstudio.microsoft.com/download/pr/2a7ae819-fbc4-4611-a1ba-f3b072d4ea25/32f3b931550f7b315d9827d564202eeb/dotnet-hosting-8.0.0-win.exe" `
                          -UseBasicParsing `
                          -OutFile "c:\run\my\dotnet-win8.exe"
        Start-Process -Wait -FilePath "c:\run\my\dotnet-win8.exe" -ArgumentList /quiet
        Remove-Item "c:\run\my\dotnet-win8.exe" -Confirm:$false -Force:$true