首页 > 解决方案 > 如何在 Azure DevOps 上构建 .NET 5 Azure Function?

问题描述

我正在尝试使用 yml 编辑器为 .NET 5 隔离进程 Azure 函数创建构建管道。我的步骤如下:

steps:
  - task: NugetToolInstaller@1
    displayName: 'NuGet Installer'
    inputs:
      versionSpec: $(NuGetVersion)

  - task: UseDotNet@2
    displayName: 'Using .NET $(NetVersion)'
    inputs:
      packageType: 'sdk'
      version: $(NetVersion)

  - task: DotNetCoreCLI@2
    displayName: 'Building Solution'
    inputs:
      command: 'build'
      arguments: '--configuration $(BuildConfiguration)'
      projects: '$(Solution)'

  - task: DotNetCoreCLI@2
    displayName: 'Publish Function'
    inputs:
      command: 'publish'
      publishWebProjects: true
      arguments: '--output $(Build.ArtifactStagingDirectory) -c $(BuildConfiguration)'
      modifyOutputPath: false

当我进入构建解决方案步骤时,它失败了,原因如下:

C:\SomeDirectory\.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.10 at [C:\somedirectory\]. 
    You can resolve the problem by installing the specified framework and/or SDK.

然后它继续链接 .NET Core 3.1 运行时。我不确定为什么会这样。.csproj 指定了 .NET 5 以及 .sln 文件。我尝试使用 .sln 文件和 .csproj 文件进行构建。我没有在任何地方指定 .NET Core 3.1,相关的 NuGet 包都是最新的。

是否有我必须使用的某个步骤或我必须指定一些变量才能使其工作?

标签: c#azure-devopsazure-functionsazure-pipelines

解决方案


推荐阅读