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 is not working on dependencies with default interface and TryDependsOn<> #1322

Open
m21-cerutti opened this issue Jan 29, 2024 · 0 comments
Labels

Comments

@m21-cerutti
Copy link

m21-cerutti commented Jan 29, 2024

Usage Information

Nuke version 8.0.0, .NET SDK version 8.0.101, .NET 8, Windows

Description

Trying to make a pipeline library for Nuke Build, with default pipeline and target dependency, when I fall inside a specific edge case with Build Components. Seems like TryDependsOn<> not assure to skip the target if the dependency is skipped when using interfaces.
Thinks it's linked to #1296 and available on Discord for more information.

Reproduction Steps

For easy reproduction :
https://gitlab.com/neitherlands/ouroboros/-/tree/test/dependency-nuke?ref_type=heads

Otherwise :

  1. Make two interface, one depending on the other
  2. Implement explicitly the interface in the Build
    Should look like that
using Nuke.Common;
using Nuke.Common.Execution;
using Serilog;

public interface ISkipped : INukeBuild
{
    public Target Skipped => _ => _
        .Executes(() => { Log.Information("Skipped"); });
}

public interface ITest : INukeBuild
{
    public Target Test => _ => _
        .TryDependsOn<ISkipped>()
        .Executes(() => { Log.Information("Test"); });
}

[UnsetVisualStudioEnvironmentVariables]
public class Build : NukeBuild, ISkipped, ITest
{
    public static int Main() => Execute<Build>(x => x.All);

    public Target All => _ => _
        .Triggers<ITest>();

    Target ISkipped.Skipped => _ => _
            .OnlyWhenStatic(() => !IsLocalBuild)
            .WhenSkipped(DependencyBehavior.Skip)
            .Inherit<ISkipped>();
}
  1. Then run in local

Expected Behavior

All targets would be skipped.

Actual Behavior

Test is not skipped.
image

Regression?

No response

Known Workarounds

Using a interface dependency with a function that checks SkippedTargets collection and see a particular step is skipped, than using it with OnlyWhenStatic on others targets.

Could you help with a pull-request?

Yes

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

1 participant