Automated Napacitor Project Configuration
Many large-scale apps need to automate the configuration of their Napacitor project — incrementing build numbers, changing the package name/app name, adjusting host configuration, and more. Napacitor's native layer is a single .NET MAUI host project (maui/), and every piece of "native configuration" that needs changing is a standard MSBuild property, so automation is far simpler than with Capacitor: there are no per-platform plist/Gradle files to deal with.
Automating with the nap CLI
The nap CLI is designed for scripting: it is non-interactive, returns a non-zero exit code on failure, and can be embedded directly into CI pipelines:
npm ci
npx nap init com.example.app "My App" --web-dir dist # generates napacitor.config.json
npx nap add maui # generates the MAUI host project
npm run build # builds the web assets
npx nap sync # copies the assets + wires up plugins
npx nap build --target android -c Release # produces the release build
The most common CI pattern is to parameterize values like appId / appName (e.g. injected from environment variables), then call nap init to write the config.
Modifying the Host Project's MSBuild Properties
Everything automatable in the host lives in maui/App.csproj and can be overridden with MSBuild command-line -p: arguments — no need to edit files by hand:
# Increment the version number (Android versionCode / iOS CFBundleVersion are generated automatically by the TFM rules)
npx nap build --target android -c Release \
-p:ApplicationDisplayVersion=1.4.5 \
-p:ApplicationId=com.mycompany.myapp \
-p:ApplicationTitle="My App QA"
Conditional property groups let you vary values per build configuration (see Environment-Specific Configurations):
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<ApplicationTitle>My App</ApplicationTitle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' != 'Release'">
<ApplicationTitle>My App - QA</ApplicationTitle>
</PropertyGroup>
Automating Plugin Wiring
After installing/removing plugins, running npx nap sync regenerates maui/napacitor.build.props, wiring each installed plugin's C# project into the host. In CI, as long as you ensure "npm ci (or npm install) first, then nap sync", the plugins' native code is always in sync.
Other Automation Scenarios
- Icons and splash screens:
npx nap assetsgenerates host resources from source SVG/PNG and can be hooked into the build pipeline — see Splash Screens and Icons; - Whitelabeling: maintain one
napacitor.config.jsonper brand (appId/appName/theme colors), reuse the same web code, and simply runnap initthen build for each brand.