{"record":{"id":"e34db8a7d600c6be","repo":"chocolatey/choco","slug":"package-name-cannot-point-directly-to-a-package-ma","errorCode":null,"errorMessage":"Package name cannot point directly to a package manifest file. Please create a package by running 'choco pack' on the .nuspec file first.","messagePattern":"Package name cannot point directly to a package manifest file\\. Please create a package by running 'choco pack' on the \\.nuspec file first\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs","lineNumber":1343,"sourceCode":"                    {\r\n                        var fullPath = _fileSystem.GetFullPath(packageName);\r\n\r\n                        if (!string.IsNullOrWhiteSpace(fullPath) && Uri.TryCreate(fullPath, UriKind.Absolute, out uri))\r\n                        {\r\n                            ThrowInvalidPathError(uri.LocalPath, uri.IsUnc, config.CommandName);\r\n                        }\r\n\r\n                        ThrowInvalidPathError(fullPath, isUncPath: false, commandName: config.CommandName);\r\n                    }\r\n                    else\r\n                    {\r\n                        throw new ApplicationException(\"Package name cannot point directly to a local, or remote file. Please use the --source argument and point it to a local file directory, UNC directory path or a NuGet feed instead.\");\r\n\r\n                    }\r\n                }\r\n                else if (packageName.EndsWith(NuGetConstants.ManifestExtension))\r\n                {\r\n                    throw new ApplicationException(\"Package name cannot point directly to a package manifest file. Please create a package by running 'choco pack' on the .nuspec file first.\");\r\n\r\n                }\r\n            }\r\n        }\r\n\r\n        private void ThrowInvalidPathError(string packageName, bool isUncPath, string commandName)\r\n        {\r\n            var sb = new StringBuilder(\"Package name cannot be a path to a file \");\r\n\r\n            if (isUncPath)\r\n            {\r\n                sb.AppendLine(\"on a UNC location.\")\r\n                  .AppendLine()\r\n                  .Append(\"To \")\r\n                  .Append(commandName.ToLowerSafe())\r\n                  .AppendLine(\" a file in a UNC location, you may use:\");\r\n            }\r\n            else\r","sourceCodeStart":1325,"sourceCodeEnd":1361,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs#L1325-L1361","documentation":"Thrown as an ApplicationException during ValidatePackageNames when a package name ends with '.nuspec' (NuGetConstants.ManifestExtension). A .nuspec is a package manifest/source file — it must first be packed into a .nupkg using 'choco pack' before it can be installed. Passing a .nuspec directly as a package name to install/upgrade/uninstall is unsupported.","triggerScenarios":"Calling install/upgrade/uninstall with config.PackageNames containing a value ending in '.nuspec'. The code checks the extension immediately after the .nupkg branch and throws unconditionally for .nuspec files.","commonSituations":"A user runs 'choco install mypackage.nuspec' or 'choco install .\\mypackage.nuspec' trying to install from a manifest. They need to pack it first: 'choco pack mypackage.nuspec' produces a .nupkg which can then be installed via --source.","solutions":["Pack the .nuspec into a .nupkg first: 'choco pack mypackage.nuspec'.","Then install from the directory containing the packed .nupkg: 'choco install mypackage --source=C:\\build\\output'.","If the .nuspec is in the current directory, run 'choco pack' then 'choco install mypackage --source=.'."],"exampleFix":"// before: trying to install directly from a manifest\nchoco install mypackage.nuspec\n\n// after: pack first, then install\nchoco pack mypackage.nuspec\nchoco install mypackage --source=.","handlingStrategy":"validation","validationCode":"// Before calling install/upgrade, validate package names are not .nuspec files\nforeach (var name in config.PackageNames.Split(';'))\n{\n    if (name.EndsWith(NuGetConstants.ManifestExtension, StringComparison.OrdinalIgnoreCase))\n    {\n        throw new InvalidOperationException(\n            $\"'{name}' is a .nuspec manifest. Pack it first with 'choco pack {name}', then install from the output directory.\");\n    }\n}","typeGuard":"public static bool IsValidPackageName(string packageName)\n{\n    return !packageName.EndsWith(\".nuspec\", StringComparison.OrdinalIgnoreCase);\n}","tryCatchPattern":"try\n{\n    _packageService.Install(config);\n}\ncatch (ApplicationException ex) when (ex.Message.Contains(\"package manifest file\"))\n{\n    logger.Error(\"Cannot install .nuspec directly. Run 'choco pack' first to create a .nupkg.\");\n}","preventionTips":["Always pack .nuspec files into .nupkg before attempting installation.","Run 'choco pack' in the directory containing the .nuspec to produce the installable .nupkg.","Validate package names to ensure they are plain IDs, not file names."],"tags":["package-name","validation","nuspec","pack","chocolatey"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}