1

I'm generating ef migration scripts in azure pipelines, for that I'm performing the following tasks:

- task: DotNetCoreCLI@2
  displayName: Install EF Tool
  inputs:
    command: custom
    custom: 'tool'
    arguments: 'install --global dotnet-ef'
- task: DotNetCoreCLI@2
    displayName: Create SQL Scripts
    inputs:
      command: custom
      custom: 'ef '
      nugetConfigPath: '$(Build.SourcesDirectory)/${{ parameters.nugetConfigPath }}'        
      arguments: 'migrations script  --output $(Build.ArtifactStagingDirectory)/sql/sqlscript.sql --idempotent --project $(Build.SourcesDirectory)/${{ parameters.startupProjectPath }}  --context AdministrationMigrationDBContext

For the first time when I run the pipeline, the sql script generated successfully. But the next time I'm getting the following error:

enter image description here

I'm getting an error while installing dotnet-ef saying "Tool dotnet-ef already installed". Can someone help me in resolving this?

Luke
  • 743
  • 6
  • 20
Abi Reddy
  • 79
  • 5
  • Self-hosted runner? Tool caching? Operating system? Containerized runner or does runner retain its changes between runs? – jikuja Oct 08 '22 at 23:05

1 Answers1

0

You can use dotnet tool update, which acording to the docs basically re-installs the tool:

The dotnet tool update command provides a way for you to update .NET tools on your machine to the latest stable version of the package. The command uninstalls and reinstalls a tool, effectively updating it.

Mr Patience
  • 1,564
  • 16
  • 30