HodorNV / ALOps

ALOps
56 stars 24 forks source link

ALOpsAppCompiler: error generating app file #126

Closed Miki-84 closed 3 years ago

Miki-84 commented 4 years ago

Hello,

I am trying to compile my AL project using the ALOpsAppCompiler step.

When compiling and executing alc.exe in the agent it fails with the following error:

*** Starting AL Compiler...
*** App.Name         = Base SM
*** App.Publisher    = Inforolot
*** App.Compiler Path= C:\Run\Microsoft.al\al-ALLanguage\extension\bin\alc.exe
*** Checking for Assemblies in App
*** Add Windows Assembly Path [C:\Windows\assembly]
**& C:\Run\Microsoft.al\al-ALLanguage\extension\bin\alc.exe /packagecachepath:"c:\Run\DevOps\PackageCache" /project:"c:\Run\DevOps\AL\Base" /out:"c:\Run\DevOps\Inforolot_Base SM_1.0.159.0.app" /fullpaths /ruleset:"c:\Run\DevOps\AL\Base\.vscode\io.ruleset.json" /assemblyprobingpaths:C:\Windows\assembly
*** AL Compiler Exit Code: -1073741502**
*** AL Compiler raw logs: Start

*** AL Compiler raw logs: End
*** Start processing compile results.
*** Compile OK.
*** Start processing compile results done.
*** Transfer App Artifact from Docker container.
##[error]No se encuentra la ruta de acceso 'c:\Run\DevOps\Inforolot_Base SM_1.0.159.0.app' porque no existe.

If I try to execute the same alc.exe instruction locally in the machine then it works and generates the .app correctly:

PS C:\temp\extension\bin> .\alc.exe /packagecachepath:"c:\Temp\dependencies" /project:"C:\Projects\vsCode\SuperMontserratMigracio\AL\Base" /out:"c:\Temp\Inforolot_Base SM_1.0.157.0.app" /fullpaths /ruleset:"C:\Projects\vsCode\SuperMontserratMigracio\AL\Base\.vscode\io.ruleset.json" /assemblyprobingpaths:"C:\Windows\assembly"
Microsoft (R) AL Compiler version 5.0.3.53059
Copyright (C) Microsoft Corporation. All rights reserved

Compilation started for project 'Base SM' containing '21' files at '18:7:6.602'.

C:\Projects\vsCode\SuperMontserratMigracio\AL\Base\src\PermissionSet.xml(1,1): info AL1027: The file at location 'C:\Projects\vsCode\SuperMontserratMigracio\AL\Base\src\PermissionSet.xml' matches the definition for 'PermissionSet'.

Compilation ended at '18:7:15.744'.

My pipeline configuration is as follow:

- task: ALOpsDockerStart@1
  inputs:
    fixed_tag: 'SMPipeline'
    docker_image: 'mcr.microsoft.com/businesscentral/onprem:es'
    accept_image_outdated: true

- task: ALOpsDockerWait@1
  inputs:
    fixed_tag: 'SMPipeline'
    search_string: 'Ready for connections!'

- task: ALOpsAppCompiler@1
  inputs:
    usedocker: true
    fixed_tag: 'SMPipeline'
    targetproject: 'AL/Base/app.json'
    nav_app_version: '1.0.*.0'
    setup_working_folder: true

And the complete log of the compilation step is:

2020-05-04T15:11:40.1382368Z ##[section]Starting: ALOpsAppCompiler
2020-05-04T15:11:40.1738881Z ==============================================================================
2020-05-04T15:11:40.1739525Z Task         : ALOps App Compiler
2020-05-04T15:11:40.1739986Z Description  : Compiles NAV Apps
2020-05-04T15:11:40.1740402Z Version      : 1.429.1393
2020-05-04T15:11:40.1740809Z Author       : Hodor
2020-05-04T15:11:40.1741348Z Help         : Compile a Business Central extension from AL code.
2020-05-04T15:11:40.1742014Z ==============================================================================
2020-05-04T15:11:46.9917764Z *** Validate configuration
2020-05-04T15:11:47.3290360Z *** No ALOps License found. Set License with the [alops-licenseid] or [alops_licenseid] variables.
2020-05-04T15:11:48.0763611Z Cleanup old Tasks
2020-05-04T15:11:48.4795274Z *** Importing required PS-Functions
2020-05-04T15:11:52.7097719Z *** Initiate Docker Session
2020-05-04T15:11:53.5920289Z *** Set Docker Container ErrorActionPreference = Stop
2020-05-04T15:11:56.9764277Z *** Import NAV/BC Management DLL's
2020-05-04T15:11:56.9804557Z *** Loading assemblies for ServiceTier [BC].
2020-05-04T15:12:13.7084136Z *** Loadin assemblies from: [C:\program files\microsoft dynamics nav\160\service]
2020-05-04T15:12:15.9385570Z *** Setting up AL Compiler [ALLanguage]
2020-05-04T15:12:16.8494152Z *** Using AL Compiler [vALLanguage] located [C:\Run\Microsoft.al\al-ALLanguage\extension\bin\alc.exe]
2020-05-04T15:12:16.8501994Z ***
2020-05-04T15:12:16.8512351Z *** Working folder: C:\agent\_work\3\s
2020-05-04T15:12:16.8521602Z ***
2020-05-04T15:12:16.8530650Z *** Copy Working folder to Docker Container: 157039e99d825eab73058d11ae9107caf553315f76ca05cbedad3a35b372eafc
2020-05-04T15:12:16.8536445Z *** Docker Working Folder: c:\Run\DevOps\
2020-05-04T15:12:16.8561355Z *** Copy from [C:\agent\_work\3\s] to [c:\Run\DevOps\]
2020-05-04T15:12:17.0215174Z *** Compression Enabled Transfer
2020-05-04T15:12:17.0373296Z *** Compress Source Files
2020-05-04T15:12:21.0730139Z *** Transfer compressed Archive to session
2020-05-04T15:12:22.2838274Z *** Expand source files in target session
2020-05-04T15:12:25.3987696Z *** Source File setup completed
2020-05-04T15:12:25.6769776Z *** Target Project: \AL\Base\app.json
2020-05-04T15:12:25.7222227Z *** Check for app.json files: c:\Run\DevOps\
2020-05-04T15:12:25.7357290Z *** Multiple projects found:
2020-05-04T15:12:25.7422824Z    - C:\Run\DevOps\AL\Base
2020-05-04T15:12:25.7423412Z    - C:\Run\DevOps\AL\CompraFruta
2020-05-04T15:12:25.7435317Z    - C:\Run\DevOps\AL\EstadisticasProducto
2020-05-04T15:12:25.7462155Z    - C:\Run\DevOps\AL\MejorPrecio
2020-05-04T15:12:25.7471777Z    - C:\Run\DevOps\AL\PermitirFactNegativas
2020-05-04T15:12:25.7474457Z    - C:\Run\DevOps\AL\RegistroVisitas
2020-05-04T15:12:25.7483974Z    - C:\Run\DevOps\AL\REQ06
2020-05-04T15:12:25.7486416Z    - C:\Run\DevOps\AL\SugerenciaCompra
2020-05-04T15:12:25.7495568Z    - C:\Run\DevOps\AL\Template
2020-05-04T15:12:25.7527402Z *** Retrieving App-Info [\AL\Base\app.json]
2020-05-04T15:12:25.7635825Z *** Loading Json Object: [c:\Run\DevOps\AL\Base\app.json]
2020-05-04T15:12:25.8454903Z   * App.ID          = a3ba9aec-3f97-4049-b58d-fa18030b5dc4
2020-05-04T15:12:25.8470315Z   * App.Name        = Base SM
2020-05-04T15:12:25.8494225Z   * App.Publisher   = Inforolot
2020-05-04T15:12:25.8522461Z   * App.Version     = 1.0.0.0
2020-05-04T15:12:25.8546051Z   * App.Platform    = 16.0.0.0
2020-05-04T15:12:25.8590666Z   * App.Application = 
2020-05-04T15:12:25.8633883Z ***
2020-05-04T15:12:26.2360222Z *** Setting Managed App Version [c:\Run\DevOps\AL\Base\app.json] =>  1.0.159.0
2020-05-04T15:12:26.7716623Z ***
2020-05-04T15:12:26.8499885Z *** Working Direcotry: [c:\Run\DevOps\]
2020-05-04T15:12:26.8513476Z *** Target Project: [\AL\Base\app.json]
2020-05-04T15:12:26.8532174Z *** Project Directory: [c:\Run\DevOps\AL\Base]
2020-05-04T15:12:26.8546296Z *** VSCode Settings: [c:\Run\DevOps\AL\Base\.vscode\settings.json]
2020-05-04T15:12:26.8561456Z *** VSCode-Settings json found.
2020-05-04T15:12:26.8572907Z *** Loading Json Object: [c:\Run\DevOps\AL\Base\.vscode\settings.json]
2020-05-04T15:12:26.8666298Z *** Using Ruleset: [c:\Run\DevOps\AL\Base\.vscode\io.ruleset.json]
2020-05-04T15:12:26.8668436Z ***
2020-05-04T15:12:27.5528909Z *** Resolve Docker Credentials
2020-05-04T15:12:27.5702273Z *** Setup BC Username/Password from Container info
2020-05-04T15:12:27.5712564Z *** Download Symbols
2020-05-04T15:12:28.1079955Z *** Working Dir: c:\Run\DevOps\
2020-05-04T15:12:28.5217693Z *** Loadin assemblies from: [C:\program files\microsoft dynamics nav\160\service]
2020-05-04T15:12:29.8170676Z *** PackageCache path created [c:\Run\DevOps\PackageCache]
2020-05-04T15:12:29.8195582Z ***
2020-05-04T15:12:29.8391844Z *** Propagated Dependency: Microsoft - System Application - 16.0.0.0
2020-05-04T15:12:29.8512004Z *** Propagated Dependency: Microsoft - Base Application - 16.0.0.0
2020-05-04T15:12:29.8540580Z *** Download System-Symbols for [16.0.0.0]
2020-05-04T15:12:30.3715574Z *** Downloading NAV Symbols for [System v16.0.0.0]
2020-05-04T15:12:30.3742198Z *** Downloading NAV Symbols from [https://157039e99d82:7049/BC/dev/packages?publisher=Microsoft&appName=System&versionText=16.0.0.0&tenant=default]
2020-05-04T15:12:30.6633790Z *** Downloading NAV Symbols with BasicAuthentication [admin]
2020-05-04T15:12:30.6651289Z ##[command]Invoke-RestMethod -Method Get -Uri https://157039e99d82:7049/BC/dev/packages?publisher=Microsoft&appName=System&versionText=16.0.0.0&tenant=default
2020-05-04T15:12:33.3699695Z *** Content-Disposition: attachment; filename=Microsoft_System_16.0.11233.12061.app
2020-05-04T15:12:33.3934936Z *** Saving symbol file [Microsoft_System_16.0.11233.12061.app] to [c:\Run\DevOps\PackageCache]
2020-05-04T15:12:33.4340147Z *** Read App Manifest: [c:\Run\DevOps\PackageCache\Microsoft_System_16.0.11233.12061.app].
2020-05-04T15:12:34.6082952Z ***
2020-05-04T15:12:34.6102336Z *** Check for Depency Apps 2
2020-05-04T15:12:34.8015606Z *** Download Application-Symbols for [System Application v16.0.0.0]
2020-05-04T15:12:34.8045894Z *** Downloading NAV Symbols for [System Application v16.0.0.0]
2020-05-04T15:12:34.8062868Z *** Downloading NAV Symbols from [https://157039e99d82:7049/BC/dev/packages?publisher=Microsoft&appName=System+Application&versionText=16.0.0.0&tenant=default]
2020-05-04T15:12:34.8097786Z *** Downloading NAV Symbols with BasicAuthentication [admin]
2020-05-04T15:12:34.8113594Z ##[command]Invoke-RestMethod -Method Get -Uri https://157039e99d82:7049/BC/dev/packages?publisher=Microsoft&appName=System+Application&versionText=16.0.0.0&tenant=default
2020-05-04T15:12:34.9890003Z *** Content-Disposition: attachment; filename="Microsoft_System Application_16.0.11240.12076.app"
2020-05-04T15:12:34.9924131Z *** Saving symbol file [Microsoft_System Application_16.0.11240.12076.app] to [c:\Run\DevOps\PackageCache]
2020-05-04T15:12:35.0154551Z *** Read App Manifest: [c:\Run\DevOps\PackageCache\Microsoft_System Application_16.0.11240.12076.app].
2020-05-04T15:12:35.0264095Z ***
2020-05-04T15:12:35.0295803Z *** Download Application-Symbols for [Base Application v16.0.0.0]
2020-05-04T15:12:35.0321746Z *** Downloading NAV Symbols for [Base Application v16.0.0.0]
2020-05-04T15:12:35.0413507Z *** Downloading NAV Symbols from [https://157039e99d82:7049/BC/dev/packages?publisher=Microsoft&appName=Base+Application&versionText=16.0.0.0&tenant=default]
2020-05-04T15:12:35.0439751Z *** Downloading NAV Symbols with BasicAuthentication [admin]
2020-05-04T15:12:35.0481363Z ##[command]Invoke-RestMethod -Method Get -Uri https://157039e99d82:7049/BC/dev/packages?publisher=Microsoft&appName=Base+Application&versionText=16.0.0.0&tenant=default
2020-05-04T15:12:35.6558268Z *** Content-Disposition: attachment; filename="Microsoft_Base Application_16.0.11240.12076.app"
2020-05-04T15:12:35.6604466Z *** Saving symbol file [Microsoft_Base Application_16.0.11240.12076.app] to [c:\Run\DevOps\PackageCache]
2020-05-04T15:12:36.0148040Z *** Read App Manifest: [c:\Run\DevOps\PackageCache\Microsoft_Base Application_16.0.11240.12076.app].
2020-05-04T15:12:37.4658509Z ***
2020-05-04T15:12:37.8287105Z *** Starting AL Compiler...
2020-05-04T15:12:37.8300311Z *** App.Name         = Base SM
2020-05-04T15:12:37.8313460Z *** App.Publisher    = Inforolot
2020-05-04T15:12:37.8376193Z *** App.Compiler Path= C:\Run\Microsoft.al\al-ALLanguage\extension\bin\alc.exe
2020-05-04T15:12:38.0922214Z *** Checking for Assemblies in App
2020-05-04T15:12:38.1145444Z *** Add Windows Assembly Path [C:\Windows\assembly]
2020-05-04T15:12:38.1620584Z ##[command]& C:\Run\Microsoft.al\al-ALLanguage\extension\bin\alc.exe /packagecachepath:"c:\Run\DevOps\PackageCache" /project:"c:\Run\DevOps\AL\Base" /out:"c:\Run\DevOps\Inforolot_Base SM_1.0.159.0.app" /fullpaths /ruleset:"c:\Run\DevOps\AL\Base\.vscode\io.ruleset.json" /assemblyprobingpaths:C:\Windows\assembly
2020-05-04T15:12:39.5990263Z *** AL Compiler Exit Code: -1073741502
2020-05-04T15:12:39.5999868Z *** AL Compiler raw logs: Start
2020-05-04T15:12:39.6000763Z 
2020-05-04T15:12:39.6009252Z *** AL Compiler raw logs: End
2020-05-04T15:12:39.6016721Z *** Start processing compile results.
2020-05-04T15:12:39.6019753Z *** Compile OK.
2020-05-04T15:12:39.6044838Z *** Start processing compile results done.
2020-05-04T15:12:39.6068221Z *** Transfer App Artifact from Docker container.
2020-05-04T15:12:40.4976946Z ##[error]No se encuentra la ruta de acceso 'c:\Run\DevOps\Inforolot_Base SM_1.0.159.0.app' porque no existe.
2020-05-04T15:12:40.7584946Z ##[section]Async Command Start: Add Build Tag
2020-05-04T15:12:40.7585793Z Build '159' has following tags now: mcr.microsoft.com/businesscentral/onprem-es, BC.Version.16.0.11240.12076, BC.Platform.16.0.11233.12061, AL.Compiler.ALLanguage
2020-05-04T15:12:40.7586467Z ##[section]Async Command End: Add Build Tag
2020-05-04T15:12:40.7587547Z ##[section]Async Command Start: Update Build Number
2020-05-04T15:12:40.7588794Z Update build number to 1.0.159.0 for build 159
2020-05-04T15:12:40.7589366Z ##[section]Async Command End: Update Build Number
2020-05-04T15:12:40.7591681Z ##[section]Finishing: ALOpsAppCompiler

I've been trying but I am stuck and i don't know how to continue. If you can give me any hint or idea about the solution it would be greate.

waldo1001 commented 4 years ago

Hi, it has probably something to do with the "February Update". It has been reported a couple of times: https://github.com/HodorNV/ALOps/issues?q=is%3Aissue+is%3Aclosed+Compile+OK

Can you try to set up your container with hyper-v isolation?

Here an example:

- task: ALOpsDockerStart@1
  inputs:
    docker_image: 'mcr.microsoft.com/businesscentral/sandbox'
    docker_pull: true
    docker_parameters: '--isolation=hyperv'
    memory_gb: 8
Miki-84 commented 4 years ago

Hi Waldo,

Thanks for the reply, I tried with the hyper-v isolation but the server was not ready for it. I will talk to my IT collegues and give it another try and i will let you know.

Thanks again and sorry for repeating the question.

AdminHodor commented 4 years ago

Dear @Miki-84 ,

Please check this comment on another issue: https://github.com/HodorNV/ALOps/issues/119#issuecomment-621353208

This ALC issue seems to be related to the image, the same one as you are using. Could you check if changing the image resolves the problem?

Kind regards,

Miki-84 commented 4 years ago

Hi AdminHodor,

I am having some troubles trying to compile in another image to test. It has to be pulled and the agent is giving me the 60 minutes timeout.... I can pull it previously manually but then ALOps does not reuse it and tries to pull it again and i've got the 60 minutes timeout again. Any idea how can I bypass this situation?

AdminHodor commented 4 years ago

Hello @Miki-84 ,

It has to be pulled and the agent is giving me the 60 minutes timeout... 60 minutes is indeed the default timeout for Azure DevOps Jobs.

I can pull it previously manually but then ALOps does not reuse it This can not be correct, ALOps does not manipulate the image in any way. If you Pulled in manually, it should be picked up. Are you sure you pulled the correct image? ALOps does add the correct -ltsc2016 / 2019 tags when required.

When you look at the log for the DockerStart step, you should see the exact image name queried for pull. Use that exact image for your manual pull.

Kind regards,

Miki-84 commented 4 years ago

@AdminHodor i finally was able to try to compile with another image (mcr.microsoft.com/businesscentral/sandbox:es) but it ended up crashing again.

I will try the hyperv solution as soon as i can and let you know how it went.

Thanks

waldo1001 commented 4 years ago

Hi @Miki-84 , any input on this?

Miki-84 commented 4 years ago

Hi Waldo,

Sorry for the delay. I never had the chance to try the hyperv solution because i was not in controll of the server and some bios modifications needed to be done. Sorry for that.

waldo1001 commented 3 years ago

Hi @Miki-84 ,

we will have a new compiler-step this week (new release). This might solve your issue.

Miki-84 commented 3 years ago

Hi @waldo1001 ,

I wil ltry again, because i don't know wwhy but my Azure devops pipelines have dissapeared, so i will give it a new try to see i f i can manage to generate the .app files from source code in devops. I'll keep you posted!

Miki-84 commented 3 years ago

Hi @waldo1001 , Yesterday i could try the new version of ALOPS and it worked perfectly! A couple of questions though,

Thanks for everything!

waldo1001 commented 3 years ago

Hi @Miki-84 ,

Yes, the ALOps license is activated, and is checking for trials. You will get warnings before it runs out (resulting in partially succeded pipeline runs) and eventually, when it runs out, the pipeline will simply fail. From the moment there is a license, it will just work again.

So I assume you used the "Compiler v2"? It's a preview feature (which is pretty stable - it's the only thing we use internally) that we are extending a bit as we speak .. so any feedback is always appreciated.

waldo1001 commented 3 years ago

I misread the second question, so I changed my response above.

About the appname - it's basically because in our opinion it's interesting to also give details on which localization the app was built. At this point, it's not part of the setup. Why would you like to change it?

Miki-84 commented 3 years ago

Hi @waldo1001, Actually there is no real reason that makes me want to change the name. It is probably my lack of expirience, but i always thought that the build would give me the final name of the extension and that i would not have to rename it in a release pipeline...or maybe MyExtension.1.0.XXX.0_onPrem_es.app should be the final name of the application? I don't see it...i think i am missing something here.

Thanks

waldo1001 commented 3 years ago

Well, the release pipeline shouldn't care - it will just get a bunch of .app files, and install them, right?

Miki-84 commented 3 years ago

You are right... i should start to realize that with this kind of automation there are some names that should not matter. Thanks!

AdminHodor commented 3 years ago

Here's an example of why we went for thing naming template, the following yaml will build one app for multiple Types,Countries and Versions, all in one go.

azure-pipelines.yml

name: $(Build.BuildId)

# This compiler (v2) is not going to use a docker container, but it's going to use the artifacts that you specify in the parameters
# The compiler will "Batch Compile", meaning: it will compile everything in the workingfolder

jobs:
- job: MultiBuildSuperCompile
  timeoutInMinutes: 0
  pool: HOD-DOCKER
  steps:
  - template: 05_MultiVersion_template.yml
    parameters:
      artifacttypes: ['Sandbox','OnPrem']
      artifactversions : ['16.3','16.4']
      artifactcountries: ['w1','be']

05_MultiVersion_template.yml

parameters:
  artifacttypes: []
  artifactversions : []
  artifactcountries: []

steps:
- ${{ each artifacttype in parameters.artifacttypes }}:
  - ${{ each artifactversion in parameters.artifactversions }}:
    - ${{ each artifactcountry in parameters.artifactcountries }}:
      - task: ALOpsAppCompiler@2
        displayName: 'ALOps Compile v2 - ${{ artifacttype  }}-${{ artifactversion  }}-${{ artifactcountry  }}'
        inputs:
          artifacttype: '${{ artifacttype  }}'
          artifactversion: '${{ artifactversion  }}'
          artifactcountry: '${{ artifactcountry  }}'
          appversiontemplate: '1.0.*.0'

When run the pipeline explodes to all combinations: image

Result of the pipeline are these artifacts, which explains the naming convention :-) image