chocolatey/choco · error · ApplicationException

Automatic package creation from installer files only availab

Error message

Automatic package creation from installer files only available in Business
 edition. See https://chocolatey.org/compare for details.

What it means

Thrown by ChocolateyNewCommand.Validate when the user passes a package name that starts with '-file' or '--file'. This triggers the automatic package creation from installer files feature, which is licensed only for Chocolatey Business edition. The open-source/free build refuses it and points the user to the comparison page. The check is a naive string-prefix match on configuration.NewCommand.Name, so any name beginning with those flags is rejected.

Source

Thrown at src/chocolatey/infrastructure.app/commands/ChocolateyNewCommand.cs:114

                    }
                    else
                    {
                        configuration.NewCommand.TemplateProperties.Add(propName, propValue);
                    }
                }
            }
        }

        public virtual void Validate(ChocolateyConfiguration configuration)
        {
            if (string.IsNullOrWhiteSpace(configuration.NewCommand.Name))
            {
                throw new ApplicationException("Name is required. Please pass in a name for the new package.");
            }

            if (configuration.NewCommand.Name.StartsWith("-file", StringComparison.OrdinalIgnoreCase) || configuration.NewCommand.Name.StartsWith("--file", StringComparison.OrdinalIgnoreCase))
            {
                throw new ApplicationException(@"Automatic package creation from installer files only available in Business
 edition. See https://chocolatey.org/compare for details.");
            }
        }

        public virtual void HelpMessage(ChocolateyConfiguration configuration)
        {
            this.Log().Info(ChocolateyLoggers.Important, "New Command");
            this.Log().Info(@"
Chocolatey will generate package specification files for a new package.
");

            "chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
            "chocolatey".Log().Info(@"
    choco new <name> [<options/switches>] [<property=value> <propertyN=valueN>]

Possible properties to pass:
    packageversion
    maintainername

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. If you need automatic package creation from installer files, obtain a Chocolatey Business license and install the licensed extension.
  2. If you do not have a Business license, create the package skeleton manually with 'choco new <pkgname>' (without --file) and fill in the install logic yourself.
  3. Ensure the package name does not accidentally begin with '-file' or '--file' due to argument mis-ordering.

Example fix

// before
choco new mypkg --file="installer.exe"
// after (FOSS edition — manual skeleton)
choco new mypkg
// then edit tools/chocolateyInstall.ps1 to invoke installer.exe
Defensive patterns

Strategy: validation

Validate before calling

// Before calling choco new, verify you are not triggering the --file path
// unless you have a Business license
if (!hasBusinessLicense && (packageName.StartsWith("--file", StringComparison.OrdinalIgnoreCase) || packageName.StartsWith("-file", StringComparison.OrdinalIgnoreCase)))
{
    Console.Error.WriteLine("Automatic package creation from installers requires Business edition.");
    return;
}

Type guard

static bool CanAutoGenerateFromInstaller(bool hasBusinessLicense) => hasBusinessLicense;

Prevention

When it happens

Trigger: Running 'choco new <pkg> --file=<installer>' or 'choco new <pkg> -file=<installer>' in the free/open-source edition of Chocolatey. Also triggered if a package name literally begins with the strings '-file' or '--file' for any reason.

Common situations: A developer on Chocolatey FOSS edition tries to auto-generate a .nuspec/spec from an existing .exe/.msi installer and passes --file. The free edition does not include the Package Internalizer / automatic package generator; that is a Business (licensed) feature.

Related errors


AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13). Data as JSON: /api/errors/a6fb632a4f0b48b7. Report an issue: GitHub.