-2

.Net Core - Publish Artifact Task

The code below is generating Published Artifacts in a drop folder but as a zip file. And this task works on only .Net core projects.

- task: DotNetCoreCLI@2
  displayName: 'dotnet publish'
  inputs:
    command: 'publish'
    publishWebProjects: false
    projects: 'src/myproj/*.csproj'
    arguments: -o $(build.artifactStagingDirectory)

If we add zipAfterPublish: false property to inputs, we can avoid zipping artifacts as described here


Asp.Net - Publish Artifact Task

The code below is the Asp.Net version of the above

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
    ArtifactName: '$(Parameters.ArtifactName)'
  condition: succeededOrFailed()

While we can avoid zipping artifacts in .Net Core, there isn't any property to add for this in Asp.Net version.

So, how can i avoid zipping artifacts in Asp.Net version of Publish Artifact task?

mevsim
  • 35
  • 2
  • 8

1 Answers1

0

If you check the YAML Snippet of PublishBuildArtifacts task form this Microsoft document then, you will find that it don't have any input property like zipAfterPublish of DotNetCoreCLI task to avoid the zip file while publishing artifact.

So, it's not possible to do it directly what you want to achieve. But there is a workaround which we can apply to achieve your desired result. That is by using the ExtractFile task.

Here I'm providing the detailed approach that you should use to get your desired result.

- task: PublishBuildArtifacts@1
  displayName: 'PublishArtifact'
  inputs:
    pathToPublish: '$(Build.ArtifactStagingDirectory)'
    artifactName: '$(Parameters.ArtifactName)'   
    
# archive the build artifact for later processing
- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.ArtifactStagingDirectory)'
    includeRootFolder: false  

# Extract files
# just extract it as an extra step as I mentioned above
- task: ExtractFiles@1
  inputs:
    archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$***.zip' 
    destinationFolder: '$(Build.ArtifactStagingDirectory)/***'
    cleanDestinationFolder: false

# and lastly deploy it.

For more information check this Extract Files task documentation from Microsoft.

SauravDas-MT
  • 1,224
  • 1
  • 4
  • 10