Linux上Dotnet Core的GitHub BuildPipeline失败,自上次运行以来未进行任何更改;请求安装或更新.NET

mwg9r5ms  于 2022-11-26  发布在  .NET
关注(0)|答案(2)|浏览(185)

我试图在我的代码中添加更改,Linux的构建管道停止了工作。Windows和Mac的构建管道成功了。
我恢复了所有更改,因此自上次成功的PullRequest以来,没有更改,只有注解。
现在,它将失败,并显示以下消息:(缩写:“* 您必须安装或更新.NET才能运行此应用程序。*”)

Build started 11/20/2022 12:32:08.
     1>Project "/home/runner/work/isoxml-dotnet/isoxml-dotnet/isoxml_dotnet.sln" on node 1 (VSTest target(s)).
     1>ValidateSolutionConfiguration:
         Building solution configuration "Debug|Any CPU".
Test run for /home/runner/work/isoxml-dotnet/isoxml-dotnet/{package}/bin/Debug/netcoreapp3.1/{package}.dll (.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 17.3.1 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Testhost process for source(s) '/home/runner/work/isoxml-dotnet/isoxml-dotnet/{package}.Test/bin/Debug/netcoreapp3.1/{package}.Test.dll' exited with error: You must install or update .NET to run this application.
App: /home/runner/.nuget/packages/microsoft.testplatform.testhost/16.9.4/lib/netcoreapp2.1/testhost.dll
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '3.1.0' (x64)
.NET location: /usr/share/dotnet/
The following frameworks were found:
  6.0.10 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=ubuntu.22.04-x64
. Please check the diagnostic logs for more information.

Test Run Aborted.
     1>Done Building Project "/home/runner/work/isoxml-dotnet/isoxml-dotnet/isoxml_dotnet.sln" (VSTest target(s)) -- FAILED.

Build FAILED.
    0 Warning(s)
    0 Error(s)

我的构建管道如下所示:

name: .NET

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  buildLinux:

    runs-on: ubuntu-latest
    strategy:
      matrix:
        dotnet-version: ['3.0', '3.1.x', '5.0.x','6.0.x' ]

    steps:
    - uses: actions/checkout@v3
    - name: Setup .NET
      uses: actions/setup-dotnet@v2
    - name: Restore dependencies
      run: dotnet restore
    - name: Build Linux
      run: dotnet build --no-restore
    - name: Test
      run: dotnet test --no-build --verbosity normal
  buildWindows:

    runs-on: windows-latest
    strategy:
      matrix:
        dotnet-version: ['3.0', '3.1.x', '5.0.x','6.0.x' ]

    steps:
    - uses: actions/checkout@v3
    - name: Setup .NET
      uses: actions/setup-dotnet@v2
    - name: Restore dependencies
      run: dotnet restore
    - name: Build Windows
      run: dotnet build --no-restore
    - name: Test
      run: dotnet test --no-build --verbosity normal
  buildMac:

    runs-on: macos-latest
    strategy:
      matrix:
        dotnet-version: ['3.0', '3.1.x', '5.0.x','6.0.x' ]

    steps:
    - uses: actions/checkout@v3
    - name: Setup .NET
      uses: actions/setup-dotnet@v2
    - name: Restore dependencies
      run: dotnet restore
    - name: Build Mac
      run: dotnet build --no-restore
    - name: Test
      run: dotnet test --no-build --verbosity normal

请注意,dotnet.yml中没有任何更改。
到目前为止,我尝试了:

  • 还原所有更改;剩下的都是评论
  • 将操作/setup-dotnet的版本更改为v3、v3.0.2、v2.0.1
    编辑备注:我删除了带有{package}的PackageName,因为它与解决方案无关。希望没有问题;)
ny6fqffe

ny6fqffe1#

你的Azure管道YAML调用setup-dotnet操作,但实际上不会将版本传递给它。这将仅选择OS映像上的默认版本。
确保传递矩阵变量:

- uses: actions/setup-dotnet@v3
  with:
    dotnet-version:  ${{ matrix.dotnet-version }}

我的猜测是,既然dotnet 7已经发布,他们就从映像中剥离了一些不再支持的dotnetSDK。

mbyulnm0

mbyulnm02#

GitHub将在2022年10月3日至12月1日期间以ubuntu-latest的形式推出Ubuntu 22.04,这并不奇怪。
https://github.com/actions/runner-images/issues/6399
您的工作流程似乎已注册。
如果您查看一下Ubuntu 22.04映像的内容,您会发现. NETCore3.1运行时并不存在,
https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
.NET Core 3.1将在几天内到期,因此请至少将您的项目升级到.NET 6。以旧的运行时为目标毫无意义。
如果确实要设置可能使用的旧运行时,

- name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: |
          3.1.x
          5.0.x
          6.0.x

https://github.com/lextudio/sharpsnmplib/blob/12.5.1/.github/workflows/dotnetcore.yml#L28

相关问题