I am adding Entity Framework Core migrations to my Azure pipeline. After build and test I am attempting to create the migration script
- task: DotNetCoreCLI@2
displayName: 'Install EF tool'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install dotnet-ef --global --version 7.0.5'
workingDirectory: '$(Build.SourcesDirectory)'
- task: DotNetCoreCLI@2
displayName: 'Generate EF SQL Script'
inputs:
command: 'custom'
custom: 'ef'
configuration: 'release'
arguments: 'migrations script --no-build --verbose --project $(Build.SourcesDirectory)\"HR Taxonomy Change Management\HR Taxonomy Change Management.csproj" --output $(Build.SourcesDirectory)\script.sql --idempotent'
The error comes in the task Generate EF SQL Script
. It appears to look for the file in Debug? The specified deps.json [C:\__w\1\s\HR Taxonomy Change Management\bin\Debug\net6.0\HR Taxonomy Change Management.deps.json] does not exist
. The does exist in the Release folder. I hope I'm not supposed to copy the file from Release to Debug? That sounds "hacky".
Starting: Generate EF SQL Script (windows_build_container)
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.235.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
C:\Windows\system32\chcp.com 65001
Active code page: 65001
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
"C:\Program Files\dotnet\dotnet.exe" ef migrations script --no-build --verbose --project "C:\__w\1\s\HR Taxonomy Change Management\HR Taxonomy Change Management.csproj" --output C:\__w\1\s\script.sql --idempotent
Using project 'C:\__w\1\s\HR Taxonomy Change Management\HR Taxonomy Change Management.csproj'.
Using startup project 'C:\__w\1\s\HR Taxonomy Change Management\HR Taxonomy Change Management.csproj'.
Writing 'C:\__w\1\s\HR Taxonomy Change Management\obj\HR Taxonomy Change Management.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\ContainerAdministrator\AppData\Local\Temp\tmpD626.tmp /verbosity:quiet /nologo "C:\__w\1\s\HR Taxonomy Change Management\HR Taxonomy Change Management.csproj"
Writing 'C:\__w\1\s\HR Taxonomy Change Management\obj\HR Taxonomy Change Management.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\ContainerAdministrator\AppData\Local\Temp\tmpDD0D.tmp /verbosity:quiet /nologo "C:\__w\1\s\HR Taxonomy Change Management\HR Taxonomy Change Management.csproj"
dotnet exec --depsfile "C:\__w\1\s\HR Taxonomy Change Management\bin\Debug\net6.0\HR Taxonomy Change Management.deps.json" --additionalprobingpath C:\Users\ContainerAdministrator\.nuget\packages --additionalprobingpath "C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages" C:\Users\ContainerAdministrator\.dotnet\tools\.store\dotnet-ef\7.0.5\dotnet-ef\7.0.5\tools\net6.0\any\tools\netcoreapp2.0\any\ef.dll migrations script --output C:\__w\1\s\script.sql --idempotent --assembly "C:\__w\1\s\HR Taxonomy Change Management\bin\Debug\net6.0\HR Taxonomy Change Management.dll" --project "C:\__w\1\s\HR Taxonomy Change Management\HR Taxonomy Change Management.csproj" --startup-assembly "C:\__w\1\s\HR Taxonomy Change Management\bin\Debug\net6.0\HR Taxonomy Change Management.dll" --startup-project "C:\__w\1\s\HR Taxonomy Change Management\HR Taxonomy Change Management.csproj" --project-dir "C:\__w\1\s\HR Taxonomy Change Management\\" --root-namespace HR_Taxonomy_Change_Management --language C# --framework net6.0 --nullable --working-dir C:\__w\1\s --verbose
The specified deps.json [C:\__w\1\s\HR Taxonomy Change Management\bin\Debug\net6.0\HR Taxonomy Change Management.deps.json] does not exist
##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 2147516545
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
##[error]Dotnet command failed with non-zero exit code on the following projects : [ '' ]
Finishing: Generate EF SQL Script (windows_build_container)
Update: @AlvinZhao asked about the build task and it is set to Release:
- task: MSBuild@1
displayName: 'ChgMgmt Build'
inputs:
solution: '$(Build.SourcesDirectory)\HR Taxonomy Change Management\*.csproj'
msbuildLocationMethod: 'version'
msbuildVersion: 'latest'
platform: 'x64'
configuration: 'release'
msbuildArguments: '/v:n /nr:false /flp1:Verbosity=d;LogFile=$(OUTPUTROOT)\logs\msbuild_x64_release.log;Encoding=UTF-8 /flp2:logfile=$(OUTPUTROOT)\logs\msbuild_x64_release.err;errorsonly /bl:$(OUTPUTROOT)\logs\msbuild_x64_release.binlog'
clean: true
maximumCpuCount: true
logProjectEvents: true
createLogFile: true
The solution turned out to be as simple as removing the --no-build
argument in the Generate EF SQL Script
task