Skip to content

after_build_success and after_build_failure not working for me on Linux Mint 22.3 #16

@willasm

Description

@willasm

before_build however is working for me. Here is my tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "debug",
      "file": "Demo.lpr",
      "type": "fpc",
      "presentation": {
        "showReuseMessage": false,
        "clear": true,
        "revealProblems": "onProblem"
      },
      "buildOption": {
        "unitOutputDir": "./out",
        "customOptions": [
          "-dDEBUG",
          "-gw2"
        ]
      }
    },
    {
      "label": "release",
      "file": "Demo.lpr",
      "type": "fpc",
      "presentation": {
        "showReuseMessage": false,
        "clear": true,
        "revealProblems": "onProblem"
      },
      "buildOption": {
        "unitOutputDir": "./out",
        "customOptions": [
          "-dRELEASE",
          "-O2"
        ]
      },
      "buildEvent": {
        "before_build": [
          "echo Before Build Works",
        ],
        "after_build_success": [
          "echo After Build Success",
        ],
        "after_build_failure": [
          "echo After Failed Build",
        ]
      },
      "group": {
        "isDefault": true
      }
    }
  ]
}

and using the default template...

program Demo;
{$mode objfpc}{$H+}

uses
  Classes, SysUtils,
  Demounit;

begin
  WriteLn('Demo - Program with Unit Example');
  WriteLn('Created by william on 28/03/2026');
  
  // Call function from our unit
  SayHello('william');
  
  WriteLn('Current year: ', GetCurrentYear);
  
  //err
  //WriteLn('Press Enter to exit...');
  //ReadLn;
end.

The WriteLn and ReadLn at the bottom are commented out to prevent it from pausing. The commented line err is just there to force an error on build.

Result for successful build...

Image

And for build error...

Image

As you can see the echo commands are never run for after_build events? I have tried it with the before_build event removed and that made no difference. Thanks for any insight you have on this, William.

P.S. Just wanted to add I managed to get code auto-completion to work with the fpGUI Toolkit which is fantastic!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions