Wednesday 13 July 2016

First thoughts on asp.net core

I've been playing with asp.net core recently and thought I'd share a few of my findings, good and bad. I always need some sort of little project to keep my interest when learning something new and I had something perfect, small-ish but very useful for work.

We have 4 go servers at work, each manage a different group of microservices which form a business capability. We have ~50 services, each one is built and deployed to different environments via go pipelines of which we have 400+ (we deploy to 3 regions and have prod/preprod/test environments in each). What we need is a way to visualise the state of all the value streams, to easily see if there are any problems and what the deployed versions of each service is. I will blog some more on this when I get an actual working solution, for now I've just being doing project setup and tests. You can find the project here: https://github.com/DamianStanger/go-stats-aggregation

So .net core, what are my findings so far?

dotnet command line

I do all my dev in VS2015 so why do I need this? Often you don't but I've found the command line to be faster than building through VS, and as for running tests, that is no competition.
You can create projects, restore packages, build, run and test all via the command line with ease. Is it too soon to wave goodbye to msbuild?
Checkout the docs on the command line tools and the getting started with .net core.

I do lots of the DevOps work at the office and I can see the command line coming in to its own on the build server. Although I don't see myself running anything on linux anytime soon its nice to know its an option, and its forced a rethinking around the command line which is nice.

Project structure

Its been really interesting to see the evolution of the project structure. No more hefty csproj files where you mix config with project setup, now you have a lightweight xproj file and a number of json files holding your config. I like it, it's moving in the direction of other web technologies in how the contents of the folders form the code base rather than a big file list maintained and merged in a csproj file.
I'm also a big fan of wwwroot, finally you don't have to mix source code with static files.

Kestrel HTTP server

This was an interesting find for me. I like node (although i don't find much excuse to use it these days) so it's great to see a light weight single threaded HTTP server as part of the core asp.net framework. Lots of options, you can quickly and easily get the app running in iisexpress or in the console with the command "dotnet run".
Added to this, gone are the days where people complain about the performance of IIS, Kestrel has some rather impressive benchmarks behind it.

ReSharper

In general ReSharper is it's usual awesome self whilst developing .net core apps. But, (and there is a theme here, see NCrunch below) testing of a .net core app with a .net core test dll is not supported yet. From the ReSharper blog "One thing to note is that this build does not yet support running tests for DNX projects, this will hopefully be included in a future build". I can only hope this changes soon, come on JetBrains, do it.

NCrunch 

Sad times with NCrunch too I'm afraid. It does not yet support .net core development. Check here for updates to this issue and here for updates and what frameworks are supported

moq.netcore

moq as found on nuget.org is not compatible with .net core :-( but Microsoft have created a version that is :-) it is located on the Microsoft internal nuget feed myget. Instructions can be found here: http://dotnetliberty.com/index.php/2016/02/22/moq-on-net-core/

integration tests

Amazing, I'm so pleased this is now as easy as this. You can spin up an in memory HTTP server and use it to do testing with. Really good. I've not looked at hooking it into selenium or anything that can understand the DOM yet so most of the uses I'm finding right now are with pattern matching and regex. Check out the integration tests I've written and the docs on integration testing.

Testing

So ReSharper has let me down, NCrunch has failed to rise to the challenge which leaves me with the runner in visual studio (It works and i can debug tests but it's so so slow) or the command line. So as of right now for testing I've been mainly using the command line "dotnet test". Ive even written a little powershell script to run all my tests. It's really fast, it could be faster yes but I'm happy with this for now, and compiles your source before running for a bonus.

browser link

Sadly I've not had much luck with this. I think its because asp.net core does not yet support signalR. I've not spent a vast amount of time investigating but other than reloading browsers whilst running I've not had much success.

Docs

I'm liking the new documentation on the new sites: https://docs.asp.net/en/latest/intro.html and https://docs.microsoft.com/en-us/dotnet/index
Well organised, easy to navigate and actually useful, makes a change. I hope they keep it up to date and keep the samples relevant to new versions as they come out.

Finally

I'm really pleased I've begun to dig into this new world of .net core, not because I'm interested in any cross platform abilities but just because it gives some really nice features.

What are your thoughts on the good and bad about .net core and the direction asp is heading right now? I've only been playing with this at home but getting a good feeling bar the tooling which I'm sure will catch up soon enough.

No comments:

Post a Comment