HodorNV / ALOps

ALOps
59 stars 24 forks source link

Import FOB fails #405

Closed peterz84 closed 3 years ago

peterz84 commented 3 years ago

I'm running ALOps and creating a 14.7 docker container. I'm trying to import several fobs (3), but with one fob in particular, it fails with the following log:

*** Import FOB: [DCW_EM.fob] in [NAV]
  * DatabaseServer   : localhost\SQLEXPRESS
  * Database Instance: SQLEXPRESS
  * Database Name    : CRONUS
  * Management Port  : 7045
*** Running command: & "C:\Program Files (x86)\Microsoft Dynamics NAV\140\RoleTailored Client\finsql.exe" --% Command=ImportObjects,ImportAction=Overwrite,SynchronizeSchemaChanges=Force,File="C:\Run\DCW_EM.fob",LogFile="C:\Users\ContainerAdministrator\AppData\Local\Temp\NavIde\16a38650-dc5d-435d-b6ac-a69a19f7cca6\DCW_EM.log",ServerName="localhost\SQLEXPRESS",generatesymbolreference=0,ServerName="localhost\SQLEXPRESS",Database="CRONUS",NavServerName="localhost",NavServerInstance="NAV",NavServerManagementport=7045 | Out-Null
##[error]: [31719426] The objects from the .fob file were imported, but they contain schema changes that cannot be synchronized to the database with the Microsoft Dynamics 365 Business Central Server instance.
Contact your system administrator with the following information:

Server Name:         localhost
Server Instance:     NAV
Tenant Name:         

Description:
The supplied field number '6085575' cannot be found in the 'Approval Entry' table.
 -- File: C:\Run\DCW_EM.fob

I even used Synchronize force:

Using hyperv isolation gives me the same result.

Complete YAML:

trigger: none
name: $(Build.BuildId)

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

pool: BHNL Business Central Pool

steps:
- checkout: self
  clean: true

- task: ALOpsDockerCreate@1
  displayName: 'ALOPS - Create Docker Image' # It will reuse the image if already exists, or build one if it doesn't.
  inputs:
    artifacttype: OnPrem
    artifactversion: '14.7'
    artifactcountry: 'w1'
    licensefile: C:\licenses\14.flf

- task: ALOpsDockerStart@1
  inputs:
    enable_symbol_loading: true
    memory_gb: '8'
    container_restart: 'always'

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

- task: ALOpsFobImport@1
  displayName: 'Import customer fob'
  inputs:
    usedocker: true
    filePath: 'fobs/TSCW.fob'
    import_action: 'Overwrite'
    synchronize_schema_changes: 'Yes'

- task: ALOpsFobImport@1
  displayName: 'Import DocCap Fob'
  inputs:
    usedocker: true
    filePath: 'fobs/DCW_EM.fob'
    import_action: 'Overwrite'
    synchronize_schema_changes: 'Force'

- task: ALOpsFobImport@1
  displayName: 'Import Doc Creator Fob'
  inputs:
    usedocker: true
    filePath: 'fobs/DCR.fob'
    import_action: 'Overwrite'
    force_full_generate_symbol_reference: true #only needed in some versions of BC and takes longer
    synchronize_schema_changes: 'Yes'
    #generate_symbol_reference: true

- task: ALOpsAppPublish@1
  displayName: 'ALOps Dependant extensions'
  inputs:
    usedocker: true
    skip_verification: true
    batch_publish_folder: '/.alpackages'

- task: ALOpsAppCompiler@1
  displayName: 'ALOPS - Compile Extension'
  inputs:
    usedocker: true
    al_analyzer: 'CodeCop,PerTenantExtensionCop,UICop'
    nav_app_version: '1.0.0.*'
    targetproject: './app.json'   # point to the folder in your repo that you want to compile in this step

- task: ALOpsAppPublish@1
  displayName: 'Publish AL-App'
  inputs:
    usedocker: true
    nav_artifact_app_filter: '*.app'

- task: ALOpsDockerRemove@1
  displayName: 'ALOPS - Remove Docker Container'
  enabled: true
  condition: always()
waldo1001 commented 3 years ago

Any chance you can send a repro for this?

peterz84 commented 3 years ago

Sure, where do I send the fob?

waldo1001 commented 3 years ago

It does see to be a simple error, though:

Description:
The supplied field number '6085575' cannot be found in the 'Approval Entry' table.
 -- File: C:\Run\DCW_EM.fob

You could provide the fob as an attachment in this issue (just drag/drop it in the textbox).
Or, if you don't want to share the code publicly : admin@hodor.be

peterz84 commented 3 years ago

I did send the fob file to the email address. The error seems simple, but the mentioned field number was added by this fob, so it should not complain about non-existing, in my opinion. But I must be overlooking something.

waldo1001 commented 3 years ago

Hm, when I try to import the fob to a 14.6, it just works. No error.

My step:

  - task: ALOpsFobImport@1
    displayName: "Import C/SIDE Customisations"
    inputs:
      usedocker: true
      filePath: "DCW_EM.fob"
      import_action: "Overwrite"
      generate_symbol_reference: true
      force_full_generate_symbol_reference: true

The only difference I see is the "force_full_generate_symbol_reference", but I don't see why that would make any difference πŸ€”

I see that I didn't get the right version, so I'm running now in 14.7

peterz84 commented 3 years ago

When I remove the delete container step from my yaml, log in on the server and run the command Import-ObjectsToNavContainer, it works fine...:

PS C:\Windows\system32> Import-ObjectsToNavContainer -objectsFile c:\licenses\DCW_EM.fob -containerName vigilant_hypatia -ImportAction Overwrite
Importing Objects from C:/licenses\DCW_EM.fob (container path)
Objects successfully imported

What is the ALOPS step doing different?

waldo1001 commented 3 years ago

14.7, sandbox, be "just works" as well. Next test in w1 (same as yours)

waldo1001 commented 3 years ago

When I remove the delete container step from my yaml, log in on the server and run the command Import-ObjectsToNavContainer, it works fine...:

PS C:\Windows\system32> Import-ObjectsToNavContainer -objectsFile c:\licenses\DCW_EM.fob -containerName vigilant_hypatia -ImportAction Overwrite
Importing Objects from C:/licenses\DCW_EM.fob (container path)
Objects successfully imported

What is the ALOPS step doing different?

The complete line is displayed in the output. This is what we do:

"C:\Program Files (x86)\Microsoft Dynamics NAV\140\RoleTailored Client\finsql.exe" --% Command=ImportObjects,ImportAction=Overwrite,SynchronizeSchemaChanges=Force,File="C:\Run\DCW_EM.fob",LogFile="C:\Users\ContainerAdministrator\AppData\Local\Temp\NavIde\16a38650-dc5d-435d-b6ac-a69a19f7cca6\DCW_EM.log",ServerName="localhost\SQLEXPRESS",generatesymbolreference=0,ServerName="localhost\SQLEXPRESS",Database="CRONUS",NavServerName="localhost",NavServerInstance="NAV",NavServerManagementport=7045 | Out-Null

Can you test that (from within the container)?

peterz84 commented 3 years ago

I did and that worked.... But now what?

PS. I could not find the log file mentioned: C:\Users\ContainerAdministrator\AppData\Local\Temp\NavIde\16a38650-dc5d-435d-b6ac-a69a19f7cca6\DCW_EM.log But there was a navcommandresult.txt

waldo1001 commented 3 years ago

As long as I don't have a way to repro this, I don't know.

14.7, w1, OnPrem also just works for me.

So may be it's the combo with the other fob imports? Can you try with only one?

peterz84 commented 3 years ago

Finally found the problem, well not really the problem (I'll leave that up to you), but what is causing it:

synchronize_schema_changes: 'Force'

If I omit this step, it works fine. Even with a filter like fobs/*.fob If you want to reproduce, just add the line above to your Task.

waldo1001 commented 3 years ago

That's good news.

Well - the only thing we do is do what you ask: in this case, we add the SynchronizeSchemaChanges=Force to the finsql.exe command, which comes back with an error πŸ€·β€β™‚οΈ.

I can't see how this is an ALOps issue...

When I add that line to my yaml, I'm still not able to repro, though ..

peterz84 commented 3 years ago

I understand you just add the line to the command, the weird thing is that when I keep the container alive and run the command my self in the container, it also succeeds πŸ€·β€β™‚οΈ.

The no-repro is also weird. I even removed the docker image, to be sure. Well solved for now πŸ’―

waldo1001 commented 3 years ago

Long shot - but could you may be execute it on another agent? πŸ€”

This is my simply repro, btw..

name: $(Build.BuildId)

variables:
  - name: "AppVersion"
    value: "1.1.[yyyyWW].*"
  - group: "Secrets"

pool:
  name: HOD-DOCKER

trigger: none

steps:
  - checkout: self
    clean: true

  - task: ALOpsDockerCreate@1
    inputs:
      artifacttype: OnPrem
      artifactversion: "14.7"
      artifactcountry: "w1"

  - task: ALOpsDockerStart@1
    inputs:
      enable_symbol_loading: true
      memory_gb: "8"

  - task: ALOpsDockerWait@1
    inputs:
      search_string: "Ready for connections!"

  - task: ALOpsFobImport@1
    displayName: "Import C/SIDE Customisations"
    inputs:
      usedocker: true
      filePath: "DCW_EM.fob"
      import_action: "Overwrite"
      generate_symbol_reference: true
      force_full_generate_symbol_reference: true
      synchronize_schema_changes: Force

  - task: ALOpsAppCompiler@1
    inputs:
      usedocker: true
      targetproject: "MainApp/app.json"
      al_analyzer: "CodeCop,PerTenantExtensionCop,UICop"
      nav_app_version: "$(AppVersion)"

  - task: ALOpsAppPublish@1
    inputs:
      usedocker: true
      nav_artifact_app_filter: "*.app"
      installpublishedapps: true

  - task: ALOpsInfo@1

  - task: ALOpsDockerRemove@1
    enabled: true
    condition: always()