I recently made a small library, InMemoryLogger, to support recording and inspecting logs made from .NET Core code under test. The library is pretty small and simply implements a .NET Core Ilogger that records incoming logs and exposes them for inspection through a few public properties. I've been using InMemoryLogger for a while now and I think it is ready for other people to use too.
If you follow arrange/act/assert in your tests the idea is to create the in memory logger in the arrange part either by directly newing it or adding it to the application under tests IServiceCollection. Then do whatever to the application under test in the act part, and finally inspect the properties that expose recorded logs on the InMemoryLogger in the assert part.
For more info check out the readme or grab InMemoryLogger from NuGet.
Monday, June 17, 2019
Wednesday, April 3, 2019
Interview on the .NET Core Show
Last week the .NET Core Show published an interview with me where where I talk about various aspects of developing microservices with .NET Core, though most of it technology stack agnostic. Enjoy.
Saturday, February 16, 2019
Building a self-contained .NET Core app in a container
Last week I needed to
This is a Dockerfile that allows this:
And the two commands needed to build and run the container are:
That builds the self-contained app into .\output\release\netcoreapp2.2\linux-x64\publish\
For context: In my case I needed to build DbUp as part of the build pipeline for a service that I run in a container. I want DbUp to be self-contained so I can run it during the deployment pipeline without needing to install the .NET Core runtime.
- Build a self-contained .NET Core app.
- Not install the .NET Core SDK on the CI server
- Fit this into a build pipeline that was already containerized.
- First build a container using docker build
- The run the container with a local folder called "output" as a volume
This is a Dockerfile that allows this:
And the two commands needed to build and run the container are:
That builds the self-contained app into .\output\release\netcoreapp2.2\linux-x64\publish\
For context: In my case I needed to build DbUp as part of the build pipeline for a service that I run in a container. I want DbUp to be self-contained so I can run it during the deployment pipeline without needing to install the .NET Core runtime.
Labels:
.NET,
ASP.NET Core,
Docker
Subscribe to:
Posts (Atom)