nuke-build / nuke

🏗 The AKEless Build System for C#/.NET
https://nuke.build
MIT License
3.07k stars 369 forks source link

ArgumentException when static and dynamic conditions of an invoked target are violated #1385

Closed chrisft closed 2 months ago

chrisft commented 6 months ago

Usage Information

8.0.0 / 8.0.202 / net8.0 / windows10

Description

ArgumentException when static and dynamic conditions of an invoked target are violated.

The invoked target is not marked as skipped after the evaluation of its static conditions (but the SummaryInformation for OnlyWhen is added). When the target is executed and its dynamic conditions are evaluated the SummaryInformation for OnlyWhen is added again which throws: System.ArgumentException: An item with the same key has already been added. Key: OnlyWhen

Reproduction Steps

using Nuke.Common;

class Build : NukeBuild
{
    public static int Main () => Execute<Build>(x => x.Repro);

    Target Repro => _ => _
        .OnlyWhenStatic(() => false, "static")
        .OnlyWhenDynamic(() => false, "dynamic");
}

Expected Behavior

No Exception. Target is skipped.

Actual Behavior

Repro_Screenshot

Regression?

No response

Known Workarounds

Only use static OR dynamic conditions for target.

Could you help with a pull-request?

No