5

I have updated my website to .net 6. It also works locally. However, my yaml pipeline in Azure DevOps is no longer running. There is an error in the publishing step for all .csproj files in solution like this. I don't know, how I can configure that it should use .net 6.

C:\Program Files\dotnet\sdk\5.0.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(141,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 6.0.  Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 6.0. [D:\a\1\s\04_Contracts\Contracts\Contracts.csproj]
##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1

Here is the Pipeline step for publishing.

- task: DotNetCoreCLI@2
  displayName: 'dotnet publish'
  inputs:
    command: publish
    publishWebProjects: false
    projects: '**/*.csproj'
    arguments: '-r linux-x64 --output $(build.artifactstagingdirectory)'
Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
Taladan
  • 429
  • 1
  • 8
  • 20

3 Answers3

9

You need first to install .NET 6 SDK in the agent, add it before the DotNetCoreCLI:

- task: UseDotNet@2
  displayName: 'Install .NET Core sdk 6.x'
  inputs:
    version: 6.x
Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
1

If you created pipeline in Gui, you should remove the old pipeline and create a new one, it worked for me

Ali Besharati
  • 918
  • 12
  • 25
0

You also need to specify the app pool to use the .net 6.0 framework:

pool:
  vmImage: windows-2022

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk'
  inputs:
  packageType: 'sdk'
  version: '6.0.x'
  includePreviewVersions: true
jqIndy
  • 414
  • 5
  • 11