1
votes

I have a simple build pipeline that triggers on my git commit and is working great.

Here is the .yaml for that process:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:
  - script: dotnet build --configuration $(buildConfiguration)
  - task: ArchiveFiles@2
inputs:
  rootFolderOrFile: '$(Build.BinariesDirectory)'
  includeRootFolder: true
  archiveType: 'zip'
  archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
  replaceExistingArchive: true
  displayName: 'dotnet build $(buildConfiguration)'

Then, I tried to make a Release build, but can't get the zip file across to my deploy step. The steps I follow are:

  1. Publish build artifacts
  2. Download build artifacts
  3. Deploy web service

Here is my setup - Overall release pipeline:

enter image description here

Artifact Stage setup as follow:

enter image description here

Here is my 3 tasks in the Stage 1 (Deploy Stage):

enter image description here

Then the 3 tasks's properties:

enter image description here enter image description here enter image description here

And here is the error I'm getting, it is with regard to the artefact publish directory:

enter image description here

1

1 Answers

2
votes

You should use dotnet publish to create your binaries. The step will also create a zip file. Then to publish the artefacts, use the PublishBuildArtifacts@1 Task. These steps should all be done within a build, not a release.

Here an example:

steps:
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'

- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    publishWebProjects: false
    projects: '**/*.csproj'
    arguments: '-o /app'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '/app'
    ArtifactName: 'drop'
    publishLocation: 'Container'

Within the release, you don't need the Publish and Download Build Artefact step since the artefacts are already there (_ISOF). After you run the first Build, you can just select the zip file in the "Package or folder" dropdown.