PacktPublishing / Automated-Testing-in-Microsoft-Dynamics-365-Business-Central-Second-Edition

Automated Testing in Microsoft Dynamics 365 Business Central - Second Edition, published by Packt
MIT License
39 stars 24 forks source link

Running DeployTestAppsFromDVD.ps1 throws error on fresh DVD installed BC #23

Closed lvanvugt closed 2 years ago

lvanvugt commented 2 years ago

Issue

When running the script DeployTestAppsFromDVD.ps1, as referenced in the Appendix of the book (page 361), ona fresh BC installetion form the product DVD the following error will occur:

Publish-NAVApp : Extension compilation failed
DotNet%20Aliases/src/dotnet.al(8,14): error AL0451: An assembly named 'MockTest, PublicKeyToken=null' could not be found in the assembly probing paths 'C:\Program Files\Microsoft Dynamics 36
5 Business Central\200\Service\Add-Ins, C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\Microsoft Dynamics NAV\Add-Ins\20.0.39668.39849, C:\Program Files\Microsoft Dynamics 365 
Business Central\200\Service\, C:\Windows\Microsoft.NET\assembly\'

Solution

As the error clearly describes the MockTest.dll is missing. This component indeed is not copied the the Add-ins folder of the sevice tier. To solve the issue make sure to install it (and restart the service tier).

Thanx to ...

... Carolien Kaasenbrood of Adfocom for reporting the issue.

lvanvugt commented 2 years ago

Will fix the script DeployTestAppsFromDVD.ps1 by adding the following lines:

# copy MockTest.dll to server folder
if ((Test-Path "$dvdFilePath\Test Assemblies\Mock Assemblies") -and (Test-Path "$serverFilePath\Add-ins") -and ((Test-Path "$serverFilePath\Add-ins\MockTest.dll") -eq $false)) {
    Copy-Item -Path "$dvdFilePath\Test Assemblies\Mock Assemblies\MockTest.dll" -Destination "$serverFilePath\Add-ins"
    Restart-NAVServerInstance $bcServerInstance
}

And introduce the variable "$serverFilePath which equals "${env:ProgramFiles}\Microsoft Dynamics 365 Business Central\200\Service"