.NET 5 - 找不到框架“Microsoft.NETCore.App",版本“3.1.0" [英] .NET 5 - The framework 'Microsoft.NETCore.App', version '3.1.0' was not found

查看:111
本文介绍了.NET 5 - 找不到框架“Microsoft.NETCore.App",版本“3.1.0"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用 azure 管道构建我的 .NET 5 函数时,我收到以下错误

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]

这还会在构建脚本的进一步下方显示 Error : Metadata generation failed 错误

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.

我的构建脚本是

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'

推荐答案

要构建 .NET 5 函数,需要 .NET Core 3 SDK.所以这必须与 5.0.x sdk 一起安装.

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'

这篇关于.NET 5 - 找不到框架“Microsoft.NETCore.App",版本“3.1.0"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆