asimmon / ephemeral-mongo

EphemeralMongo is a set of three NuGet packages wrapping the binaries of MongoDB 4, 5 and 6 built for .NET Standard 2.0.
Apache License 2.0
103 stars 12 forks source link

System.IO.FileNotFoundException : Could not find mongod in the following paths #48

Open azzlack opened 1 year ago

azzlack commented 1 year ago

Getting the following error when building on Ubuntu 22.04 in our Docker CI environment:

System.IO.FileNotFoundException : Could not find mongod in the following paths: '/builds/lunsjkollektivet/internal/backend/src/Tests/Tests.Common/bin/Debug/net6.0/runtimes/linux-x64/native/mongodb/bin/mongod'

I am using the package references mentioned here: https://github.com/asimmon/ephemeral-mongo/issues/36#issuecomment-1698390299

The commands that i'm running when testing are as follows:

export NUGET_PACKAGES="$(realpath ./.nuget)/"
dotnet restore ./Tests/Tests.Common/Tests.Common.csproj --packages ./.nuget
dotnet test ./Tests/Tests.Common/Tests.Common.csproj --no-restore --collect:"XPlat Code Coverage" --logger "trx;LogFileName=test-result.trx;MethodFormat=Class;FailureBodyFormat=Verbose" --results-directory "./.testresults"
wcgomes commented 10 months ago

Hi,

I had the same issue using the EphemeralMongo7.runtime.ubuntu.22.04-x64 package.

After the build you should find a runtimes folder inside the bin directory. Inside the runtimes folder you should see the ubuntu.22.04-x64 folder, but the test is expecting a folder named linux-x64.

A temporary workaround for this is create a after build task to copy those files to a new linux-x64 folder.

  <Target Name="CopyMongoRuntimes" AfterTargets="Build" Condition="$([MSBuild]::IsOSPlatform('Linux'))">
    <Message Text="Executing CopyMongoRuntimes task" Importance="High" />
    <ItemGroup>
      <FilesToCopy Include="$([MSBuild]::EnsureTrailingSlash('$(TargetDir)runtimes\ubuntu.22.04-x64\'))**\*.*"/>
    </ItemGroup>
    <Copy SourceFiles="@(FilesToCopy)" DestinationFolder="$([MSBuild]::EnsureTrailingSlash('$(TargetDir)runtimes\linux-x64\'))%(RecursiveDir)"/>
    <Message Text="Copied CopyMongoRuntimes files" Importance="High" />
  </Target>
stevekumbsky-gdrx commented 3 months ago

@wcgomes - thanks for this workaround. I've recently had to work on a project with MongoToGo (which does not support linux) and moved to EphemeralMongo but encountered the OpenSSL issue which lead me here.

@asimmon - I think the issue may be related to the the #43 PR. If I understand the code properly - in the DownloadMongoTask class, there are ProjectInfo objects set for the Ubuntu 22.04 runtime for Mongo6 and 7.

new ProjectInfo("EphemeralMongo7.runtime.ubuntu.22.04-x64", "ubuntu2204", "x86_64", "targeted", 7, "ubuntu.22.04-x64"),

However, the Rid property (last value in setting ProjectInfo) is to ubuntu.22.04-x64 and NOT linux-64 . I downloaded the repo but I'm getting runtime issues in compiling and such so can't really try out. Is is possible that setting the Rid property to linux-64 for the Ubuntu 22.04 runtime would solve this issue? Or is that intentional to have a new Rid?