1

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
  • I'm getting this too. Did you ever resolve it? My set up looks the same as yours. – LPQ Jun 27 '22 at 14:43
  • @LPQ I contacted the developer who published the article and this was his response => "Make sure all the package references in the project file are aligned with the SDK version." Unfortunately, I have been swamped and have not had the time to try to resolve the issue myself. Give it a try and let me know if it works out for you. – Sechaba Motaung Jun 29 '22 at 13:09
  • I managed to resolve this. In my YAML I was setting the PackageID of my project to something that was ambiguous. I removed that line to leave it as the defaults and then my migration script would build. – LPQ Jun 30 '22 at 16:39

1 Answers1

0

Please make sure when you run the command dotnet ef migration add IntitailCreate -s API -p Persistence then your working directory should be the parent directory.

-- Your_project |_ API |_ Persistence |_ Domain

so you need to open your terminal in Your_project Folder