Modules/businessdev.ALbuild.Core/Public/Get-BcContainerHostShare.ps1

function Get-BcContainerHostShare {
    <#
    .SYNOPSIS
        Returns the host folder shared into a Business Central container (mapped to C:\run\my).
 
    .DESCRIPTION
        Getting files into a container with 'docker cp' does not work for a running hyperv-isolated
        container (the Docker Desktop default on Windows client hosts) - "filesystem operations
        against a running Hyper-V container are not supported". Instead the container is created with
        a host folder bind-mounted to C:\run\my; writing a file to that host folder makes it appear
        inside the container. This returns the per-container host folder, chosen for the environment:
 
          - Azure DevOps agent: under AGENT_TEMPDIRECTORY (job-scoped, writable, auto-cleaned).
          - Windows host: C:\ProgramData\ALbuild\<container> (shared, like BcContainerHelper).
          - other: a temp folder (BC containers are Windows-only, so this is a fallback).
 
        New-BcContainer mounts this folder; Copy-BcFileToContainer writes into it; Remove-BcContainer
        cleans it up. The path is deterministic from the container name so every step agrees on it.
 
    .PARAMETER Name
        Container name.
 
    .OUTPUTS
        System.String - the host folder path.
    #>

    [CmdletBinding()]
    [OutputType([string])]
    param(
        [Parameter(Mandatory, Position = 0)] [ValidateNotNullOrEmpty()] [string] $Name
    )

    $base =
    if ($env:AGENT_TEMPDIRECTORY) { Join-Path $env:AGENT_TEMPDIRECTORY 'ALbuild-share' }
    elseif ($env:ProgramData) { Join-Path $env:ProgramData 'ALbuild' }
    elseif ($env:USERPROFILE) { Join-Path $env:USERPROFILE '.albuild/share' }
    else { Join-Path ([System.IO.Path]::GetTempPath()) 'ALbuild' }

    return (Join-Path $base $Name)
}