Nuget “Include Prerelease” not equals “latest version”

Today I stumbled on ‘strange’ behaviour of Nuget. Well, it’s not really strange but more like confusing.

It started when I added Application Insights to an existing website. This can be done in several ways (there is really good tooling inside Visual Studio when creating a new website or with the right-click on the project) but I was adding it by hand.

So I added Application Insights for Web Applications. And version 0.17.0 was added. This is relying on the Application Insights API package 0.17.0.

All went well.


But later on I noticed(*) that there is a even newer version of the SDK package is available: 0.17.1


Well, my assumption is then when I ask for packages, including prereleases, I automatically get all the latest versions. I was wrong.

What did I learn today? Do not take Nuget and it’s release management for granted. After installing a certain package, check for updated and decide if that one is good for you.

* I ran into a problem when I simply added the System Diagnostics listener nuget package. Suddenly my code was not working anymore (and I got this ‘Object reference not set to an instance of an object’ when simply consuming the Telemetry client). I traced it down to a line of code in the Application_Start() method in the App.config. There I add the Application Insights instrumentation key by hand because we want to separate tracing from developers and from testing and from production (we are using an OTAP environment). Just by removing that line, everything was working again. But I lost the iKey choice. In the end, just updating the SDK nuget package fixed this error.