No test is available message when running dotnet test using Dockerfile

Expected behavior

The unit tests should run successfully.

Actual behavior

The unit tests are not running successfully.

Additional Information

I have added a dotnet test command in my Dockerfile, but when I ran it the logs showed the message No test is available in /src/poc.tests/bin/Debug/net6.0/poc.frontend.unittests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

#20 [build 12/13] RUN dotnet test "poc.frontend.unittests.csproj" --logger "trx;LogFileName=test_results.trx"
#20 1.088   Determining projects to restore...
#20 1.513   All projects are up-to-date for restore.
##[debug]Agent environment resources - Disk: / Available 18863.00 MB out of 74244.00 MB, Memory: Used 820.00 MB out of 6932.00 MB, CPU: Usage 11.69%
#20 3.886   poc.frontend.unittests -> /src/poc.tests/bin/Debug/net6.0/poc.frontend.unittests.dll
#20 3.905 Test run for /src/poc.tests/bin/Debug/net6.0/poc.frontend.unittests.dll (.NETCoreApp,Version=v6.0)
#20 4.003 Microsoft (R) Test Execution Command Line Tool Version 17.3.3 (x64)
#20 4.004 Copyright (c) Microsoft Corporation.  All rights reserved.
#20 4.010 
#20 4.126 Starting test execution, please wait...
#20 4.173 A total of 1 test files matched the specified pattern.
#20 5.156 No test is available in /src/poc.tests/bin/Debug/net6.0/poc.frontend.unittests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
#20 5.265 Results File: /src/poc.tests/TestResults/test_results.trx
#20 5.266 
#20 5.273 Additionally, path to test adapters can be specified using /TestAdapterPath command. Example  /TestAdapterPath:<pathToCustomAdapters>.
#20 DONE 5.4s

This is strange as I have the NUnit3.TestAdapter.dll in the bin folder and running dotnet test on my machine generates the correct result. Is there a configuration that I am missing in my Dockerfile?

Running from my local machine produces the correct result, that is, the unit tests are being executed successfully.

This is my Dockerfile.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["poc.frontend/poc.frontend.csproj", "poc.frontend/"]
RUN dotnet restore "poc.frontend/poc.frontend.csproj"
COPY ["Tests/poc.frontend/poc.frontend.unittests/poc.frontend.unittests.csproj", "poc.tests/"]
RUN dotnet restore "poc.tests/poc.frontend.unittests.csproj"
COPY . .
WORKDIR "/src/poc.frontend"
RUN dotnet build "poc.frontend.csproj" -c Release
WORKDIR "/src/poc.tests"
RUN dotnet build "poc.frontend.unittests.csproj" -c Release
#RUN dotnet test --test-adapter-path "bin/Release/net6.0/NUnit3.TestAdapter.dll" -c Release --results-directory /testresults --logger "trx;LogFileName=test_results.trx" "poc.frontend.unittests.csproj" -v normal
RUN dotnet test "poc.frontend.unittests.csproj" --logger "trx;LogFileName=test_results.trx"

FROM build AS publish
WORKDIR "/src/poc.frontend"
RUN dotnet publish "poc.frontend.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "poc.frontend.dll"]

Pipeline task:

- script: |
        docker build -f $(Build.SourcesDirectory)/${{parameters.dockerFile}} --target build -t frontend:v$(Build.BuildNumber) .
        docker create -ti --name testcontainer frontend:v$(Build.BuildNumber)
        docker cp testcontainer:src/TestResults $(Build.ArtifactStagingDirectory)/testresults
        docker rm -fv testcontainer
      displayName: 'Execute unit tests and extract the test result file'
      enabled: true

Steps to reproduce the behavior

  1. Create a pipeline in Azure DevOps and add the script above.
  2. Run the pipeline