Skip to content

Is there a way to invoke InstallTool depending on the targets that will be run? #4317

Answered by pascalberger
paulomorgado asked this question in Q&A
Discussion options

You must be logged in to vote

In Cake Frosting the IToolInstaller service can be used in a task:

[TaskName("MyTask")]
public sealed class MyTask : FrostingTask<BuildContext>
{
    private readonly IServiceProvider _provider;

    public MyTask(IServiceProvider provider)
    {
        _provider = provider;
    }

    public override void Run(BuildContext context)
    {
        var toolInstaller = (IToolInstaller)provider.GetService(typeof(IToolInstaller));
        toolInstaller.Install(new PackageReference("nuget:?package=MyPackage&version=1.0.0"));
    }
}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@paulomorgado
Comment options

@nils-a
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by paulomorgado
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants