ArchiveFiles@2 and the root folder

Viewed 3569

I have the following code in my yaml pipeline which builds on an on-premises self hosted agent. This self hosted agent does not have winzip / 7zip installed

buildlabel: 11.0.46999
mycomponentInstallerRootDir: $(Build.SourcesDirectory)\myproduct\installer\mycomponent\$(buildlabel)
mycomponent: 'test'

- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: $(mycomponentInstallerRootDir)
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(mycomponent)/$(buildlabel).zip'
    includeRootFolder: false
  enabled: true

- publish: $(Build.ArtifactStagingDirectory)
  artifact: buildartifacts_installer
  enabled: true

My requirement is to achieve the following:

  • test/11.0.46999.zip must be generated as a build artifact
  • 11.0.46999.zip must have only the files and folders under $(Build.SourcesDirectory)\myproduct\installer\mycomponent\11.0.46999

But what I am observing is that test/11.0.46999.zip has an intermediate folder 11.0.46999 which contains the files and folders under $(Build.SourcesDirectory)\myproduct\installer\mycomponent\11.0.46999

I have tried with includeRootFolder: false as per the MSDN documentation, but still am unable to get rid of this intermediate folder in the generated zip file

the generated zip file

What am I missing here in my approach?

Thanks

Edit 1: // Some more details in response to the note by @KrzysztofMadej

enter image description here

Edit 2: I can add one more bit of information:

The build log shows the following command being executed as part of the Archive task

C:\AzAgent\_work\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\2.161.0\7zip\7z.exe a -tzip -mx=5 <mycomponentInstallerRootDir>\11.0.46999.zip @C:\AzAgent\_work\_temp\r5rzi127rs15lwec2nyk9ms4i
0 Answers
Related