GitLab - Could not find 'mono' host

Viewed 500

Hi there i´m trying to use CI/CD in GITLAB and i´m prettey new to this.

I was able to create the following yml file

# 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

But when i run this it gives me this error :

Test run for /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 Starting test execution, please wait... A total of 1 test files matched the specified pattern. System.IO.FileNotFoundException: Could not find 'mono' host. Make sure that 'mono' is installed on the machine and is available in PATH environment variable. at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.DotnetHostHelper.GetMonoPath()

When i run the same command in my personal PC no problems were found.

EDIT: My *.csproj file attached

<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>
2 Answers

Based on the error message (and some of the comments), it looks like you're using the wrong type of runner.

GitLab CI/CD is run on a GitLab Runner. If you want to run anything that relies on Windows or Windows packages, then you need to either install a GitLab Runner on Windows or if you're using GitLab.com, then use the Windows shared runners.

The image you specified image: mcr.microsoft.com/dotnet/sdk:5.0 in the CI yaml will also need to have all the dependencies installed, or install the necessary ones as part of the script section.

I also recommend taking a look at the dotnet CI example and dotnet-core CI example. See the CI/CD Examples docs page for more.

I have a similar problem, when trying to run tests in a Docker Linux container, using NUnit3Adapter and VisualStudio 2022 TestExplorer. No issue with MS Test Framework, but NUnit searches for a mono framework, although dotnet for Linux is provided.

Any idea why the NUnit tests look for mono instead of dotnet in the adapter?

I use multiple target frameworks in the projects, usually .NET 6.0 and .NET Framework 4.72, but for Linux I only want .NET 6.0.

Image base is: mcr.microsoft.com/dotnet/sdk:6.0

Error:

[02.09.2022 4:12:50.021 ] [Error] System.IO.FileNotFoundException: Could not find 'mono' host. Make sure that 'mono' is installed on the machine and is available in PATH environment variable. at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.DotnetHostHelper.GetMonoPath() at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DefaultTestHostManager.GetTestHostProcessStartInfo(IEnumerable``1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable´1 sources, String runSettings) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)

Related