DevOps is one of those things that I don't know enough about. For that reason, I try not to avoid it in the hopes that I will understand it. So today, I decided to setup a BitBucket Pipeline for a .NET 5 application. The documentation online seemed pretty straightforward and my starting bitbucket-pipelines.yml
file contained the following:
image: mcr.microsoft.com/dotnet/sdk:5.0
pipelines:
default:
- step:
name: Build and Test
script:
- dotnet restore
- dotnet build --no-restore
- dotnet test --no-build --logger:trx
Unfortunately, every time the tests ran, the following error would appear.
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.ProxyExecutionManager.StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler)
After some research, it turns out that the docker container is running on a Linux host and the dotnet sdk doesn't contain the mono-complete
dependency. Switching the dotnet sdk to an explicit Linux based container allowed for the installation of mono-complete
. The final working BitBucket Pipeline is as follows:
image: mcr.microsoft.com/dotnet/sdk:5.0-focal
pipelines:
default:
- step:
name: Build and Test
script:
- apt update
- apt install -y mono-complete
- dotnet restore
- dotnet build --no-restore
- dotnet test --no-build --logger:trx
I'm pretty clueless when it comes to DevOps, so if there's a better way to do this, please let me know in the comments! Thanks!
References
- Header image by Ulrichulrich, CC BY-SA 3.0, via Wikimedia Commons