1
votes

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?

1
Can you show how you compile your solution on pipeline?Krzysztof Madej
Hi Did you get a chance to give below suggestions a try. How did it go?Levi Lu-MSFT
In the end I just changed the target to a lower version of .net core and it worked. - However I will revist this in the coming days becuase there are some features in the more recent version of .net core I need. I will mark this as the answer when I try it out later this week. Thanks for your helpAyo Adesina

1 Answers

2
votes

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'