OnlyWhenStatic does not skip dependencies
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
I'm expecting a complete sample.
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. οΌΌοΌοΌΎα΄οΌΎοΌοΌ
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.