Search code examples
azure-devopsazure-pipelinesazure-pipelines-yaml

Relative merits of more specific Azure DevOps pipeline task and more general one


Is there any reason why this:

  - task: DotNetCoreCLI@2
    displayName: Apply EF database migrations
    inputs:
      command: custom
      custom: ef
      arguments: 'database update --project .\MyProject'

is better or worse than

  - task: CmdLine@2
    displayName: Apply EF database migrations
    inputs:
      script: |
        dotnet ef database update --project .\My.Project

They both work and appear to do the same thing. The advantage I see to the latter is that it directly uses the command I run locally to apply migrations that I've generated to the development database on my local machine, without having to break that command into pieces.


Solution

  • Generally, they achieve the same results. For their differences, you may consider the following:

    For DotNetCoreCLI@2 Task

    For CmdLine@2 Task

    • You can run any command as you would in a local terminal. If you already have a script that works locally, you can reuse it without modification, making it simpler and quicker to set up.

    • This task is more generic and might not provide the detailed logging for .NET-specific commands compared to DotNetCoreCLI@2 Task.

    You can choose a task based on your actual needs and scenarios.