.NET core gotcha
Recently I've been messing around with the new .NET Core.
I've created a class library which I'm using in an ASP.NET Core Web API.
Firstly, at least before 1.1, I couldn't add a reference to the class library just by giving it the .dll file. I needed to create a NuGet package of my library and publish it to a NuGet feed. I set up a local NuGet feed and added it as a source in VS and were able to add my code. This is all fairly easy.
Instructions on how to create a NuGet package can be found here: https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package
And how to set up a local NuGet feed: https://docs.microsoft.com/en-us/nuget/hosting-packages/local-feeds
After a while I did some changes to the library and wanted to update the package in my Web API project as well. I did a build of the library, updated the version number and created a new NuGet package and finally published it to my local NuGet feed.
All looked well in my WebAPI project, I saw the new version number and was able to update it. Suprisingly the newly added functionality in my package was missing! I tried the whole process again, only to find the same. Then I removed the NuGet package and reinstalled it. Still no luck.
This led me to think that there was something in my Web API project that did this so I decided to create a completely fresh solution and added the NuGet package there. I was again surprised to see that the new functionality was still missing!
After doing some searching and finding a couple of references to issues with the preview versions of .NET Core I tried to clean the folders of my class library, and rebuilding the solution. I got no errors on build, rebuild and clean and thought all was well.
I checked the dll created from the build and I saw that this had the old version number but anyway I created a new NuGet package with a new version number and back in my Web projects I tried to reinstall the NuGet package once more. Still I found that the functionality was missing.
Totally out of clues as to how to proceed, without starting building a fresh class library, I mentioned this to a colleague. He had struggled a bit with .NET Core before but couldn't really understand what was making this mess. The only thing he asked was if I had been doing the builds from Visual Studio directly or if I used the command line.
I had infact only been using VS, and with no errors reported I was confident that this couldn't be the issue, but I gave the command line option a go. I ran dotnet build on my solution, no errors reported. Checked the dll created and VOILA! the version number was changed. I quickly created a new NuGet package, jumped in to my Web API project and updated.
Finally, my new code was available.
This was a really annoying experience. Of course the build in VS should be able to do this properly, or at least report an error if not. But I must say I am a bit annoyed with myself for not thinking of the command line build option..