Repository navigation
Packaging Foundry
Part of the Foundry API reference.
Foundry supports two release patterns:
-
CurseForge dependency: CurseForge installs
Foundry-1.0beside your addon. -
Embedded copy: your addon package includes Foundry under
Libs\Foundry-1.0.
Most dual-platform addons should use one shared .toc and let platform metadata
decide how Foundry is delivered.
Use OptionalDeps, not Dependencies, in your addon .toc:
## Interface: 120100
## Title: MyAddon
## Version: @project-version@
## OptionalDeps: Foundry-1.0
## SavedVariables: MyAddonDB
embeds.xml
Core.luaWhy OptionalDeps?
- If standalone
Foundry-1.0is installed, WoW loads it before your addon. - If your package embeds Foundry,
embeds.xmlloads the embedded copy. - If both exist, the first copy loaded owns
_G.Foundry_1_0. A later copy stands down, unless it is a newer build of 1.0.115 or later that can upgrade it in place (see below).
If you embed Foundry, the OptionalDeps line is required. Without it, WoW can
load your addon before the standalone, and your embedded copy then serves every
Foundry addon, even when the installed standalone is newer, unless the upgrade
applies (see below).
Folder names that sort after Foundry-1.0 load after the standalone anyway.
The line turns that from a side effect of the name into a guarantee.
Do not use ## Dependencies: Foundry-1.0 in a shared dual-platform TOC unless
every release channel guarantees standalone Foundry is installed separately.
Foundry started as a standalone addon only. Embedding was added because Wago does not install required dependencies automatically. The standalone is still the recommended delivery, and an embedded copy is the fallback.
The first copy loaded claims _G.Foundry_1_0. Foundry has no rule that favors
the standalone either. It wins only when it loads first. When an addon lists ## OptionalDeps: Foundry-1.0, WoW loads the standalone before that addon, which is
what lets it win over that addon's own embedded copy. The line protects only the
addon that carries it: an addon that embeds Foundry without the line and sorts
earlier still puts its own copy in charge for every Foundry addon, unless a
newer copy upgrades it in place as described next. Older release notes describe
the standalone as winning; that holds only when it loads first, as above.
A newer copy can upgrade the active one. From 1.0.115, a later copy that is a newer build replaces the active copy's core and each module it carries, in place, so addons that use Foundry run the newer copy's code for everything that copy carries. This happens only when all of these hold:
- The active copy is 1.0.115 or later. A 1.0.114 or earlier copy that loads first is never upgraded and keeps serving exactly as before.
- The later copy's API version is not lower than the active copy's.
- Loading is still in progress, before the player has logged in. An addon loaded on demand after login never upgrades the active copy.
- The player is not in combat.
Otherwise the first copy keeps serving and the later copy loads nothing. The
existing per-module fill-in still applies: a module the active copy lacks is
supplied by the later copy. The upgrade
is a safety net, not a replacement for OptionalDeps: copies from 1.0.114 and
earlier are never upgraded, so the line is still the way to make the standalone
load first.
/foundry copies prints what is running: the active copy (its addon
folder, version and API version), each module that comes from a different copy,
and each other copy with its outcome:
-
upgraded to: this copy replaced the active copy's core. -
not used: the active copy was left alone, either because it is 1.0.114 or earlier or because this copy was not a newer build. -
refused: api version: this copy's API version is lower than the active copy's. -
after login: this copy loaded after the player had logged in. -
combat: this copy loaded during combat. -
refused: module list: the active copy's module list did not match what it was serving, so it was left alone. -
layout: the active copy has an internal layout this copy does not recognize.
After an upgrade, the active copy line still shows the first copy's addon
folder and version, but the API version is the newer copy's. The upgraded to
line names the copy that replaced its code. Copies older than 1.0.115 are not listed. The command is skipped if the
FOUNDRY slash key or SLASH_FOUNDRY1 is already taken.
Foundry modules hold live state: event registrations, lifecycle handlers, and the DB module that strips saved-variable defaults on logout. Two live copies could run that logout cleanup twice and corrupt saved data, so Foundry keeps exactly one active copy. An upgrade replaces the code in place rather than starting a second copy, and it is only allowed before login and out of combat.
The copy that runs may be older than the one you shipped. It lacks anything
added since it was built, including later fixes. Using a newer API on an older
copy can raise an error or quietly do the wrong thing, so check the version
before relying on a newer API, for example with
F:RequireModule("Settings", 2) (see
Requiring version 2).
The DB module has one hard floor: if an older Foundry copy that predates the DB logout hook has already claimed the runtime, a DB module loading from a newer copy refuses to attach and prints a message saying so. Saved data is left untouched.
On CurseForge, keep Foundry as a real required dependency in .pkgmeta:
required-dependencies:
- foundryThat tells CurseForge to install Foundry beside your addon. It does not replace
the OptionalDeps line in your .toc, which is what makes WoW load the
standalone first.
Your addon code still accesses Foundry the same way:
local F = _G.Foundry_1_0
if not F then
error("MyAddon requires Foundry-1.0. Please install or enable it.")
endFor embedded builds, include Foundry in your package:
MyAddon/
MyAddon.toc
embeds.xml
Core.lua
Libs/
Foundry-1.0/
Foundry-1.0.xml
Foundry.lua
LICENSE
Modules/
Commands.lua
Events.lua
Lifecycle.lua
DB.lua
List.lua
Settings.lua
Tooltip.lua
Menu.lua
Window.lua
Your embeds.xml loads Foundry before your addon code. If your pinned Foundry
tag contains Foundry-1.0.xml, use the manifest:
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Include file="Libs\Foundry-1.0\Foundry-1.0.xml"/>
</Ui>The manifest carries Foundry's runtime load order, so consumers do not need to hand-maintain the module list.
Use the explicit script list only when embedding an older Foundry tag that does
not have Foundry-1.0.xml, and match it to the module list that tag actually
ships — the list below is the current one:
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="Libs\Foundry-1.0\Foundry.lua"/>
<Script file="Libs\Foundry-1.0\Modules\Commands.lua"/>
<Script file="Libs\Foundry-1.0\Modules\Events.lua"/>
<Script file="Libs\Foundry-1.0\Modules\Lifecycle.lua"/>
<Script file="Libs\Foundry-1.0\Modules\DB.lua"/>
<Script file="Libs\Foundry-1.0\Modules\List.lua"/>
<Script file="Libs\Foundry-1.0\Modules\Settings.lua"/>
<Script file="Libs\Foundry-1.0\Modules\Tooltip.lua"/>
<Script file="Libs\Foundry-1.0\Modules\Menu.lua"/>
<Script file="Libs\Foundry-1.0\Modules\Window.lua"/>
</Ui>Use <Script> for Lua files. Use <Include> only for XML files.
Foundry-1.0.xml is a small loader file shipped by Foundry:
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="Foundry.lua"/>
<Script file="Modules\Commands.lua"/>
<Script file="Modules\Events.lua"/>
<Script file="Modules\Lifecycle.lua"/>
<Script file="Modules\DB.lua"/>
<Script file="Modules\List.lua"/>
<Script file="Modules\Settings.lua"/>
<Script file="Modules\Tooltip.lua"/>
<Script file="Modules\Menu.lua"/>
<Script file="Modules\Window.lua"/>
</Ui>Those paths are relative to the manifest's own folder. Your addon includes the
manifest; Foundry owns the internal file list — which is exactly why the
<Include> form above is preferred over hand-copying this list.
This is the known-good externals: block for the BigWigs packager (the one behind
the standard GitHub release actions and CurseForge/Wago packaging):
externals:
Libs/Foundry-1.0:
url: https://github.com/Royaleint/Foundry
tag: v1.0.115
curse-slug: foundryPin to a release tag (check releases
for the current one) and move it by hand when you want a newer Foundry. Do not
leave the tag off: the packager then bundles the default branch as it is on
packaging day, which can be ahead of any release. Avoid tag: latest for the
same reason: it moves without you choosing when. Do not embed a moving branch
for public releases.
Four things authors commonly trip on:
-
You name the folder, not the repo. The left-hand key (
Libs/Foundry-1.0:) is the checkout path. A default checkout of the repo would land inLibs/Foundry(the repository is namedFoundry, unlike Ace3 repos whose URLs end inAceLocale-3.0-style names) — the key above is what gives you the conventional folder name. -
The embedded folder name is cosmetic anyway. Nothing in Foundry keys on the
Libs/subfolder name; WoW only follows the path in your TOC orembeds.xml, and copy-sharing keys on_G.Foundry_1_0.Libs/Foundry/Foundry-1.0.xmlworks identically if you prefer it. Only the standalone addon folder must be namedFoundry-1.0(see Common Gotchas below). -
Your zip stays clean automatically. The packager applies Foundry's own
.pkgmetaignore list when vendoring it as an external, so the embedded copy is justFoundry.lua,Foundry-1.0.xml,Modules/, andLICENSE— the repo's tests and docs never enter your package. -
Name the CurseForge slug. The packager links an embedded library to its
CurseForge project on its own only when the external comes from a CurseForge or
WowAce repo. Foundry comes from GitHub, so add
curse-slug: foundryto the entry. Without it, the packager doesn't send that relation, so your addon won't appear on Foundry's Dependents list.
- Use
foundryas the CurseForge dependency slug. - Use
<Script>for.luafiles. - Use
<Include>for Foundry's XML manifest. - Keep
embeds.xmlbefore your addon's Lua files in the.toc. - Keep
LICENSEwith embedded Foundry copies. - Do not call
C_AddOns.LoadAddOn("Foundry-1.0")from your addon to force-load Foundry. - Do not rename the standalone folder; it should be
Foundry-1.0(WoW's dependency and load-order machinery finds the standalone addon by folder name). The embeddedLibs/subfolder name, by contrast, is cosmetic. - Your addon still needs its own current
## Interfacevalue. Foundry's TOC does not cover your addon.