Reputation: 2516
I am trying to create an Azure pipeline for a .NET Framework project. The build appears to complete with no errors but there is no artifact generated:
The YAML definition is below, can anyone see what I'm doing wrong here?
name: 'App-Api-Dev'
trigger:
batch: true
branches:
include: [ development ]
paths:
include:
- src/App.Api/*
pool:
name: 'Default'
variables:
solution: '**/*.sln'
project: '**/Api.csproj'
buildPlatform: 'x86'
buildConfiguration: 'Release'
stages:
- stage: Build
jobs:
- job: Build
pool:
name: Default
steps:
- task: NuGetToolInstaller@1
displayName: 'Install Nuget'
- task: NuGetCommand@2
displayName: 'Nuget Restore'
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
displayName: 'Build'
inputs:
solution: '$(project)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishSymbols@2
inputs:
SearchPattern: '**/bin/**/*.pdb'
PublishSymbols: false
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifacts'
inputs:
PathtoPublish: $(build.artifactStagingDirectory)
ArtifactName: 'PublishBuildArtifact'
Upvotes: 1
Views: 2104
Reputation: 3058
According to the configuration of your publish build artifact task, you are publishing artifacts from $(build.artifactStagingDirectory). However, this directory is purged before each new build and it is empty.
A typical way to use this folder is to publish your build artifacts with the Copy files and Publish build artifacts tasks. You can copy the artifacts you want to publish to this directory before publishing. For example:
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '**'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
If the artifacts you want to publish are ready in some directories, you can also directly use publish build artifact task. For example:
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.SourcesDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
In addition, I suggest you understand the local path and role of each variable.
Build.ArtifactStagingDirectory: The local path on the agent where any artifacts are copied to before being pushed to their destination. For example: c:\agent_work\1\a
Please find more detailed information in this document.
Upvotes: 3
Reputation: 2978
Nothing was copied to the build.artifactstagingdirectory. Try using the newer Publish Pipeline Artifact task. If I have heard correctly this is the right task to use when using Azure DevOps Pipelines for publishing.
- task: PublishPipelineArtifact@1
inputs:
#targetPath: '$(Pipeline.Workspace)'
#artifactName: 'PublishBuildArtifact'
Upvotes: 2