Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
414 views
in Technique[技术] by (71.8m points)

azure devops - Create xml with artifact files

I have a hard time getting any information on how to do this.

I want to include a task in my build pipeline that creates an XML file that lists each file of the resulting artifact along with some metadata like checksum, size, etc.

Something like this:

<files>
  <file>
    <name>file1.dll</name>
    <path></path>
    <size></size>
    <checksum></checksum>
  </file>
  <file>
    <name>file2.dll</name>
    <path></path>
    <size></size>
    <checksum></checksum>
  </file>
</files>

I'm thinking I probably need to use a powershell script but how would I go about getting the list of files? I would have to iterate through the list and populate the xml file with that list.

Or is there some task I use to achieve this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Place the resulting artifact files into a specific directory on the agent, such as $(Build.ArtifactStagingDirectory).

In this directory, you can try the steps below:

  1. List all files in the directory and subdirectories using the PowerShell command Get-ChildItem.

    Get-ChildItem -Attributes !Directory -Path path/to/dir -Recurse -Name
    
  2. In a loop, do the following operations for each files:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...