Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

437
Views
How can I add to the extended properties collection of a build in Azure Devops pipelines

I am using the .NET client libraries for Azure DevOps to get information about my builds and display them on a website. I want to get the assembly version of my application that is being built to display on the web site.

I see here that there is a collection of arbitrary key-value pairs that I can get via the REST API (and also with the dotnet client library). But how do I set these properties during my build?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I want to get the assembly version of my application that is being built to display on the web site.

You can use Reflector, ILDASM, Jetbrains dotpeek or ILSpy to get the assembly version.

You usually can find ILDASM in C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\ildasm.exe (where v8.1A is the version of the Windows SDK installed).

ILDASM: Ildasmtooltoseeversion

enter image description here

enter image description here

how do I set these properties during my build? You need to set extended properties in the form of environment variables.

You can use variables with expressions to conditionally assign values and further customize pipelines.

over 4 years ago · Santiago Trujillo Report

0

Use this YAML task template called SetBuildProperties.yml to add build properties in a pipeline:

SetBuildProperties.yml:

# Sets custom build properties. Use this to transfer info between pipelines.
parameters:

- name: buildId
  type: string

steps:
  
- task: PowerShell@2
  displayName: 'Set build properties'
  name: 'SetBuildProperties'
  inputs:
    targetType: 'inline'
    script: |

        # prepare the auth token
        $authHeader = "Bearer $(System.AccessToken)"

        $requestHeader = @{
            "Authorization" = $authHeader
            "Accept" = "application/json"
        }

        # array of operations
        # @{} is a hashtable in PowerShell. 
        # @() is an array (list) in PowerShell.
        $paramsObject = 
        @(
            @{
                "op" = "add"
                "path" = "/myProperty"
                "value" = "myValue"
            }
        )

        $params = ConvertTo-Json -InputObject $paramsObject

        Write-Host "JSON: " $params

        $contentType = "application/json-patch+json;charset=utf-8"        


        $apiurl = "https://dev.azure.com/MyOrg/MyProject/_apis/build/builds/${{ parameters.buildId }}/properties?api-version=6.0"
        
        Write-Host "Invoking REST API url: " $apiurl

        try 
        {
            $properties = Invoke-RestMethod -Uri $apiurl -Method PATCH -Headers $requestHeader -Body $params -ContentType $contentType

        }
        catch
        {
            # Writes an error to build summary and to log in red text
            Write-Host "##vso[task.LogIssue type=error;]Error occurred: " $_

            exit 1
        }

If you need to read the properties in the same or a different pipeline you can use this template GetBuildProperties.yml:

# Gets custom build properties. Use this to transfer info between pipelines.
parameters:

- name: buildId
  type: string

steps:
  
- task: PowerShell@2
  displayName: 'Get build properties'
  name: 'GetBuildProperties'
  inputs:
    targetType: 'inline'
    script: |

        # prepare the auth token
        $authHeader = "Bearer $(System.AccessToken)"

        $requestHeader = @{
            "Authorization" = $authHeader
            "Accept" = "application/json"
        }

        $apiurl = "https://dev.azure.com/MyOrg/MyCompany/_apis/build/builds/${{ parameters.buildId }}/properties?api-version=6.0"
        
        Write-Host "Invoking REST API url: " $apiurl

        try 
        {
            $properties = Invoke-RestMethod -Uri $apiurl -Method Get -Headers $requestHeader

            $propertiesJSON = ConvertTo-Json -InputObject $properties
            Write-Host 'properties: ' $propertiesJSON
        }
        catch
        {
            # Writes an error to build summary and to log in red text
            Write-Host "##vso[task.LogIssue type=error;]Error occurred: " $_

            exit 1
        }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!