Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnlyWhenStatic does not skip dependencies #1296

Open
DWIAltonaAnalytics opened this issue Nov 23, 2023 · 3 comments
Open

OnlyWhenStatic does not skip dependencies #1296

DWIAltonaAnalytics opened this issue Nov 23, 2023 · 3 comments
Labels

Comments

@DWIAltonaAnalytics
Copy link

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

@matkoch
Copy link
Member

matkoch commented Nov 23, 2023

I'm expecting a complete sample.

@DWIAltonaAnalytics
Copy link
Author

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants