nuke icon indicating copy to clipboard operation
nuke copied to clipboard

OnlyWhenStatic does not skip dependencies

Open DWIAltonaAnalytics opened this issue 2 years ago β€’ 3 comments

Usage Information

7.0.6 / 8.0.100 / Net. 7.0 / Windows

Description

according to documentation OnlyWhenStatic should by default skip a task and all it's dependencies.

Reproduction Steps

Create a task like in the documentation, without the WhenSkipped declaration or with it set to skip WhenSkipped(DependencyBehavior.Skip).

Expected Behavior

No Task should run

Actual Behavior

Task A is run

Regression?

No response

Known Workarounds

No response

Could you help with a pull-request?

No

DWIAltonaAnalytics avatar Nov 23 '23 10:11 DWIAltonaAnalytics

I'm expecting a complete sample.

matkoch avatar Nov 23 '23 13:11 matkoch

all right:

class Build : NukeBuild
{
    /// Support plugins are available for:
    ///   - JetBrains ReSharper        https://nuke.build/resharper
    ///   - JetBrains Rider            https://nuke.build/rider
    ///   - Microsoft VisualStudio     https://nuke.build/visualstudio
    ///   - Microsoft VSCode           https://nuke.build/vscode

    public static int Main () => Execute<Build>(x => x.Compile);

    Target Restore => _ => _
        .Executes(() =>
        {
            Log.Error("this should not run");
        });

    Target Compile => _ => _
        .OnlyWhenStatic(()=>IsServerBuild)
        .DependsOn(Restore)
        .Executes(() =>
        {
            Log.Warning("this shouldn't run either");
        });

}

I would expect both targets to be skipped if I run nuke localy.

but what I get is:

PowerShell Desktop version 5.1.19041.3693
Microsoft (R) .NET SDK version 8.0.100
​
β–ˆβ–ˆβ–ˆβ•—Β Β Β β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—Β Β Β β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—Β Β β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—                                   
β–ˆβ–ˆβ–ˆβ–ˆβ•—Β Β β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘Β Β Β β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘Β β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β•β•β•                                   
β–ˆβ–ˆβ•”β–ˆβ–ˆβ•—Β β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘Β Β Β β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•Β β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—Β Β                                    
β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘Β Β Β β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•—Β β–ˆβ–ˆβ•”β•β•β•Β Β                                    
β–ˆβ–ˆβ•‘Β β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘Β Β β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—                                   
β•šβ•β•Β Β β•šβ•β•β•β•Β β•šβ•β•β•β•β•β•Β β•šβ•β•Β Β β•šβ•β•β•šβ•β•β•β•β•β•β•                                   
​                                                                     
NUKE Execution Engine version 7.0.6 (Windows,.NETCoreApp,Version=v7.0)
​                                                                     
​
╬════════════
β•‘ Restore
╬═══
​
16:19:38 [ERR] this should not run
​
╬══════════════════════
β•‘ Errors & Warnings
╬═════════════
​
[ERR] Restore: this should not run
​
═══════════════════════════════════════
TargetΒ Β Β Β Β Β Β Β Β Β Β Β Β StatusΒ Β Β Β Β Β Duration
───────────────────────────────────────
RestoreΒ Β Β Β Β Β Β Β Β Β Β Β SucceededΒ Β Β Β Β < 1sec
CompileΒ Β Β Β Β Β Β Β Β Β Β Β SkippedΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β // OnlyWhen: IsServerBuild
───────────────────────────────────────
TotalΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β < 1sec
═══════════════════════════════════════
​
Build succeeded on 23.11.2023 16:19:38. οΌΌοΌˆοΌΎα΄—οΌΎοΌ‰οΌ

DWIAltonaAnalytics avatar Nov 23 '23 15:11 DWIAltonaAnalytics

strangely, it worked on our gitlab runner as expected:

CleanCoverage Skipped // Skipped: because of CleanAll CleanAll Skipped // OnlyWhen: Rebuild

will test locally again and close if confirmed fixed.

DWIAltonaAnalytics avatar Dec 04 '23 08:12 DWIAltonaAnalytics