Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

443
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda