Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Some core opinionated functionality for ASP.NET Core applications.

License

Notifications You must be signed in to change notification settings

Homely/Homely.AspNetCore.Hosting.CoreApp

Repository files navigation

Homely - ASP.NET Core MVC Helpers

Homely - ASP.NET Core 'Hosting' core application-library.

This application-library contains an opinioned program.cs class which is to reduce the ceremony for creating ASP.NET Core "Web Hosting" applications.

Basically, we (at Homely) use the same program.cs code for litterally all of our microservices. So instead of just copying/pasting this code or having this same code in our Template, we've provided this code as a NuGet package so it's easy to update all-or-any microservice if we decide to change something (e.g. we decide to change to a different logging framework).

NOTE: This is a netcoreapp application and not a netstandard library. So it can only be referenced in another netcoreapp .NET Core Application.

Build status


Why use this? What's wrong with the default standard program.cs?

We're just extending the default program.cs content that comes out of the box by:

  • Wrapping the default code inside Serilog error handling. So if any error occurs at any stage of the program (most importantly, at the EARLY starting/initialization stages, Serilog will nicely handle this.
  • Logging some important*** information about the web api: assembly date, version and when this program first started.

That's it :)

Reducing boilerplate code.

*** We (at Homely) thinks this is important!


How to use this library

  1. install-package Homely.AspNetCore.Hosting.CoreApp.Program.Main into your ASP.NET Core application.
  2. Reference the Main<T> method. You can optionally provide some customization ... if you feel like it.

Simple quickstart

public static Task Main(string[] args)
{
    return Homely.AspNetCore.Hosting.CoreApp.Program.Main<Startup>(args);
}

NOTE: the Startup class should be your Startup.cs class.

More customized startup

public static Task Main(string[] args)
{
    var options = new MainOptions
    {
        CommandLineArguments = args,
        FirstLoggingInformationMessage = "~~ Accounts Web Api ~~",
        LogAssemblyInformation = true,
        LastLoggingInformationMessage = "-- Accounts Web Api has ended/terminated --",
        EnvironmentVariableKey = "ASPNETCORE_ENVIRONMENT"
    };

    return Homely.AspNetCore.Hosting.CoreApp.Program.Main<Startup>(options);
}

Contributing

Discussions and pull requests are encouraged :) Please ask all general questions in this repo or pick a specialized repo for specific, targetted issues. We also have a contributing document which goes into detail about how to do this.

Code of Conduct

Yep, we also have a code of conduct which applies to all repositories in the (GitHub) Homely organisation.

Feedback

Yep, refer to the contributing page about how best to give feedback - either good or needs-improvement :)