Reputation: 2395
I have got a Visual Studio 2019 Solution with a .NET Framework Application, with a Azure Pipeline that builds and deploys a web app.
I recently added an Azure Functions Project to my solution. (.net core) The two projects in the solution do not refrence each other.
On my Local Machine - The solution builds with no problems, and I can run both applications.
However when the Azure Pipeline process tries to build the solution fails with the following error:
Error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 3.1.
I actually want this Azure Pipeline to ignore the new .net core project, and contiune to build then deploy my web application.
How can I get Azure to build my project in the same way as my local machine?
Upvotes: 4
Views: 3640
Reputation: 399
I had this problem, I had just updated a project from .NET Core 2.2 to .NET Core 3.1 and it stopped building in Azure Devops giving me the error The current .NET SDK does not support targeting .NET Core 3.1
during the Nuget Restore task.
The pipeline was using the Nuget Tool Installer task before the Nuget Restore. The installer was using a version of Nuget that didn't support .NET Core 3.1.
I updated the Nuget Tool Installer to use a newer version and my build ran correctly.
Upvotes: 0
Reputation: 30313
It looks like that the pipeline is trying to use the wrong .NET Core SDK to compile your projects which are targeting .NET Core 3.1.
You can try adding task Use .NET Core before restore and build task to make sure the .NET Core 3.1 version is used in your pipeline. See below:
- task: UseDotNet@2
inputs:
version: 3.1.302
- task: DotNetCoreCLI@2
inputs:
command: restore
projects: '**/*.csproj'
- task: DotNetCoreCLI@2
inputs:
command: build
projects: '**/*.csproj'
If you used Visual Studio Build task to build your projects, you need to run your pipeline on agent windows-latest
which has visual studio 2019 installed. Or you might still encounter this error "The current .NET SDK does not support targeting .NET Core 3.1"
If you want to ignore the new .net core project. You can set the projects attribute of the build task to build a specific project. See below:
- task: DotNetCoreCLI@2
inputs:
command: restore
projects: '**/oldProject.csproj'
- task: DotNetCoreCLI@2
inputs:
command: build
projects: '**/oldProject.csproj'
Visual Studio Build task to build a single project
- task: VSBuild@1
condition: always()
inputs:
solution: '**/oldProject.csproj'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArgs: '/t:build'
Upvotes: 4