I have a Devops pipeline which used to run under a windows-latest
agent. We’ve recently moved it to ubuntu-latest
for a variety of reasons. However since that change, the dotnet-ef
tool has not been outputting the migrations SQL script to the artifacts folder.
This is the (simplified) YML for the pipeline:
trigger:
- dev
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet@2
displayName: 'Use .NET8 SDK'
inputs:
useGlobalJson: false
packageType: sdk
version: 8.x
includePreviewVersions: false
- task: CmdLine@2
displayName: "Build EF Migrations"
inputs:
script: |
dotnet tool install --global dotnet-ef --version 8.0.7
dotnet ef migrations script -p FooBar.Domain -s FooBar.API -o "$(System.DefaultWorkingDirectory)/ef-migrations.sql" -i -v
# other build stages....
- task: PublishBuildArtifacts@1
displayName: "Publish Artifacts"
inputs:
artifactName: 'drop'
The step in the pipeline works fine with no errors in the log. In fact, the output states it has created the file:
Writing ‘/home/vsts/work/1/s/ef-migrations.sql’…
Finishing: Build EF Migrations
The issue is that the Artifacts folder contains no reference to that file:
Can anyone tell me why this is happening?
4
According to your PublishBuildArtifacts@1
task, the PathtoPublish
is the default value $(Build.ArtifactStagingDirectory)
, which is /home/vsts/work/1/a
.
According to your scripts -o "$(System.DefaultWorkingDirectory)/ef-migrations.sql
, your ef-migrations.sql
is in $(System.DefaultWorkingDirectory)
, which is /home/vsts/work/1/s
Copy your ef-migrations.sql
to $(Build.ArtifactStagingDirectory)
before publishing build artifact.
- task: CmdLine@2
displayName: "Build EF Migrations"
inputs:
script: |
dotnet tool install --global dotnet-ef --version 8.0.7
dotnet ef migrations script -p FooBar.Domain -s FooBar.API -o "$(System.DefaultWorkingDirectory)/ef-migrations.sql" -i -v
cp ef-migrations.sql $(Build.ArtifactStagingDirectory)
2