Publish-NAVApp: Extension compilation failed during publishing an extension in on on-premises Business Central Production Environment

Hi D365 BC lovers,

In this article, I am sharing very important detail related to publishing an app-file on an on-premises Microsoft Dynamics 365 Business Central Production Environment using the Publish-NAVApp PowerShell cmdlets.

During publish I faced the following error:

.............................................................
PS C:\Users\Administrator.Prod> Publish-NAVApp -Path "C:\ClientExtensions\Tabrez_Publisher_ClientCustomization_1.0.0.5.app" -ServerInstance BC140 -SkipVerification
Publish-NAVApp : Extension compilation failed
CodeUnit/50000_Sales-Post.Codeunit.al(7,54): error AL0132: 'Codeuint' does not contain a definition for 'Sales Transaction Events'
At line:1 char:1
+ Publish-NAVApp -Path "C:\Extension\Default publisher_BHMCustomization ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Publish-NAVApp], InvalidOperationException
+ FullyQualifiedErrorId : MicrosoftDynamicsNavServer$BC140/nav-systemapplication,Microsoft.Dynamics.Na 
v.Apps.Management.Cmdlets.PublishNavApp 


Important Note to consider here: Actually in my case, all the objects are missing. 

This is a very common issue, It happens when a developer trying to publish an extension with a newer version, this issue can be fixed by running the following command snippet in command prompt with Administrative Privileges. 

Please follow below steps to fix the error:
1. Open Command Prompt or Business Central Administrator Shell 
Start - > Command Prompt -> Run as administrator
or Start -> Business Central Administrator Shell -> Run as administrator

2. Then use following snippet:

................................................
cd C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\140\RoleTailored Client

3. Use one of the following command snippets as now you are in the correct directory:

......................................................
For Windows Authentication:
finsql.exe Command=generatesymbolreference, Database="<application sql database>", ServerName=<sql server host name>, ntauthentication=yes
or
finsql.exe Command=generatesymbolreference, Database="<application sql database>", ServerName=<sql server host name> 

For SQL Authentication:
finsql.exe Command=generatesymbolreference, Database="<application sql database>", ServerName=<sql server host name>, ntauthentication=no, username=<sql server username>, password=<sql server password>

example:

Expert Note:
The finsql.exe command will start a background finsql.exe process (if you want to see then you can see it in Windows Task Manager).
When it finishes it will create one or two text-files in the Role Tailored Client directory:
1. filename: navcommandresult.txt - it contains the status
2. filename: naverrorlog.txt - it will be created only when an error occurs and contains the log

The above 3 steps fixed "Extension compilation failed" error for me.

You can find more detailed information on following MSDN Links: 
Running C/SIDE and AL Side-by-Side {Related to this post}
Publish-NAVApp
Publishing and Installing an Extension v2.0

I hope this article will help to get rid of extension compilation failed error during publishing an extension to Dynamics 365 Business Central on-premises.

Stay Tuned!

Comments (3) -

Faruk Islam 4/19/2020 7:45:31 AM

Bhai baat karni hai ,Bhai reply do

Yeah faruk, Please say!

683087 110982It shows how you comprehend this subject. Added this page, is for much more. 75720

Add comment