Hi Bas,
Your two commands show where the gap is. The libraries you add by hand all come from each package’s bin\1500\ folder. AX packages ship their compiled .lib files in a bin folder with one subfolder per target, as listed under targets: in the package’s apax.yml. dependencies.json only tells the compiler which packages are installed and where. When you build a subfolder directly with apax build stc, the libraries in those target folders aren’t picked up, so you have to pass them yourself.
Two approaches avoid listing the libraries by hand.
Option 1 – Make cd2_small its own apax project (recommended)
This is the setup apax is designed for. Each project’s dependencies are declared in its own apax.yml, and apax build resolves their libraries automatically.
Create a project for the small part, for example with apax create lib cd2_small, or app if it runs on its own.
Move the sources from src\cd2_small into the new project’s src folder.
In its apax.yml, set the same targets and catalogs as the main project, and add only the dependencies this part uses:
yaml
dependencies:
"@ax/simatic-tasks": <same version as main project>
"@ax/system-datetime": <same version as main project>Run apax install, then apax build in that folder.
Only cd2_small is compiled. No lib= arguments are needed, and its dependencies are documented in one place.
Option 2 – Keep one project and generate the lib= arguments with a script
If the code has to stay in the current project, let a script collect the libraries from .apax\packages so you never list them by hand. Save this as build-small.ps1 in the project root:
powershell
$target = "1500" # folder name your packages ship libraries in
$libs = Get-ChildItem .apax\packages -Recurse -Filter *.lib |
Where-Object { $_.FullName -match "\\bin\\$target\\" }
$cmd = @('build','stc','-p','target=s7generic',
'--property','input=.\src\cd2_small',
'--property','dependenciesJson=.apax\dependencies.json')
foreach ($l in $libs) { $cmd += '--property'; $cmd += "lib=$($l.FullName)" }
& apax @cmdThen add it as a script in apax.yml:
yaml
scripts:
build-small:
- pwsh ./build-small.ps1Run it with apax build-small. It produces the same command you already confirmed works, and any library you install later is included automatically. Libraries that cd2_small doesn’t use are passed too, which makes the command longer but doesn’t change what gets compiled.
Hope this helps! If this solution works for you, kindly mark it as the accepted answer so it can help others facing the same issue.