We script EntityFramework Core migrations as part of our Azure DevOps build pipelines. (The corresponding release pipeline then executes the migrations.) Our build pipelines reuse a single Task Group. Within that Task Group, we create the migrations using a PowerShell task:
if (("$(filePathToProjFolder)" -ne "-") -and ("$(dbcontexts)" -ne "-"))
{
dotnet tool install --global dotnet-ef
$dbcontexts = "$(dbcontexts)" -split "\|"
foreach ($dbcontext in $dbcontexts)
{
dotnet ef migrations script -i -o $(build.artifactstagingdirectory)\migrations-$dbcontext.sql --project $(filePathToProjFolder) --context $dbcontext --no-build
}
}
One pipeline works just fine, but the other in particular results in an error:
The specified deps.json
[C:\agents\dev\_work\237\s\<projectName>\bin\Debug\net8.0\<projectName>.deps.json] does not exist
Verbose logging has confirmed that the working build pipeline generates both the Release and Debug DLLs, but the failing build pipeline only generates the Release DLLs.
The build pipelines are Classic Pipelines, not YAML, but the corresponding YAML for the build task is:
steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
projects: '**/*.csproj'
arguments: '--configuration $(BuildConfiguration) --no-restore'
Turns out the cause was the --no-build
parameter at the tail end of my dotnet ef migrations script
command. Removing that parameter resolved the problem.