abpframework/abp · error · CliUsageException

' ' nuget package could not be found!

Error message

'{packageName}' nuget package could not be found!

What it means

FindNugetPackageInfoAsync GETs www.abp.io/api/app/nugetPackage/byName/?name=<packageName> and throws a CliUsageException on 404 NotFound. The catalog does not know the package name; other non-success codes go to RemoteServiceExceptionHandler. Mirrors the NPM equivalent (error 205) but for NuGet metadata.

Solutions

  1. Confirm the exact NuGet package name (e.g. 'Volo.Abp.AspNetCore.Mvc') on nuget.org or ABP docs and re-run.
  2. Upgrade the ABP CLI so the catalog lookup reflects current package names.
  3. If the package is not an ABP module, install it directly with 'dotnet add package <name>'.

Example fix

// before
abp add-package Volo.Abp.Mvc   // wrong name
// after
abp add-package Volo.Abp.AspNetCore.Mvc
Defensive patterns

Strategy: validation

Validate before calling

using var http = new HttpClient();
var resp = await http.GetAsync($"https://www.abp.io/api/app/nugetPackage/byName/?name={packageName}");
if (resp.StatusCode == HttpStatusCode.NotFound)
{ Console.Error.WriteLine($"NuGet package '{packageName}' not in catalog."); return; }

Try / catch

try { await ProjectNugetPackageAdder.AddAsync(packageName); }
catch (CliUsageException ex) when (ex.Message.Contains("nuget package could not be found"))
{ Console.Error.WriteLine(ex.Message); }

Prevention

When it happens

Trigger: Running 'abp add-package <nugetName>' where <nugetName> is not in the ABP NuGet package catalog, or calling ProjectNugetPackageAdder with an unknown package identifier.

Common situations: Typo in the package name; third-party package not registered with ABP; package only in a newer catalog than the CLI version; confusing a module name with its NuGet package name.

Related errors


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/d09cbf5b1a29d46b. Report an issue: GitHub.

Appendix: source

Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/ProjectNugetPackageAdder.cs:376

    {
        var projectFileContent = File.ReadAllText(projectFile);
        return SolutionPackageVersionFinder.TryParseVersionFromCsprojFile(projectFileContent, out var version)
            ? version
            : null;
    }

    protected virtual async Task<NugetPackageInfo> FindNugetPackageInfoAsync(string packageName)
    {
        var url = $"{CliUrls.WwwAbpIo}api/app/nugetPackage/byName/?name=" + packageName;
        var client = _cliHttpClientFactory.CreateClient();

        using (var response = await client.GetAsync(url, _cliHttpClientFactory.GetCancellationToken()))
        {
            if (!response.IsSuccessStatusCode)
            {
                if (response.StatusCode == HttpStatusCode.NotFound)
                {
                    throw new CliUsageException($"'{packageName}' nuget package could not be found!");
                }

                await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response);
            }

            var responseContent = await response.Content.ReadAsStringAsync();
            return JsonSerializer.Deserialize<NugetPackageInfo>(responseContent);
        }
    }

    protected virtual async Task RunBundleForBlazorAsync(string projectFile)
    {
        var args = new CommandLineArgs("bundle");

        args.Options.Add(BundleCommand.Options.WorkingDirectory.Short, Path.GetDirectoryName(projectFile));
        args.Options.Add(BundleCommand.Options.ForceBuild.Short, string.Empty);

        await BundleCommand.ExecuteAsync(args);

View on GitHub (pinned to 7ed43b1931)