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 246 forks source link

Issue in devops pipeline step Compile Test App #371

Closed peterz84 closed 5 years ago

peterz84 commented 5 years ago

First I created a devops Project and imported the repo: https://dev.azure.com/businesscentralapps/HelloWorld/_git/HelloWorld

Now I have a Main App and a Test App.

I created a BuildAgent following the guide on https://blogs.msdn.microsoft.com/freddyk/2018/11/12/developing-business-central-extensions-part-3/

This means the YAML pipeline will trigger my server (Windows 2019) to download my sources, spin up a container, compile the app, publish the app, import the testtoolkit and compile the testapp. This last step fails with the following error:

error

As you suggested in a comment on your blog, the new Container is started with the parameter -enableSymbolLoading. You also commented that I should: unpublish the application symbols in the database. Not sure what you mean by this.

I'm using image mcr.microsoft.com/businesscentral/onprem:cu2-nl-ltsc2019

kine commented 5 years ago

If you are not using C/Side development, you can run the container without enableSymbolLoading but import the test toolkit and it should work. You only need to add line to your app.json "test":"13.0.0.0" which will tell AL to download test symbols...

peterz84 commented 5 years ago

Tried that, but wasn't succesfull. It complained there was no application Test from Publisher Microsoft.

Anyway, this issue seems to be fixed by the newest version of NAVContainerHelper.

peterz84 commented 5 years ago

Just tried with NAVContainerHelper 0.5.0.5, but still the same error.

kine commented 5 years ago

How are you importing the test toolkit?

freddydk commented 5 years ago

As Kamil says, the error above should disappear if you have a test rerefence in your app.json in your test app (if you did NOT start with -enablesymbolloading) I am currently writing up a blog post on symbols and everything you need to know about them.

freddydk commented 5 years ago

Just tried a pipeline and get an error myself:

[error]Cannot index into a null array. [error]At C:\Program [error]Files\WindowsPowerShell\Modules\navcontainerhelper\0.5.0.5\ContainerHandling\Invoke-ScriptInNavContainer.ps1:30 char:9

Not the same as yours - but will investigate this.

kine commented 5 years ago

This is when you have disabled the WebClient in the container (I had this one before but I found that he webclient is disabled in my build pipeline to save some time...) - you are taking the webclient URL and in this case it is empty but you are copying the protocol from it...

Or it could be something different... :-)

freddydk commented 5 years ago

Not the web client issue - but I can repro on my own machine now. But this is a null array - not the same as peter gets. (I got that as well - but then I added the test reference to the right app.json file)

freddydk commented 5 years ago

Note that by default - the scripts in my template repo does start up using -enablesymbolloading and as such will NOT need the test reference.

peterz84 commented 5 years ago

Indeed. But changed my app.json of the test app anyway to test the other approach too: image

Removed enableSymbomLoading in CreateContainer.ps1: image

error: image

freddydk commented 5 years ago

On the last screenshot - it does indeed download the test symbols - I will check if I can repro this

freddydk commented 5 years ago

Tried with microsoft/bcsandbox:us - worked fine - currently downloading the cu2-nl container

peterz84 commented 5 years ago

TestExtension2.zip

freddydk commented 5 years ago

It repros with the docker image you are using - stay tuned

peterz84 commented 5 years ago

Is it bad to say I'm happy to hear that? :)

freddydk commented 5 years ago

Sorry to say that this was 60% my fault (and 40% Azure DevOps) My mistaket was to checkin a line, which caused compile-appinnavcontainer to NEVER download test symbols. Azure DevOps mistake is to reuse folders with 2 versions of the build - meaning that if you successfully had build before - then the test symbols where there. This also means that I could only repro because I had a brand new agent which hadn't built before (lucky me)

I have fixed issue number one in 0.5.0.6 - already published to the Gallery. I will have to find out what to do about issue no., 2 (which I only discovered because of issue no. 1) - I think that is a problem and I will have to find a way around that - folders should be clean with every build IMO.

Run your pipeline again - it should download symbols and compile.

peterz84 commented 5 years ago

Yes it works now! So I should be able to remove the test: 13.0.0.0 and add EnableSymbolLoading again?

I'm not sure if I can follow you on the second one as devops (the yaml script) will spin up a new Container everytime you schedule a build? Probably some folders wich are not created/updated when spinning up the container?

freddydk commented 5 years ago

Correct - the build server doesn't totally clean up.

freddydk commented 5 years ago

Not sure if everything will work - the build server might have old symbols, which it doesn't overwrite. Will investigate this.

freddydk commented 5 years ago

Found out that this is a feature - you should set build.clean to all in your pipeline: image Then it cleans the directories, Will add that to the template...

freddydk commented 5 years ago

You can insert these lines as the first in CI.yml:

variables: build.clean: all platform: x64