Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 708
Chris Evans Avatar asked Nov 06 '19 13:11

Chris Evans


People also ask

Is Azure DevOps CI CD?

Azure DevOps Starter creates a CI/CD pipeline in Azure Pipelines. You can create a new Azure DevOps organization or use an existing organization. Azure DevOps Starter also creates Azure resources in the Azure subscription of your choice. Sign in to the Azure portal.

How do I update Azure DevOps?

You have 2 options. Download the tasks from an existing Azure DevOps organization (cloud version). Then use tfx or PowerShell to upload the upgraded tasks to your Azure DevOps server. Build the tasks from source and publish them to your Azure DevOps server.


1 Answers

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.

like image 133
Chris Evans Avatar answered Nov 03 '22 22:11

Chris Evans