.NET Core Console App with Dependency Injection, Logging, and Settings

preview_player
Показать описание


0:00 - Intro
1:49 - Creating Console App (.NET Core)
3:35 - NuGet references
7:29 - Editing csproj file in .NET Core
9:15 - Add application settings json file
10:46 - Define goals
11:30 - Builder setup: BuildConfig
21:12 - Serilog setup: LoggerConfiguration
25:04 - Host setup: CreateDefaultBuilder
30:11 - Program entry point Class
39:51 - Dependency Injection
43:04 - Calling entry point in Main()
50:10 - Runnning the application and fixing exceptions
55:02 - Recap, summary and concluding remarks

Thanks to Ralfs HBK for the chapter breakdown
Рекомендации по теме
Комментарии
Автор

Yes. I would very much like to see the winforms and WPF version of this.

ibrahimhussain
Автор

uowwww!!! great content as always, tim!!
my skills have grown so much since i´ve started following your videos, I usualy watch them several times and they´re my first consulting material whenever I get doubts during daily job....

TheJessejunior
Автор

I especially enjoyed this video.
I enjoy most of these videos, but I especially enjoyed this one.

It is greater to watch this, even if you never intend to write a console app, and explains the DI that gets used when writing an ASP/Web app.

I really like how you will always say "Don't do this in production" and then go back and fix it.
It can get a little frustrating when going through tutorials that say things like that, but never show you how to actually do it 'properly'.

JonathanPeel
Автор

When I see the "I" in the channel's name, I always think it's an interface.

Автор

Bro your videos are AMAZING. You are covering the topics that we want to learn about, but other people are not covering!

divanvanzyl
Автор

I’m happy to see this. I’m a developer who primarily works on windows worker services / windows services, and a lot of backend applications where there is no user interaction. A lot of people forget that there are a whole realm of developers who aren’t primarily working on web.

goodoleme
Автор

Your content's trustworthiness has become my go-to, when looking for C#/.Net subjects.

mohammedal-mudhafar
Автор

First of all excellent videos!. I wanted to add that at 38:00 another very good reason to pass parameters separately is to avoid the string manipulation if our log level is higher.

josepiratilla
Автор

Tim, this is pure gold:
var svc =
Save my life on a few console application that I'm now refactoring to hookup DI properly or the right way. Thanks a bunch.

sunilanthony
Автор

As always a very clear, tight explanation of how things work in the .NET world. Thanks.

oncalldev
Автор

Thanks Tim for teaching us dependency injection in a very simple way !

AmitDileepKulkarni
Автор

Thank you so much for this!! I discovered this video after struggling with migrating some code from the Framework to Core. The video demonstrated the functionality in a way that I could easily internalize and use. Subscribing to the Patreon is the least I can do. Be well!!!

oscarjr
Автор

Tutorials like these are little gems from this man.

parko
Автор

This one had a lot of great information in it. Thanks Tim! Keep them coming!

JoshuaKersey
Автор

Great tutorial :-) Tim treats wachers as human beings: inteligent and smart, because he is very inteligent and smart and tries to predict eventual question or request and imediatelly answer to it. What a great guy :-) But without self-exaltation.

RobertOspara
Автор

I love the refactoring option (underscore) update...I have been using that for a while now...just popped back as I had lost it...oh and the content is great too ;o) Thanks for the great content Tim.

mbrotto
Автор

Thanks for the underscore tip; that will save me some time. I recently implemented something like this using AddHostedService to register the operation class (GreeterService in your case), and host.RunAsync to execute it. The trick with this approach is to call at the end of the operation to terminate the process.

jalvrus
Автор

So well put, I almost never come across a video where you follow tutorial step by step and it works, usually something is missing, something is forgotten
thank you!

KhachaturStepanyan
Автор

The copy output directory tip was clutch! Exactly the issue I was having. Great video as always. Thanks

BlahzayBeta
Автор

Good video. Just a couple clean up items that were forgotten:

1. *host* is an IDisposable, so you should wrap it in a using in your main method or call Dispose() manually. This way it cleans up every dependency that you might have living in your dependency injection.
2. It's best practice to call Serilog's Log.CloseAndFlush() method at the end of your program since you created the logger outside of the hosting environment. If you configure Serilog in the .UseSerilog() method, you don't have to do this (assuming you are disposing host properly).

lockegarmin