Autumn
Autumn

Reputation: 876

How to upgrade azure CI to use c# 8.0

I have an azure pipeline that builds my asp.net core 2.2 project. I upgraded the project use c# 8.0. However, my azure pipelines don't seem to support c# 8.0. How do I upgrade my azure pipeline to use c# 8.0?

I have looked through the options in the azure pipeline and have not found anything on upgrading to c# 8.0

Here is the generated YAML file

pool:
  name: Hosted VS2017
  demands:
  - msbuild
  - visualstudio

steps:
- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.4.1'
  inputs:
    versionSpec: 4.4.1

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Parameters.solution)'
    vstsFeed: '3e219c03-bc0d-4106-82be-9ff3b21190a5'

- task: VSBuild@1
  displayName: 'Build solution'
  inputs:
    solution: '$(Parameters.solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

- task: VSTest@2
  displayName: 'Test Assemblies'
  inputs:
    testAssemblyVer2: |
     **\$(BuildConfiguration)\*test*.dll
     !**\obj\**
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'
    diagnosticsEnabled: True
  enabled: false

- task: PublishSymbols@2
  displayName: 'Publish symbols path'
  inputs:
    SearchPattern: '**\bin\**\*.pdb'
    PublishSymbols: false
  continueOnError: true

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
    ArtifactName: '$(Parameters.ArtifactName)'
  condition: succeededOrFailed()

I expect the project to build, but it gives me this error: CSC : error CS1617: Invalid option '8.0' for /langversion. Use '/langversion:?' to list supported values.

Upvotes: 10

Views: 3675

Answers (1)

Autumn
Autumn

Reputation: 876

I figured out the issue. Based on the YAML file, I am using the "Hosted 2017" agent pool. After I changed this to "Azure Pipelines" with the "windows-2019" specification, it worked.

Upvotes: 13

Related Questions