abpframework/abp · error · Exception

Build failed!

Error message

Build failed!

What it means

Thrown by DefaultDotNetProjectBuilder.BuildSolution when the underlying 'dotnet build <sln> /graphBuild' invocation exits with a non-zero status. The build output is already printed to the console in red; this exception propagates the failure to the caller. The message is intentionally generic because the real diagnostic detail is in the captured dotnet output.

Solutions

  1. Read the dotnet output already printed above the exception to find the compile/restore error.
  2. Run 'dotnet build <slnPath> /graphBuild' manually in the same directory to reproduce and iterate faster.
  3. Restore packages ('dotnet restore') and confirm the correct SDK is installed ('dotnet --version').
  4. Fix the underlying compile error, then re-run the ABP build command.

Example fix

# before: build fails, exception thrown
abp build
# after: reproduce manually, fix the error, rebuild
dotnet build MySolution.sln /graphBuild
# ... fix reported CS errors ...
abp build
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight: confirm the SDK and solution exist before building.
if (!File.Exists(slnPath)) throw new FileNotFoundException("Solution not found: " + slnPath);
var (sdk, _) = CmdHelper.RunCmdAndGetOutput("dotnet --version", out _);
if (string.IsNullOrWhiteSpace(sdk)) throw new InvalidOperationException(".NET SDK not found on PATH.");

Try / catch

try
{
    builder.BuildSolution(slnPath, arguments);
}
catch (Exception ex) when (ex.Message == "Build failed!")
{
    logger.LogError(ex, "Solution build failed; inspect the dotnet output above for compile/restore errors.");
    throw;
}

Prevention

When it happens

Trigger: CmdHelper.RunCmdAndGetOutput runs 'dotnet build <slnPath> /graphBuild <args>' and buildStatus != 0. Triggered by compilation errors, missing SDK, restore failures, or invalid solution files during an ABP CLI build operation.

Common situations: Code compilation errors; missing or incompatible .NET SDK; NuGet restore failures (offline feed, auth); broken .sln/.slnx file; pre-existing errors in a repo when running 'abp build'; wrong working directory so the solution path is stale.

Related errors


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

Appendix: source

Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Build/DefaultDotNetProjectBuilder.cs:69

    public void BuildSolution(string slnPath, string arguments)
    {
        var buildArguments = "/graphBuild " + arguments.TrimStart('"').TrimEnd('"');
        Console.WriteLine("Executing...: dotnet build " + slnPath + " " + buildArguments);

        var output = CmdHelper.RunCmdAndGetOutput(
            "dotnet build " + slnPath + " " + buildArguments,
            out int buildStatus
        );

        if (buildStatus == 0)
        {
            WriteOutput(output, ConsoleColor.Green);
        }
        else
        {
            WriteOutput(output, ConsoleColor.Red);
            throw new Exception("Build failed!");
        }
    }

    private void BuildInternal(DotNetProjectInfo project, string arguments, ConcurrentBag<string> builtProjects)
    {
        var buildArguments = arguments.TrimStart('"').TrimEnd('"');
        Console.WriteLine("Executing...: dotnet build " + project.CsProjPath + " " + buildArguments);

        var output = CmdHelper.RunCmdAndGetOutput(
            "dotnet build \"" + project.CsProjPath + "\" " + buildArguments,
            out int buildStatus
        );

        if (buildStatus == 0)
        {
            builtProjects.Add(project.CsProjPath);
            WriteOutput(output, ConsoleColor.Green);
        }

View on GitHub (pinned to 7ed43b1931)