Skip to main content

Chocolatey

Publish to the Chocolatey Windows package manager

Anodizer generates Chocolatey .nuspec manifests and chocolateyInstall.ps1 PowerShell scripts, packs them into .nupkg files, and pushes them to the Chocolatey community repository (or a custom source). Chocolatey is the leading package manager for Windows, letting users install your tool with choco install myapp.

Minimal config

crates:
  - name: myapp
    publish:
      chocolatey:
        repository:
          owner: myorg
          name: myapp
        license: MIT

Chocolatey config fields

FieldTypeDefaultDescription
namestringcrate nameOverride the Chocolatey package name
idsstring[]noneBuild ID filter: only include artifacts whose id is in this list
repository.ownerstringrequiredGitHub owner of the project repository
repository.namestringrequiredGitHub repository name
package_source_urlstringnoneURL shown as the package source in the Chocolatey gallery
ownersstringnoneChocolatey gallery package owner username
titlestringpackage nameDisplay title in the gallery (supports templates)
authorsstringcrate nameAuthor name(s) shown in the gallery
project_urlstringGitHub repo URLProject homepage URL
url_templatestringrelease URLCustom URL template for download URLs (overrides the release asset URL)
icon_urlstringnoneURL to the package icon image
copyrightstringnoneCopyright notice (supports templates)
descriptionstringcrate namePackage description (supports templates)
licensestringnoneSPDX license identifier (e.g., MIT, Apache-2.0)
license_urlstringautoExplicit license URL. Falls back to https://opensource.org/licenses/<license>
require_license_acceptanceboolfalseRequire users to accept the license before install
project_source_urlstringnoneSource code repository URL
docs_urlstringnoneDocumentation URL
bug_tracker_urlstringnoneBug tracker URL
tagsstring or string[]package nameSpace-separated string or array of tags for the gallery
summarystringnoneShort summary of the package (supports templates)
release_notesstringnoneRelease notes for this version (supports templates)
dependenciesobject[]nonePackage dependencies (see below)
api_keystring$CHOCOLATEY_API_KEYChocolatey API key for choco push (supports templates)
source_repostringhttps://push.chocolatey.org/Push source URL
skip_publishboolfalseSkip pushing the .nupkg to the Chocolatey repository
disablebool or stringfalseDisable this publisher entirely. Accepts a bool or a template string that evaluates to a truthy value
usestringarchiveArtifact type to package: archive, msi, or nsis
amd64_variantstringv1amd64 microarchitecture variant filter (v1, v2, v3, v4)

Dependencies

Each entry in the dependencies array has:

FieldTypeDescription
idstringChocolatey package ID of the dependency
versionstringOptional version constraint (e.g., [1.0.0,))

API key setup

Anodizer needs a Chocolatey API key to push packages. You can provide it in two ways:

  1. Environment variable (recommended for CI): set CHOCOLATEY_API_KEY.
  2. Config field: set api_key in the chocolatey config. This field supports template rendering, so you can reference environment variables or other context values.

The environment variable is used as a fallback when api_key is not set in the config. To obtain an API key, sign in to chocolatey.org/account and generate one from your account page.

How nuspec and nupkg files are generated

When the publish stage runs for Chocolatey, Anodizer:

  1. Finds Windows artifacts from the build stage, filtering by ids and amd64_variant if configured. It looks for both 32-bit (i686/i386/x86) and 64-bit artifacts.
  2. Generates a .nuspec XML manifest containing all package metadata (name, version, authors, description, license, tags, dependencies, etc.). All XML special characters are properly escaped.
  3. Generates a chocolateyInstall.ps1 PowerShell script placed in a tools/ directory. The script uses Install-ChocolateyZipPackage with SHA-256 checksums. If both 32-bit and 64-bit artifacts are found, a dual-architecture script is generated that passes both URLs; otherwise a single-architecture script is produced.
  4. Runs choco pack to create the .nupkg file from the nuspec and tools directory.
  5. Runs choco push to upload the .nupkg to the configured source repository (defaults to https://push.chocolatey.org/).

If no Windows artifacts are found, Anodizer falls back to a placeholder GitHub release download URL and logs a warning.

skip_publish behavior

When skip_publish: true is set, Anodizer skips the entire publish function early -- no nuspec is generated, no choco pack is run, and no push occurs. This is useful when you want to define the Chocolatey config for future use without actually publishing, or when another system handles the push step.

In dry-run mode (--dry-run), Anodizer logs what it would do without generating any files or running any commands.

Full example

crates:
  - name: myapp
    publish:
      chocolatey:
        name: myapp
        repository:
          owner: myorg
          name: myapp
        title: "My App"
        authors: "My Org"
        description: "A fast CLI tool for doing things"
        license: MIT
        project_url: "https://github.com/myorg/myapp"
        icon_url: "https://raw.githubusercontent.com/myorg/myapp/main/icon.png"
        copyright: "Copyright 2026 My Org"
        tags:
          - cli
          - tool
          - devops
        summary: "A fast CLI tool"
        docs_url: "https://myorg.github.io/myapp"
        bug_tracker_url: "https://github.com/myorg/myapp/issues"
        project_source_url: "https://github.com/myorg/myapp"
        dependencies:
          - id: dotnet-runtime
            version: "[6.0,)"
        source_repo: "https://push.chocolatey.org/"
        skip_publish: false