[Disclaimer: Patrick Smacchia from the NDepend team approached me and offered me a licence for NDepend if I would blog about my experiences with the tool. However, all opinions are my own.] Static code analysis is a powerful tool to understand and improve your codebase, using a variety of techniques…
C# 6 introduced getter-only auto-properties, which are a great way of conveying immutability for your classes. However, by default MongoDB ignores these properties from its class maps, as it can’t deserialise them back into a class. To automatically map read-only properties, you can use a custom convention: /// <summary> ///…
We use feature branches, and build all of them on our TeamCity CI setup. Every build can be deployed on our test servers, but it’s useful to be able to quickly distinguish which ones came from master and which came from other branches. I took a script from here and…
You can run this on a scheduled task and it will take a backup of all databases, zip it and copy it to a backup location, and automatically remove older backups after 7 days. REM Create filename for output set filename=mongodb-backup-%DATE:~6,4%_%DATE:~3,2%_%DATE:~0,2%__%TIME:~0,2%_%TIME:~3,2%_%TIME:~6,2% REM Export the databases @echo Dumping databases to “%filename%”…
We use logstash in our infrastructure, which ingests logs and outputs transformed data to a store of your choice, which for us is Elasticsearch. We then use Grafana to visualise some of this data. Recently we noticed that Grafana was struggling to perform the queries it needed, which led to…
ASP.NET temporary files can quickly mount up and eat up disk space, especially if you deploy multiple times a day. This website provides a handy command that you can run to delete any unnecessary files: Get-ChildItem “C:\Windows\Microsoft.NET\Framework*\v*\Temporary ASP.NET Files” -Recurse | Remove-Item -Recurse You’ll get a few errors when it…
It can be useful to time how long certain commands take to run. With Powershell, you can do this easily using the Measure-Command cmdlet: Measure-Command { ping google.com | Out-Default } Simply replace ping google.com with whatever you want to time, and off you go. You’ll get a readout similar…
Servers run out of disk space too sometimes, but the Server versions of Windows don’t have the handy Disk Cleanup utility installed by default. If you want to get it back, you can run this Powershell command: Install-WindowsFeature Desktop-Experience or you can follow the instructions here if you’re more of…
Here’s a nice little gotcha. When RavenDB (v3.0.30155) returns data from the database, it will generally preserve the casing of the IDs (e.g. an ID of MyDocuments/1 will be returned as such), even though RavenDB itself doesn’t care about casing (e.g. if you run Session.Load<MyDocument>(“mydocuments/1”), you’ll still get back the…
One of our builds just failed with this fairly cryptic error: [File content replacer] no net in java.library.path java.lang.UnsatisfiedLinkError: no net in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) Turns out we’d manually updated Java on the machine that the build agent was running on. If you…