Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

azure functions - .NET 5 - The framework 'Microsoft.NETCore.App', version '3.1.0' was not found

When using azure pipelines to build my .NET 5 function I am getting the following error

##[error]/home/vsts/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): Error : It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.
  - The following frameworks were found:
      5.0.4 at [/opt/hostedtoolcache/dotnet/shared/Microsoft.NETCore.App]

This also displays a Error : Metadata generation failed error further down the build script

##[error]/home/vsts/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): Error : Metadata generation failed.

My build script is

trigger:
- master

stages:

- stage: 'Build'
  jobs:
  - job:
    pool:
      vmImage: 'ubuntu-latest'
    workspace:
      clean: all
    steps:
    - task: UseDotNet@2
      displayName: Use Dot Net Core 5.0.x
      inputs:
        packageType: 'sdk'
        version: '5.0.x'
    - task: DotNetCoreCLI@2
      displayName: Build
      inputs:
        arguments: '--configuration Release'
        command: 'build'
        projects: '**/*.csproj'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To build .NET 5 functions, the .NET Core 3 SDK is required. So this must be installed alongside the 5.0.x sdk.

In my case it meant that the script needed to be updated to

trigger:
- master

stages:

- stage: 'Build'
  jobs:
  - job:
    pool:
      vmImage: 'ubuntu-latest'
    workspace:
      clean: all
    steps:
    - task: UseDotNet@2
      displayName: Use Dot Net Core 3.1.x
      inputs:
        packageType: 'sdk'
        version: '3.1.x'
    - task: UseDotNet@2
      displayName: Use Dot Net Core 5.0.x
      inputs:
        packageType: 'sdk'
        version: '5.0.x'
    - task: DotNetCoreCLI@2
      displayName: Build
      inputs:
        arguments: '--configuration Release'
        command: 'build'
        projects: '**/*.csproj'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...