Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

434
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda