使用 netcoreapp3.1 构建库会在尝试在多个框架上运行测试的 GitHub 操作上引发错误
我正在努力为一个伟大的项目做出贡献(https://github.com/billbogaiv/hybrid -model-binding) - 我想更新目标框架并设置测试。
我的分叉: https://github.com/Misiu/hybrid-model-binding /树/测试
我已将项目从 netstandard2.1
更新到 netcoreapp3.1
,一切正常。
所以现在我的解决方案中有 3 个项目:
- HybridModelBinding - 主库项目
- AspNetCoreWebApplication - 包含示例的项目
- HybridModelBinding.UnitTests - 将包含单元测试的项目
我希望我的测试在多个 dotnet 版本上运行,因此我添加了此工作流程:
name: .NET Core
# Trigger event on a push or pull request
on: [push, pull_request]
# Jobs that run in parallel
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [ '3.1.x','5.0.x', '6.0.x' ]
# Steps that run sequentially
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/[email protected]
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
所以理论上一切都应该在 3 个运行时上构建和运行。 第一个构建工作正常(在 3.1.x 上),但第二个和第三个抛出错误:
测试运行 /home/runner/work/混合模型绑定/混合模型绑定/测试/HybridModelBinding.UnitTests/bin/Debug/netcoreapp3.1/HybridModelBinding.UnitTests.dll (.NETCoreApp,版本=v3.1) Microsoft (R) 测试执行命令行 工具版本 16.11.0 版权所有 (c) Microsoft Corporation。版权所有 保留。
开始执行测试,请稍候...共1个测试文件 与指定的模式匹配。 Testhost 进程退出并出现错误:It 无法找到任何兼容的框架版本 找不到框架“Microsoft.AspNetCore.App”,版本“3.1.0”。
- 发现了以下框架: 5.0.14 at [/home/runner/.dotnet/shared/Microsoft.AspNetCore.App] 可以通过安装指定框架来解决问题 和/或 SDK。指定的框架可以在:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=3.1.0&arch=x64&rid=ubuntu.20.04-x64 。请检查诊断日志以获取更多信息。
测试运行已中止。 3>完成构建项目“/home/runner/work/hybrid-model-binding/hybrid-model-binding/tests/HybridModelBinding.UnitTests/HybridModelBinding.UnitTests.csproj” (VSTest 目标)——失败。 1>完成构建项目“/home/runner/work/hybrid-model-binding/hybrid-model-binding/HybridModelBinding.sln” (VSTest 目标)——失败。
构建失败。
构建摘要: https://github.com/Misiu/hybrid -model-binding/runs/5392702331?check_suite_focus=true
我可以在本地编译项目并运行测试,但我想在 GitHub 上运行它们,因此将来我们可以添加更多测试并更轻松地开发库。
I'm trying to contribute to a great project (https://github.com/billbogaiv/hybrid-model-binding) - I want to update the target framework and set up tests.
My fork: https://github.com/Misiu/hybrid-model-binding/tree/tests
I've updated the project from netstandard2.1
to netcoreapp3.1
and everything works fine.
So now I have 3 projects in the solution:
- HybridModelBinding - main library project
- AspNetCoreWebApplication - project with samples
- HybridModelBinding.UnitTests - project that will contain unit tests
I'd like my tests to run on multiple dotnet versions, so I've added this workflow:
name: .NET Core
# Trigger event on a push or pull request
on: [push, pull_request]
# Jobs that run in parallel
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [ '3.1.x','5.0.x', '6.0.x' ]
# Steps that run sequentially
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/[email protected]
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
So in theory everything should be built and run on 3 runtimes.
The first build works fine (on 3.1.x), but the second and third throw errors:
Test run for
/home/runner/work/hybrid-model-binding/hybrid-model-binding/tests/HybridModelBinding.UnitTests/bin/Debug/netcoreapp3.1/HybridModelBinding.UnitTests.dll
(.NETCoreApp,Version=v3.1) Microsoft (R) Test Execution Command Line
Tool Version 16.11.0 Copyright (c) Microsoft Corporation. All rights
reserved.Starting test execution, please wait... A total of 1 test files
matched the specified pattern. Testhost process exited with error: It
was not possible to find any compatible framework version The
framework 'Microsoft.AspNetCore.App', version '3.1.0' was not found.
- The following frameworks were found:
5.0.14 at [/home/runner/.dotnet/shared/Microsoft.AspNetCore.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.AspNetCore.App&framework_version=3.1.0&arch=x64&rid=ubuntu.20.04-x64
. Please check the diagnostic logs for more information.Test Run Aborted.
3>Done Building Project "/home/runner/work/hybrid-model-binding/hybrid-model-binding/tests/HybridModelBinding.UnitTests/HybridModelBinding.UnitTests.csproj"
(VSTest target(s)) -- FAILED.
1>Done Building Project "/home/runner/work/hybrid-model-binding/hybrid-model-binding/HybridModelBinding.sln"
(VSTest target(s)) -- FAILED.Build FAILED.
Build summary: https://github.com/Misiu/hybrid-model-binding/runs/5392702331?check_suite_focus=true
I can compile projects locally and run the tests, but I'd like to run them on GitHub, so in the future, we can add more tests and develop the library easier.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过矩阵下的
include
指定目标框架名称 (TFM),并通过添加参数-f=${{ matrix.tfm 指定
。dotnet test
的框架}}来源
Specify the Target framework monikers (TFMs) via
include
under the matrix and specify the framework fordotnet test
by adding the argument-f=${{ matrix.tfm }}
.Sources