{"record":{"id":"0f88a4cdcc5fc064","repo":"abpframework/abp","slug":"build-failed","errorCode":null,"errorMessage":"Build failed!","messagePattern":"Build failed!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Build/DefaultDotNetProjectBuilder.cs","lineNumber":69,"sourceCode":"\n    public void BuildSolution(string slnPath, string arguments)\n    {\n        var buildArguments = \"/graphBuild \" + arguments.TrimStart('\"').TrimEnd('\"');\n        Console.WriteLine(\"Executing...: dotnet build \" + slnPath + \" \" + buildArguments);\n\n        var output = CmdHelper.RunCmdAndGetOutput(\n            \"dotnet build \" + slnPath + \" \" + buildArguments,\n            out int buildStatus\n        );\n\n        if (buildStatus == 0)\n        {\n            WriteOutput(output, ConsoleColor.Green);\n        }\n        else\n        {\n            WriteOutput(output, ConsoleColor.Red);\n            throw new Exception(\"Build failed!\");\n        }\n    }\n\n    private void BuildInternal(DotNetProjectInfo project, string arguments, ConcurrentBag<string> builtProjects)\n    {\n        var buildArguments = arguments.TrimStart('\"').TrimEnd('\"');\n        Console.WriteLine(\"Executing...: dotnet build \" + project.CsProjPath + \" \" + buildArguments);\n\n        var output = CmdHelper.RunCmdAndGetOutput(\n            \"dotnet build \\\"\" + project.CsProjPath + \"\\\" \" + buildArguments,\n            out int buildStatus\n        );\n\n        if (buildStatus == 0)\n        {\n            builtProjects.Add(project.CsProjPath);\n            WriteOutput(output, ConsoleColor.Green);\n        }","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Build/DefaultDotNetProjectBuilder.cs#L51-L87","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the dotnet output already printed above the exception to find the compile/restore error.","Run 'dotnet build <slnPath> /graphBuild' manually in the same directory to reproduce and iterate faster.","Restore packages ('dotnet restore') and confirm the correct SDK is installed ('dotnet --version').","Fix the underlying compile error, then re-run the ABP build command."],"exampleFix":"# before: build fails, exception thrown\nabp build\n# after: reproduce manually, fix the error, rebuild\ndotnet build MySolution.sln /graphBuild\n# ... fix reported CS errors ...\nabp build","handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm the SDK and solution exist before building.\nif (!File.Exists(slnPath)) throw new FileNotFoundException(\"Solution not found: \" + slnPath);\nvar (sdk, _) = CmdHelper.RunCmdAndGetOutput(\"dotnet --version\", out _);\nif (string.IsNullOrWhiteSpace(sdk)) throw new InvalidOperationException(\".NET SDK not found on PATH.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    builder.BuildSolution(slnPath, arguments);\n}\ncatch (Exception ex) when (ex.Message == \"Build failed!\")\n{\n    logger.LogError(ex, \"Solution build failed; inspect the dotnet output above for compile/restore errors.\");\n    throw;\n}","preventionTips":["Run 'dotnet restore' and 'dotnet build' locally before invoking 'abp build'.","Pin the .NET SDK version (global.json) to avoid environment drift.","Keep the working directory at the solution root.","Treat compile errors as failures in CI so the ABP build is only the final step."],"tags":["cli","build","dotnet","compilation"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}