.net - GitLab - 找不到“单声道”主机
问题描述
嗨,我正在尝试在 GITLAB 中使用 CI/CD,我对此很陌生。
我能够创建以下 yml 文件
# Default image is docker:stable
image: docker:stable
# Define deployment stages
stages:
- build
# We use docker-in-docker (dind) for building docker images (build stage)
services:
- docker:dind
# Build unit test on dotnet core sdk image
build:
stage: build
image: mcr.microsoft.com/dotnet/sdk:5.0
script:
- cd TestRegressionNebra/
- dotnet restore "TestRegressionNebra.csproj"
- dotnet build "TestRegressionNebra.csproj"
- 'dotnet test "TestRegressionNebra.csproj" --test-adapter-path:. --logger:"junit;LogFilePath={assembly}-test-result.xml;MethodFormat=Class;FailureBodyFormat=Verbose"'
artifacts:
when: always
paths:
- ./**/*test-result.xml
reports:
junit:
- ./**/*test-result.xml
tags:
- nebra
但是当我运行它时,它给了我这个错误:
测试运行 /builds/fm/ecommerce/qa/testregression/TestRegressionNebra/bin/Debug/net461/TestRegressionNebra.dll (.NETFramework,Version=v4.6.1) Microsoft (R) Test Execution Command Line Tool Version 16.11.0 开始测试执行,请稍候... 共有 1 个测试文件符合指定模式。System.IO.FileNotFoundException:找不到“单”主机。确保机器上安装了“mono”并且在 PATH 环境变量中可用。在 Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.DotnetHostHelper.GetMonoPath()
当我在我的个人电脑上运行相同的命令时,没有发现任何问题。
编辑:附上我的 *.csproj 文件
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JunitXml.TestLogger" Version="3.0.98" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Selenium.Support" Version="3.141.0" />
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="94.0.4606.6100" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Configuration.Install" />
</ItemGroup>
解决方案
根据错误消息(和一些评论),您似乎使用了错误类型的跑步者。
GitLab CI/CD 在 GitLab Runner 上运行。如果你想运行任何依赖于 Windows 或 Windows 包的东西,那么你需要在 Windows 上安装 GitLab Runner,或者如果你正在使用 GitLab.com,则使用 Windows 共享运行器。
您在 CI yaml 中指定的映像image: mcr.microsoft.com/dotnet/sdk:5.0
还需要安装所有依赖项,或者安装必要的依赖项作为该部分的script
一部分。
我还建议查看dotnet CI 示例和dotnet-core CI 示例。有关更多信息,请参阅CI/CD 示例文档页面。
推荐阅读
- flutter - 在 null 上调用了 getter 'dateOfBirth'。接收者:null 尝试调用:dateOfBirth
- java - 字符串不包含另一个字符串,而是具有相同长度的字符串
- java - 如何使用 RecyclerView 创建可选标签?
- multisite - ATG 404 not found error time 未设置多站点 ID 和站点类型
- javascript - Axios POST错误的时区VueJs 3
- javascript - 如何在javascript中的嵌套树数组中过滤和排序?
- sql - 从 VBScript 中的 SQL SP 获取结果
- mysql - 包含 presto Athena 中的字符串函数
- excel - 基于日期与当前日期比较的总和值
- php - 如何使用 Exchange 服务器使用 smtp 服务器配置在 php 中发送邮件