azureazure-devopsdotnet-tool

How to ensure a "dotnet tool" is installed in an Azure Pipeline?


In a Azure Devop Build, I'm using a tool(https://github.com/tomchavakis/nuget-license). I want this tool to be installed in my Azure Devop Agent.

I've created this task in my YML:

  - task: CmdLine@2
    displayName: 'Install dotnet-project-licenses'
    inputs:
        script: 'dotnet tool install dotnet-project-licenses -g'

This works, but only the first time. Then when the tool is already installed, I get an error code.

So how to install this automatically on my agents once? Or swallow the error?


Solution

  • Try running the script as

    dotnet tool update dotnet-project-licenses -g
    

    If the tool isn't installed this command should install it, and if it is already installed it shouldn't give an error