Navcontainerhelper: DotNet Packages for ZipArchive missing when creating a Base App

Created on 18 Dec 2020  路  18Comments  路  Source: microsoft/navcontainerhelper

Base App created using "Create-AlProjectFolderFromNavContainer" and the .netpackages for the new Zip System Module are missing.

A clear and concise description of what the issue is.

Scripts used to create container and cause the issue

Create-AlProjectFolderFromNavContainer -containerName $containerName `
                                        -alProjectFolder $alProjectFolder `
                                        -useBaseLine `
                                        -addGIT `
                                        -id $appId `
                                        -publisher $appPublisher `
                                        -name $appName `
                                        -version $appVersion `
                                        -alFileStructure $alFileStructure

Full output of scripts
Latest BC Container Helper

f:\...Base App\BaseApp\source\ConfPersonalizationMgt.codeunit.al(460,14): error AL0185: DotNet 'ZipFileExtensions' is missing
f:\...\Base App\BaseApp\source\ConfPersonalizationMgt.codeunit.al(461,18): error AL0185: DotNet 'ZipFile' is missing
f:\...\Base App\BaseApp\source\ConfPersonalizationMgt.codeunit.al(463,21): error AL0185: DotNet 'ZipArchive' is missing
f:\...\Base App\BaseApp\source\ConfPersonalizationMgt.codeunit.al(464,25): error AL0185: DotNet 'ZipArchiveMode' is missing
f:\...\Base App\BaseApp\source\OfficeLineGeneration.codeunit.al(534,31): error AL0185: DotNet 'PluralizationService' is missing
f:\...\Base App\BaseApp\source\StreamManagement.codeunit.al(36,21): error AL0185: DotNet 'ZipArchive' is missing
f:\...\Base App\BaseApp\source\StreamManagement.codeunit.al(38,26): error AL0185: DotNet 'ZipArchiveEntry' is missing


bug Fix Ready Ships in a future version

All 18 comments

Output from container creation? or the script so that I can see which artifacts this is based on?

Thanks

Sorry about that...

$artifacturl = Get-BCArtifactUrl -country w1 -type OnPrem

$containerName = "bc17w1"
$auth = "UserPassword"
$credential = New-Object pscredential 'gunnargestsson', (ConvertTo-SecureString -String 'P@ssword1' -AsPlainText -Force)
$licenseFile = "*.flf"

New-BCContainer -accept_eula `
                -artifacturl $artifacturl `
                -containerName $containerName `
                -auth $auth `
                -credential $credential `
                -licenseFile $licenseFile `
                -updateHosts `
                -includeAL `
                -memoryLimit 10G

and it worked with 17.1?

Have not tried 17.1.
Added

assembly("System.IO.Compression")
{

    type("System.IO.Compression.ZipArchive"; "ZipArchive")
    {
    }

    type("System.IO.Compression.ZipArchiveMode"; "ZipArchiveMode")
    {
    }

    type("System.IO.Compression.ZipArchiveEntry"; "ZipArchiveEntry")
    {
    }


}
assembly("System.IO.Compression.FileSystem")
{
    type("System.IO.Compression.ZipFile"; "ZipFile")
    {
    }
    type("System.IO.Compression.ZipFileExtensions"; "ZipFileExtensions")
    {
    }
}

assembly("System.Data.Entity.Design")
{
type("System.Data.Entity.Design.PluralizationServices.PluralizationService"; "PluralizationService")
{
}
}

and the following files from dotnet 4.8

System.Data.Entity.Design.dll
System.IO.Compression.dll
System.IO.Compression.FileSystem.dll

But this seems to break the compile-appinbccontainer function

Cannot repro this. The script I normally use to test this is this:

$artifactUrl = Get-BCArtifactUrl -version 17 -country w1 -type OnPrem
$containerName = "my2"
$auth = "UserPassword"
$credential = New-Object PSCredential 'admin', (ConvertTo-SecureString -String 'P@ssword1' -AsPlainText -Force)
$licenseFile = "c:\temp\license.flf"
$alProjectFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "baseapp-$containername"

New-BCContainer -accept_eula `
                -containerName $containerName `
                -auth $auth `
                -Credential $credential `
                -licenseFile $licenseFile `
                -updateHosts `
                -includeAL `
                -alwaysPull `
                -memoryLimit 20G `
                -doNotUseRuntimePackages `
                -artifactUrl $artifactUrl `
                -isolation hyperv

$appId = "88b7902e-1655-4e7b-812e-ee9f0667b01b"
$appPublisher = "Freddy Kristiansen"
$appName = "MyBaseApp"
$appVersion = "1.0.0.0"
Create-AlProjectFolderFromBCContainer -containerName $containerName `
                                      -alProjectFolder $alProjectFolder `
                                      -useBaseLine `
                                      -id $appId `
                                      -publisher $appPublisher `
                                      -name $appName `
                                      -version $appVersion

$app = Compile-AppInBCContainer -containerName $containerName `
                                -credential $credential `
                                -appProjectFolder $alProjectFolder `
                                -appOutputFolder $alProjectFolder `
                                -UpdateSymbols

This seems to work.

Not sure why i have hyperv here though?

The Compile-AppInBCContainer works fine but VS Code can't compile the app.

and you have included C:\ProgramData\BcContainerHelper\Extensions\containername.netPackages in your .netPackages?

yes I did

Could you try to modify new-navcontainer.ps1 and replace the IF section at line 1958 (starting with if ($includeAL)) with this:

    if ($includeAL) {
        $dotnetAssembliesFolder = Join-Path $containerFolder ".netPackages"
        New-Item -Path $dotnetAssembliesFolder -ItemType Directory -ErrorAction Ignore | Out-Null

        Write-Host "Creating .net Assembly Reference Folder for VS Code"
        Invoke-ScriptInBcContainer -containerName $containerName -scriptblock { Param($dotnetAssembliesFolder)

            $serviceTierFolder = (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service").FullName

            $paths = @("C:\Windows\assembly", "C:\Windows\Microsoft.NET\assembly", $serviceTierFolder)

            $rtcFolder = "C:\Program Files (x86)\Microsoft Dynamics NAV\*\RoleTailored Client"
            if (Test-Path $rtcFolder -PathType Container) {
                $paths += (Get-Item $rtcFolder).FullName
            }
            $mockAssembliesPath = "C:\Test Assemblies\Mock Assemblies"
            if (Test-Path $mockAssembliesPath -PathType Container) {
                $paths += $mockAssembliesPath
            }
            $paths += "C:\Program Files (x86)\Open XML SDK"

            $paths | % {
                $localPath = Join-Path $dotnetAssembliesFolder ([System.IO.Path]::GetFileName($_))
                if (!(Test-Path $localPath)) {
                    New-Item -Path $localPath -ItemType Directory -Force | Out-Null
                }
                Write-Host "Copying DLLs from $_ to assemblyProbingPath"
                Get-ChildItem -Path $_ -Filter *.dll -Recurse | % {
                    if (!(Test-Path (Join-Path $localPath $_.Name))) {
                        Copy-Item -Path $_.FullName -Destination $localPath -Force -ErrorAction SilentlyContinue
                    }
                }
            }

            $serviceTierAddInsFolder = Join-Path $serviceTierFolder "Add-ins"
            if (!(Test-Path (Join-Path $serviceTierAddInsFolder "RTC"))) {
                if (Test-Path $RtcFolder -PathType Container) {
                    new-item -itemtype symboliclink -path $ServiceTierAddInsFolder -name "RTC" -value (Get-Item $RtcFolder).FullName | Out-Null
                }
            }
        } -argumentList (Get-BcContainerPath -containerName $containerName -path $dotnetAssembliesFolder)
    }

And then retry container generation.
This will copy DLLs to the .netpackages folder in a different way and include these DLLs as well.

Will do that tomorrow... Will keep you updated

did you have support in Run-AlPipeline for the -useNewDatabase for building the custom base app ?

No - Run-AlPipeline is specifically for appsourceapps and PTEs

Roger that

Success, now the app compiles in VS Code!

Cool - I am confident this code works for old versions as well - will include that in the next containerhelper preview - tests should fail if this breaks the scenario.

Shipped in 1.0.18

Was this page helpful?
0 / 5 - 0 ratings