Currently started using global templates in the majority of my pipelines and there is an issue occurring where an empty artifact is getting published in addition to the original artifact.
This is causing minor issues with some of my deployment groups (workaround is to just ignore it when downloading). While it is not causing major issues, I'm just curious about why the extra file is being published as well as preventing it.
EDIT:
Included my yaml template being used as:
parameters:
ArtifactPath: ''
ArtifactName: ''
ArtifactPublish: false
Artifacts: []
Solution: '**/*.sln'
jobs:
- job: Build
displayName: 'Build, Pack, and Publish'
pool:
vmImage: 'windows-latest'
variables:
solution: ${{ parameters.Solution }}
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
prereleaseVersion: '$(majorVersion).$(minorVersion).$(Build.BuildNumber)-$(Build.SourceBranchName)'
releaseVersion: '$(majorVersion).$(minorVersion).$(Build.BuildNumber)'
steps:
- task: NuGetToolInstaller@1
displayName: "Install Nuget Tool"
- task: NuGetCommand@2
displayName: 'Restore Nuget Packages'
inputs:
command: 'restore'
restoreSolution: '$(solution)'
feedsToUse: 'select'
vstsFeed: 'FEED'
- task: VSBuild@1
displayName: 'Build Solution'
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(Build.ArtifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
displayName: 'Run Unit Tests'
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: NuGetCommand@2
displayName: 'Pack Prerelease Nuget Packages'
condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master'), ne(variables['Build.SourceBranch'], 'refs/heads/release'))
inputs:
command: 'pack'
configuration: '$(buildConfiguration)'
packagesToPack: '**/nuspec/*.nuspec'
versioningScheme: 'byEnvVar'
versionEnvVar: prereleaseVersion
verbosityPack: 'detailed'
- task: NuGetCommand@2
displayName: 'Push Prerelease Nuget Packages'
condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master'), ne(variables['Build.SourceBranch'], 'refs/heads/release'))
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'FEED'
verbosityPush: 'normal'
- task: NuGetCommand@2
displayName: 'Pack Release Nuget Packages'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/release'))
inputs:
command: 'pack'
configuration: '$(buildConfiguration)'
packagesToPack: '**/nuspec/*.nuspec'
versioningScheme: 'byEnvVar'
versionEnvVar: releaseVersion
verbosityPack: 'detailed'
- task: NuGetCommand@2
displayName: 'Push Release Nuget Packages'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/release'))
continueOnError: true
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'FEED'
verbosityPush: 'detailed'
- task: PublishSymbols@2
displayName: 'Publish Symbols to Symbol Server'
inputs:
SearchPattern: '**/bin/**/*.pdb'
SymbolServerType: 'TeamServices'
- ${{ if eq(parameters.ArtifactPublish, true) }}:
- ${{ each artifact in parameters.Artifacts }}:
- task: CopyFiles@2
displayName: 'Copy .artifactignore: ${{ artifact.ArtifactPath }}'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '.artifactignore'
TargetFolder: '$(Build.SourcesDirectory)/${{ artifact.ArtifactPath }}'
- ${{ each artifact in parameters.Artifacts }}:
- task: PublishPipelineArtifact@1
displayName: 'Publish Artifact: ${{ artifact.ArtifactName }}'
inputs:
targetPath: '$(Build.SourcesDirectory)/${{ artifact.ArtifactPath }}'
artifactName: '${{ artifact.ArtifactName }}'
Yaml file that consumes it:
trigger:
- release
- development
- master
- feature/*
- task/*
resources:
repositories:
- repository: templates
name: Project/Repo-Name
type: git
ref: refs/heads/release
variables:
# This is the version displayed in package manager (Major.Minor.BuildNumber)
majorVersion: 1
minorVersion: 1
jobs:
- template: Templates/build.yml@templates
parameters:
Solution: 'SolutionName'
ArtifactPublish: true
Artifacts:
- ArtifactPath: 'bin/directory/$(buildConfiguration)'
ArtifactName: 'ArtifactName'
You have one Publish Symbols task in your template, this task will publish symbols to the symbol server in Azure Artifacts with a random name. That's why we can see the extra artifact in Published
tab, it's expected behavior when using PublishSymbols@2
task.
I'm just curious about why the extra file is being published as well as preventing it.
It's not recommended to disable or remove the Publish Symbols
step though it helps to remove the artifact. This task is quite important for some scenarios where you want to have the ability to debug the published nuget packages, check my another similar issue. So my suggestion is just ignoring it~