Posts

Showing posts with the label .Net Framework

NUnit Console Runner and NLog extension logging for your tests

Image
Have you experienced the frustration of tests running perfectly well on your local machine and then failing in CI? This all too familiar "It worked on my machine" comes to mind. You set off to investigate and after a while you realize you are too far into the rabbit hole between code and logs in Kibana and this investigation is getting you nowhere. Wouldn't it be nice if you could hijack the logger and print the logs in the test runner's console? TL;DR NLog can be extended easily and NUnit  Console Runner does not play well with simple console logs.   Photo by  Kaboompics .com  from  Pexels Enter Console logging In .Net in general it is not advisable to log to console in a multi-threaded environment, because the console is not thread safe. While logging simple strings may not cause any problems logging strings with interpolated variables may very well be sub optimal to say the least. Should you use any such debugging technique you are better off with a thread safe f

Running an Asp.Net Core 2.* Web API as a Windows Service

Image
At my current workplace there is a healthy hunger for new technologies and a pragmatic view of the software industry in our corner of the planet. As a Microsoft driven shop, previous reservations of moving to different ecosystems and operating systems have melted away with the arrival and wide adoption of .Net Core. After all the language is the same. The developers need "only" to catch up on their containers. When I joined a month ago as a tech lead, little did I know that putting my money where my mouth is would mean having to deal with outdated Microsoft documentation or even S.O answers to questions such as "How do I run an Asp.Net Core app as a windows service without IIS". TL;DR add a reference to the NuGet package  Microsoft.Aspnetcore.Hosting.Windowsservices , publish and register your executable as a service. A Prophecy? Almost a year ago I wrote a blog post about porting  full framework projects to core . Ever since I have written my share of .Net Cor

How to port a .NET framework project to .NET Core including tests - A Guide

Image
So you want to port your project to .Net Core and don't know how? Are you reluctant to let go of your traditional .Net Framework targeting but want to have a taste of the new .Net buzz?  Is the information on the subject incomplete or too confusing (yes it usually is). Well you have come to the right place.  TL;DR This is guide. It will hopefully save you time. Rejoice. A tale of two frameworks (well actually 3)  I will make this one short and sweet and let this article tell the tale. I recommend to read this article  before you continue:  .NET Standard - Demystifying .NET Core and .NET Standard . To port or not to port It depends If this is your production code and there is no prospect to run it in a platform other than windows then maybe not.  If it is a huge complicated project then maybe not If it is your open source baby maybe yes If it is a new project and you see the benefit of it being cross platform maybe yes The considerations are many and it is up to you