Scripts2026年5月13日·1 分钟阅读

Chocolatey — Automation Package Manager for Windows

Chocolatey is a machine-level package manager for Windows software that automates installation, upgrade, and configuration of applications using PowerShell and NuGet packaging infrastructure. It offers a community-curated repository with thousands of packages.

Introduction

Chocolatey brought Linux-style package management to Windows years before WinGet existed. It wraps native Windows installers (MSI, EXE, MSIX) in NuGet packages, adding silent install flags, checksums, and dependency resolution. Thousands of community-maintained packages are available on the Chocolatey Community Repository.

What Chocolatey Does

  • Installs, upgrades, and uninstalls Windows software silently from the command line
  • Resolves dependencies between packages automatically
  • Verifies package integrity using checksums built into each package
  • Supports both community repository and self-hosted private feeds
  • Integrates with configuration management tools like Ansible, Puppet, and Chef

Architecture Overview

Chocolatey extends the NuGet packaging format with a chocolateyInstall.ps1 script inside each package. When you run choco install, the client downloads the .nupkg from a configured feed, extracts it, and executes the install script which typically downloads the actual software installer and runs it silently. Packages are tracked in a local lib directory. The client is a .NET application that provides CLI commands for install, upgrade, uninstall, search, and configuration management.

Self-Hosting & Configuration

  • Install with a single PowerShell script in an elevated terminal
  • Configure alternative feed sources for enterprise or private repositories
  • Set default parameters like automatic confirmation and proxy settings in chocolatey.config
  • Use packages.config XML files to declare and install a set of packages in one command
  • Deploy across machines using Group Policy, SCCM, or automation tools

Key Features

  • Largest Windows package repository with thousands of community packages
  • Enterprise edition adds package internalization, CDN, and audit features
  • Seamless integration with DevOps tools (Ansible, Puppet, Chef, DSC)
  • Runtime checks and virus scanning on the community repository
  • Package builder and package internalizer for air-gapped environments

Comparison with Similar Tools

  • WinGet — newer, Microsoft-backed, but smaller ecosystem and fewer enterprise controls
  • Scoop — user-level portable installs without admin, but smaller catalog for system-level software
  • Ninite — GUI-only batch installer with no CLI, scripting, or customization
  • MSYS2 / pacman — targets Unix toolchains on Windows rather than general Windows apps

FAQ

Q: Is Chocolatey free? A: The open-source CLI (choco) and the community repository are free. Chocolatey for Business adds enterprise features under a commercial license.

Q: Does it need admin rights? A: Most packages require elevation because they install system-wide. A non-admin mode exists for portable packages but covers fewer apps.

Q: Can I host my own package feed? A: Yes. Any NuGet-compatible feed works as a Chocolatey source, including ProGet, Nexus, Artifactory, or a simple file share.

Q: How does Chocolatey handle updates? A: Run choco upgrade all to update every installed package. You can pin specific packages to prevent unwanted upgrades.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产