This intro is unusually written just before publish – when the whole post is done. Why? Because plans have changed a bit. Not because of my intention, though. My concept for this post was to create initial Web App from a template, add some library project and its tests. Configure the whole repository on Continuous Integration service of my choice, Travis afterward. But as it turns out, Travis can only handle .NET Core projects, not the ‘typical’ .NET – my fault, I made some assumptions on my memories which were not correct. But! Sh*t happens, I’ll share what I did till now (solution and project creation). The part regarding CI will be (hopefully) described in next post.
Maybe I’m not an experienced open source contributor but I created few projects during my business career so let me present you how I usually do this.
Please treat this only as suggestions and filter out information that doesn’t fit your beliefs or company guidelines. However, below I describe what I like when the project is kicked-off.
This post is directed mainly to C# devs using Visual Studio, but – if you are not one of us, maybe you’ll get something beneficial for you anyway 🙂
The very first step of creating a solution is… creating a solution! Do I sound like Captain Obvious? May be, but in fact, many developers forget about this step and create solution willy-nilly while creating a project which in my opinion is a fault. What I aim for is to have a solution to be created separately. To have control while it is performing.
Unfortunately, it is not so easy to find the blank template in Project/Solution creator in VS – maybe this is the cause why it is used so rarely. On a screenshot below you can find blank template location (not very intuitive):
In newest Visual Studio 2017 there is a new approach to find for solution templates – you can just search for ‘blank’ or ’empty’ and desired template will be shown. If you like the old Form, just click ‘more…’
Thanks to that we have clean (indeed!) solution!
And only from that point, I start to add new projects to my solution.
Why do I care about it?
I really don’t like when a solution is hidden in any subfolder. This is the main file that describes all ‘ingredients’ that make your solution complete and it should be easily accessible at the very beginning. On one click – no matter where your code lays – is it C:\src\ or E:\Very\Secure\Corporation\Path\source\ – the solution file should be right there. Not in E:\Very\Secure\Corporation\Path\source\CodeMate\WebApp\ or so.
Let’s make our solution… dirty?
We have a clean solution, cool, Uncle Bob is proud, but… we need to add something here! As far as Web Application is meant to be done, I will add this project in first place.
We don’t want any built in authentication to be added, as far as the application is meant to be accessed by OAuth logging with GitHub or other services that are widely spread across programmers community. Unit tests are also omitted because Microsoft Framework Tests would be put by default in place – and I prefer xUnit to be in. At this point, we only incorporate MVC structure.
Now we have a comprehensive solution with few pages, controller, some scripts, styling, and views. We have our website now!
To make the last note on our solution creation, I really like to use Solution Folders – they don’t affect the physical structure of files but organizes the solution nicely so programmer always knows what lays where. I always start with two: ‘Core’ and ‘Tests’ which separates my application code and testing code. It may change as the project grows up, of course, must work for you and your team.
Configuring Continuous Integration
I wanted to cover CI with Travis with .NET here, but as I told you in the introduction, it turns out Travis supports only .NET Core building, so I must dismiss that one and find another. Maybe TeamCity will be an option? I don’t have a background with this application yet but I bet it is a marvelous piece of software as far as it is developed by my favorite Jetbrains.
If you want to find more about configuring .NET Core on Travis, please look at Michał Dymel’s post he committed recently.
I don’t think I use tools that many of you don’t know because all of them are quite popular, but maybe someone will find that list helpful.
- Visual Studio – no longer so obvious as other C# IDEs are in the game now
- Resharper – VS productivity boost – the reason I love JetBrains 🙂
- SourceTree – phenomenal Desktop visual client for Git source control
- GhostDoc – handy plugin for creation XML documentation (remember it gives good suggestions but doesn’t do the whole job for you!)
- WakaTime – tracker which tells you how many time you spent on each project in your Visual Studio (and not only, it has plenty other integrations like Notepad++, Eclipse, IntelliJ etc.)
- RazorGenerator – clever extension for compiling *.cshtml files (I will cover that more precisely later)
So! That would be it for today – not too much, but I lost some time with Travis unfortunately… I haven’t checked at the time if it fits .NET, because I was 100% convinced it does, but it turns out I was using it with Java back earlier – not with C# 🙂
In next post, I hope I will cover TeamCity integration – or another one capable of doing CI for my project for free.
P.S. On the top bar of this blog I put GitHub link so you can always give a look how the code actually shapes.