Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the C# version of my Azure build agent

I can build my code locally but the code will not build in my Azure pipeline. The build error message suggests my Azure build agent is using a different version of C#. How do I check to see what version it's using?

like image 917
NJS Avatar asked Sep 01 '25 22:09

NJS


2 Answers

In the log of visual studio build task, you can search csc.exe, then you could find the path of csc.exe. Then you could check language version by calling csc.exe -langversion:?

VS2019 : C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn

Regarding specify the hosted agent dynamic, you could use parameters in YAML pipeline, then you could choose the image in Run pipeline form:

For example:

parameters:
- name: image
  displayName: Pool Image
  type: string
  default: windows-latest
  values:
  - windows-latest
  - vs2017-win2016
  - ubuntu-latest
  - ubuntu-16.04
  - macOS-latest
  - macOS-10.14

trigger:
- none


jobs:
- job: myjob
  pool: 
    vmImage: ${{ parameters.image }}
  steps:
    - task: CmdLine@2
      inputs:
        script: '.\csc.exe -langversion:?'
        workingDirectory: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn'
like image 167
starian chen-MSFT Avatar answered Sep 03 '25 13:09

starian chen-MSFT


To check installed software on your build agent from azure devops go to:

Settings > Agent pools > buid-agents > build-agent-0-1

and go to Capabilities tab

like image 32
Much to learn Avatar answered Sep 03 '25 15:09

Much to learn