# Build and distribute programs

> Choose managed, Release, and NativeAOT builds and package the correct outputs.

Canonical: https://alice-lang.org/documentation/guides/publishing/

[Documentation index](https://alice-lang.org/documentation/llms.txt) · [Complete book](https://alice-lang.org/llms-full.txt)

## Build without running

```sh
alice build
alice build --release
```

Project builds delegate to MSBuild using the generated `.alice/` project. Build artifacts live under the package's `bin/` and `obj/` directories. `alice run` builds and executes, while `alice check` only checks the program.

For loose files, `alice build main.al` compiles the file and its required sources. The CLI also supports output and assembly-reference options; see [commands](https://alice-lang.org/documentation/tools/cli.md).

## NativeAOT

```sh
alice build --release --native
```

The equivalent persistent manifest setting is:

```toml
[build]
native = true
```

NativeAOT uses .NET's ahead-of-time compilation. It needs the target platform's native build prerequisites, and libraries must support trimming/AOT where required. Reflection-heavy or runtime-code-generation APIs can require extra configuration or be incompatible.

This is different from `@[Native]` on a numeric function: NativeAOT publishes a .NET application; the experimental attribute path compiles a restricted function subset through a system C compiler.

## Package an application

Build on or for the intended target, inspect the actual output path printed by the build, and include the application's required files. Games need assets and graphics/audio dependencies; a web host needs its runtime configuration and content. Do not distribute `.alice/` as though it were the executable.

For managed output, the destination needs the compatible .NET runtime unless your chosen publishing configuration includes it. A native executable targets its operating system and architecture; it is not automatically portable across them.

## Verify outside the checkout

Copy the intended distribution to a clean temporary directory. Run it with representative arguments and check file access, configuration loading, output, and shutdown. This detects accidental dependencies on source-tree paths.

Keep `alice.toml`, `alice.lock`, and a toolchain pin in the source repository to make the build reproducible. Dependency locking is useful but does not make the operating system, SDK patches, or external services bit-for-bit identical.

## Clean outputs

`alice clean` removes build outputs so a subsequent build starts fresh. Generated projects can be recreated from the manifest; do not preserve hand-edited generated project settings. Use `Directory.Build.props` or the manifest for settings that belong in source control.

## Continue reading

- Previous: [Understand performance](https://alice-lang.org/documentation/guides/performance.md)
- Next: [Memory and value semantics](https://alice-lang.org/documentation/advanced/memory.md)
