Forum

Error NETSDK1045: T...
 
Notifications
Clear all

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.

3 Posts
1 Users
0 Reactions
888 Views
Posts: 24
Admin Registered
Topic starter
(@rijwan-ansari)
Illustrious Member
Joined: 5 years ago

Azure DevOps, Build pipelines failed because of .NET 6. 

Exact Error:

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\ProjectName.csproj]

2 Replies
Posts: 24
Admin Registered
Topic starter
(@rijwan-ansari)
Illustrious Member
Joined: 5 years ago

The reason for this error is that .NET 6 project. Azure Pipelines uses .NET 5 as latest version in its hosted build agents. It means the host machine has .NET 5 version as latest and .NET 6 is missing. 

Since .NET 6 is not installed yet in Microsoft hosted build agents in Azure DevOps. i.e. .NET 6 is still not supported in Azure DevOps pipelines. 

Solution:

To resolve the above error or issues, we can add a task before build task. We need to specify the .NET core SDK version before build task as shown below:

- task: UseDotNet@2
  displayName: 'Use .NET Core 6 sdk'
  inputs:
    version: '6.0.x'
Reply
Posts: 24
Admin Registered
Topic starter
(@rijwan-ansari)
Illustrious Member
Joined: 5 years ago

Complete azure-pipelines.yml file

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
#  https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core 

trigger:
- master

pool:
  vmImage: windows-latest

variables:
  buildConfiguration: 'Release'

steps:
- task: UseDotNet@2
  displayName: 'Use .NET Core 6 sdk'
  inputs:
    version: '6.0.x'

- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'
Reply
Share: