1

使用 GitHub Actions 构建我的 Azure 静态 Web 应用程序时,会产生以下 oryx 错误

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.6 at [/tmp/oryx/platforms/dotnet/5.0.203/shared/Microsoft.NETCore.App] 
You can resolve the problem by installing the specified framework and/or SDK. 
The specified framework can be found at: 
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=debian.9-x64 
Metadata generation failed. 

Oryx 错误似乎表明 .NET Core 3.1.0 不可用,在构建脚本中尝试了以下操作,

  • dotnet-version: '3.1.x'找不到框架“Microsoft.NETCore.App”,版本“3.1.0”
  • dotnet-version: '3.1.0'找不到版本 = 3.1.0 的 .NET Core SDK

这可能是.NET 5 的副本 - The framework 'Microsoft.NETCore.App', version '3.1.0' was not found,但未能成功添加缺少的 SDK。Oryx 团队最近合并更改以添加 .NET Core 3.1 SDK https://github.com/microsoft/Oryx/issues/1032

点网核心 Csproj

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
    <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.3.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.0.3" OutputItemType="Analyzer" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="4.0.4" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

构建脚本

name: Azure Static Web Apps CI/CD

on:
  push:
    branches:
      - master
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - master

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - uses: actions/setup-dotnet@v1
        with:
          dotnet-version: '3.1.x'
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets}}
          repo_token: ${{ secrets}}
          action: "upload"
          app_location: "Client"
          api_location: "Api"
          output_location: "wwwroot"

  close_pull_request_job:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close Pull Request Job
    steps:
      - name: Close Pull Request
        id: closepullrequest
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets}}
          action: "close"

Oryx 构建日志

Oryx Version: 0.2.20210410.1, Commit: e73613ae1fd73c809c00f357f8df91eb984e1158, ReleaseTagName: 20210410.1

Build Operation ID: |CKsa7CC9RZs=.1df8a945_
Repository Commit : 95e1079c5ea6bee2df8c47e2dd98d10d18313ca2

Detecting platforms...
Detected following platforms:
  dotnet: 5.0.6


Source directory     : /github/workspace/Api
Destination directory: /bin/staticsites/ss-oryx/api


Using .NET Core SDK Version: 5.0.203
  Determining projects to restore...
  Restored /github/workspace/Api/Api.csproj (in 7.54 sec).
  1 of 2 projects are up-to-date for restore.

Publishing to directory /bin/staticsites/ss-oryx/api...

Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  Data -> /github/workspace/Data/bin/Release/netstandard2.1/Data.dll
  Api -> /github/workspace/Api/bin/Release/net5.0/Api.dll
  Determining projects to restore...
  Restored /tmp/txcrqp1l.xyi/WorkerExtensions.csproj (in 3.18 sec).
  WorkerExtensions -> /tmp/txcrqp1l.xyi/buildout/Microsoft.Azure.Functions.Worker.Extensions.dll
/var/nuget/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 [/tmp/txcrqp1l.xyi/WorkerExtensions.csproj]
/var/nuget/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : The framework 'Microsoft.NETCore.App', version '3.1.0' was not found. [/tmp/txcrqp1l.xyi/WorkerExtensions.csproj]
/var/nuget/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :   - The following frameworks were found: [/tmp/txcrqp1l.xyi/WorkerExtensions.csproj]
/var/nuget/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :       5.0.6 at [/tmp/oryx/platforms/dotnet/5.0.203/shared/Microsoft.NETCore.App] [/tmp/txcrqp1l.xyi/WorkerExtensions.csproj]
/var/nuget/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :  [/tmp/txcrqp1l.xyi/WorkerExtensions.csproj]
/var/nuget/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : You can resolve the problem by installing the specified framework and/or SDK. [/tmp/txcrqp1l.xyi/WorkerExtensions.csproj]
/var/nuget/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :  [/tmp/txcrqp1l.xyi/WorkerExtensions.csproj]
/var/nuget/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : The specified framework can be found at: [/tmp/txcrqp1l.xyi/WorkerExtensions.csproj]
/var/nuget/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :   - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=debian.9-x64 [/tmp/txcrqp1l.xyi/WorkerExtensions.csproj]
/var/nuget/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :  [/tmp/txcrqp1l.xyi/WorkerExtensions.csproj]
/var/nuget/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : Metadata generation failed. [/tmp/txcrqp1l.xyi/WorkerExtensions.csproj]
4

0 回答 0