The .NET platform has been revolutionized with the advent of .NET Core. A platform once limited primarily to Windows is now officially supported on just about any platform that you'd like to develop and run applications. In this course, Building Cross-platform Applications with .NET Core, you'll learn how to develop and run .NET Core apps on a variety of platforms. You'll learn how to publish your app to run on different runtimes as well as understand different deployment models and how to test both platform agnostic and platform specific functionality. You'll see how to work with files, app configuration, logging, and dependency injection. You'll also learn how to build console app, services and web endpoints to see that you can create just about any type of app. Finally you'll get an update on the state .of the .NET Core tooling that's still being developed including the latest changes to use the MSBuild project system. By the time you're done, you'll know what it takes to successfully develop a cross-platform .NET Core application.
Wes Higbee is passionate about helping companies achieve remarkable results with technology and software. He’s had extensive experience developing software and working with teams to improve how software is developed to meet business objectives. Wes launched Full City Tech to leverage his expertise to help companies delight customers.
Course Overview Hi, my name is Wes Higbee. Welcome to my course, Building Cross-Platform Applications with. NET Core. For over a decade now, the. NET platform has been limited to Windows, and that's a shame because the platform itself as well as the C# language provide a wonderful set of tooling to develop applications. Take for example Link, a highly productive way for you to slice and dice data and quickly get the results you need without a lot of convoluted code. Or take the TPL, a set of APIs to drastically simplify parallel programming that's been around for quite some time now in the. NET framework. Starting with. NET Core, you have access to not only develop but also to run your. NET applications just about anywhere. And in this course I want to help you get started with that. In this course we'll start out with a console application that we both develop and run on a variety of different operating systems. We'll talk about confidently testing across platforms. We'll then talk about how you can work with files. We'll move on to how you can deploy your application, instead of as a console app, but as a service. And we'll talk about how you can run that service on different operating systems and platforms. We'll get into how you configure your applications and how you can log output from your applications. We'll take a look at how we can read and write data to databases. We'll look at dependency injection. And then we'll wrap up taking a look at how we can use ASP. NET Core to embed a web site or a web endpoint inside of our service. When you're done with this course, you'll be able to build console apps, services, and web apps that can run on Mac, Windows, Linux, and even Docker. Let's get started.
Building Console Apps In this first module, we'll go about creating a console application. We'll take a look at how we can develop it on a variety of platforms, and how we can build and run it on a variety of different platforms. And along the way, I'm going to share with you some of the changes with the. NET Core tooling, specifically the switch from project. json to the MSBuild tooling. I intend for that to be an added bonus of this course. I can give you an update on the state of. NET Core and where development is headed.
Publishing to Multiple Platforms Thus far, we've built up our console application and we've used the source code to get that application to run on a variety of different platforms: Mac, Linux via Docker, and Windows. Chances are, you won't want to distribute a source code though when it comes time to deploy your application. In this module, we will turn our attention to distributing a compiled version of our application. This'll simplify what it takes to run our app on various different platforms, and it'll also simplify what people need to have installed on a given target machine. As we distribute our compiled application you'll probably wonder how do I know if this will actually work? So what can I do to test across the various different platforms that I might be using? And that testing might be simply just running the application on a target platform, how do you do that? What might you set up in a continuous integration environment to be able to perform some automated testing? But then also how could we write some unit tests of individual snippets of code to have some confidence in then? These are the topics that we'll cover over the next two modules.
Working with Files We've gone through quite a bit of the plumbing to be able to build our application, to restore packages, to compile it, to publish it, and to run it on different platforms, and even write some tests that work on different platforms. Now, let's get into some of the nuance of building a console application. What are some of the things that we're likely to do in a console application, or any sort of application, for that matter? Well, when it comes to applications, we tend to like to access files. So let's take a look at what it's like to work with files when we're writing cross-platform. NET Core console applications.
Configuring Apps When building. NET Core applications, we oftentimes want some means to be able to configure our application. For example, in this link checker, we have a website right now that's hard coded. It might be nice to inject that from some argument somewhere so that we could run this for different websites. Also, that report file that we're writing out to. It might be nice to customize that as well. In this module, we will turn our attention to configuring our applications. And we'll see how Microsoft has provided a wonderful framework and a set of APIs to be able to easily and consistently configure applications using environment variables, JSON files, INI files, command line arguments, and many other providers.
Logging Logging is another prominent consideration when it comes to writing just about any sort of application. And in the past, we've had lots of libraries that we can choose from to be able to log output in our applications. We have even had APIs that are built into the. NETFramework, itself. Well now, we have a new logging framework that again is affiliated with ASP. NET Core, but is actually applicable in any type of. NET Core application. So let's take a look at that in this module.
Writing to Databases What's an application if it doesn't have a database to store information for the long haul? Of course, we've seen how we can use files to store a report but what if we want to have a common database that we can use for an application that works across platforms? That's what we'll turn to in this module. I will prefix this module by saying that there are plenty of courses that dive into the specifics of data access using a given technology, for example Entity Framework. And I don't want to blow this module up into its own course. Instead, I just want to talk about a few cross-platform considerations and mostly, I want to focus on how easy it is to be able to spend up databases inside of containers, 'cause I really think that's the future of how we're going to be using development databases. It's just so simple to do, I want to show you that using a variety of different databases. And I want to show you how easy it is with Entity Framework Core to access all these different database technologies without doing much besides changing a connection string in our code.
Building and Deploying Services Thus far in the course, we have focused on a console application. And that's only one type of app that we might like to deploy. We might also like to deploy some sort of service, basically a console app that just runs in the background. In this module, we'll take a look at creating a service that takes our link checker and just runs in the background every minute to check links on a given website. And of course, in a real application, you would want to maybe make it do more than just check one site, but we'll keep this simple. We'll check our website every minute, and save out the results as we have been in the past.
Adding a Web Status Endpoint We took a step down what is a slippery slope when we used the ASP. NET core framework to block our console application so it could act more as a service when we are running inside of a systemd. service. So we added that for blocking, and that was one of many ways that we could do that. I did that though because I wanted to talk about adding a web status endpoint, which is a nice thing to have in just about every service these days. It's nice to have a web endpoint you can go to, just to see what's going on inside of that service. So that's what we'll take a look at in this module. Now that we've put one foot on that slippery slope, we will slide down the rest of the way.
Injecting Dependencies In this last module of the course, we will turn our attention to dependency injection. This is also a framework much like logging and configuration. This, again, is affiliated with ASP. NET Core, but it doesn't mean it's limited to ASP. NET Core, and we will take a look at that in this module. Specifically, we'll talk about getting our task to work again. So the job that we have that runs every minute to check links. And, we'll also look at how we can integrate logging and configuration with ASP. NET Core and with Hangfire. And behind the scenes, we'll see the magic happening. We'll see that both ASP. NET Core and Hangfire are using the same logging system. We'll get their messages out into our logging destinations like our console output and also our file output, and we'll see how that can all work really nicely together with this centralized logging framework that we now have. So let's get started.