'.NET Core Create SQL scripts task failing in azure pipeline - Unable to retrieve project metadata error

I had a perfectly working pipeline for my API project where I followed the below tutorial. https://dotnetthoughts.net/run-ef-core-migrations-in-azure-devops/

From this, I made a change to get a NuGet package(Class Library) from a private feed at the restore task. Now I am getting the following error when I try to create scripts for my DB context.

Unable to retrieve project metadata. Ensure it's an SDK-style project. If you're using a custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.

Please assist. Here is my YAML:

steps:
- task: DotNetCoreCLI@2
  displayName: 'Create Manifest File'
  inputs:
    command: custom
    custom: new
    arguments: 'tool-manifest'

- task: DotNetCoreCLI@2
  displayName: 'Install EF Tool'
  inputs:
    command: custom
    custom: tool
    arguments: 'install dotnet-ef'

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 6.0.x'
  inputs:
    version: 6.0.x
    performMultiLevelLookup: true

- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: restore
    projects: '**/*.csproj'
    vstsFeed: 'myFeed'

- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    projects: '**/*.csproj'
    arguments: '--configuration $(BuildConfiguration)'

- task: DotNetCoreCLI@2
  displayName: Test
  inputs:
    command: test
    projects: '$(Parameters.TestProjects)'
    arguments: '--configuration $(BuildConfiguration)'

- task: DotNetCoreCLI@2
  displayName: Publish
  inputs:
    command: publish
    publishWebProjects: false
    projects: '$(Parameters.RestoreBuildProjects)'
    arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
    zipAfterPublish: True

- task: DotNetCoreCLI@2
  displayName: 'Create SQL Scripts'
  inputs:
    command: custom
    custom: ef
    arguments: 'migrations script --output $(Build.SourcesDirectory)/SQL/cotripdbscript.sql --idempotent --project $(Build.SourcesDirectory)/CoTrip_.csproj --context ApplicationDbContext'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
  condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact - SQL Migration Script'
  inputs:
    PathtoPublish: '$(Build.SourcesDirectory)/SQL/cotripdbscript.sql'
    ArtifactName: SQLScripts


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source