title: Unit Test Results from 'dotnet test' call in Docker
body: <p>I am starting to investigate Azure Devops and its pipelines feature for setting up a continuous integration workflow. I have a pipeline that builds a Docker image of my application using the following dockerfile:</p>
  
  <pre><code>FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build-env
  
  WORKDIR /cicd
  
  # restore (put more volatile, changing projects later in process)
  COPY src/WebApp/WebApp.csproj ./src/WebApp/
  RUN dotnet restore src/WebApp/WebApp.csproj -s http://mycontainerrepo.acme.com/repository/nuget/
  
  COPY tests/WebApp.Test/WebApp.Test.csproj ./tests/WebApp.Test/
  RUN dotnet restore tests/WebApp.Test/WebApp.Test.csproj -s http://mycontainerrepo.acme.com/repository/nuget/
  
  # copy source
  COPY . .
  
  # test (if tests fail, no final image, yay)
  RUN dotnet test tests/WebApp.Test/WebApp.Test.csproj
  
  # publish
  RUN dotnet publish src/WebApp/WebApp.csproj -o /publish
  
  # runtime stage
  FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS release
  COPY --from=build-env /publish /publish
  WORKDIR /publish
  ENTRYPOINT ["dotnet", "WebApp.dll"]
  </code></pre>
  
  <p>The call to run <code>dotnet test</code> executes just fine and outputs results to the console, but I don't know of any way to make use of this result in the pipeline. In TeamCity, you could set an <a href="https://github.com/Microsoft/vstest/issues/1590" rel="nofollow noreferrer">environment variable</a> to sort of trick it into outputting the test results (xUnit only, I think...). But not sure if there's a similar trick here...</p>
  
  <p>I saw <a href="https://github.com/dotnet/dotnet-docker/blob/master/samples/dotnetapp/dotnet-docker-unit-testing.md" rel="nofollow noreferrer">this post</a> on Github about making a separate test image just for testing but was hoping to avoid that route unless its my only option.</p>
  
  <p>Any other CI/CD Azure Devops gurus out there?</p>