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)测试执行命令行工具版本16.11.0开始测试执行,请等待…总共有1个测试文件与指定的模式匹配。System.IO.FileNotFoundException:无法找到"mono"主机。确保机器上安装了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="..CommonCommon.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 Examples文档页面。

在跨平台项目中,如果Linux上使用。NET 6.0和。NET Framework 4.72,那么如果需要在。NET Framework 4.72上进行测试,则必须安装mono。如果只在Linux上使用。NET 6.0,则忽略该警告。

最新更新