Welcome back. How was your week?

Let's hop back in.

The Base Solution

Assuming you're using version control, we'll start by making a new branch. It's probably unnecessary at this point, but it's a good habit to be in.

From your project directory:

git checkout -b foundation

This command will create a new branch called foundation and switch you to that branch. Now we should be able to work in some degree of freedom without breaking anything in our main branch.

The first thing we should do is create a solution file. This is mostly a construct of big Visual Studio, but having a solution file does make future automations slightly easier.

dotnet new sln -n ResumeGenerator

Whew, that's a file created. Here comes the real dangerous part of the project.

How do we want to interact with the tooling?

We could write a simple console application that outputs a PDF, but it might be better to have a few of some sort so you can see how things look before it spits it out. Just in case.

That being said, we'll start with an empty web project and connect it to our solution.

dotnet new web -n Web

This should create a new folder called Web with some files inside of it. To link it to the solution, we'll use the dotnet sln command.

dotnet sln add Web/Web.csproj 

To make sure that worked, run the dotnet build command and you should see an output that looks like this.

$ dotnet build
Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  Web -> C:\[YOUR_DIRECTORY]\ResumeGenerator\Web\bin\Debug\netcoreapp3.1\Web.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:03.07

This shows us that the solution file knows to go and build the project. If and when we add future pieces to the project, we can now run dotnet build from the directory with the solution file and everything should go.

Simple.

The Base Project

Since we've added a web project to the solution, we should be able to see a pretty empty web page as a reward for out troubles.

$ dotnet run -p Web/Web.csproj 
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\[YOUR_DIRECTORY}\ResumeGenerator\Web

Opening a browser and going to http://localhost:5000 shows us our reward for the hard work.

2020-09-10-14_20_27-https___localhost_5001

Kind of boring, but it's better than nothing.

An Interrogation of the Hierarchy

Let's take a look at our project directory and see what we have in this project.

- ResumeGenerator
  - LICENSE
  - README.md
  - ResumeGenerator.sln
  - Web
    - appsettings.development.json
    - appsettings.json
    - bin
    - obj
    - Program.cs
    - Startup.cs
    - Web.csproj

A lot of these files are just the cost of doing business, but let's look at the important ones.

  • LICENSE and README.md are part of your version control if you went through GitHub when you created a new repository. I'll update the README as I go along, but mostly so we can keep it and this post somewhat in sync.
  • appsettings.*.json is where we can store environment variables and keys the project may rely on. This file is very handy in development, but can sometimes be a security risk if you go to deploy, so we won't use it a ton.
  • Program.cs and Startup.cs are the currently the only actual programming we have for our beautiful Hello World page.

For the most part, we can ignore everything else.

Wrap Up

I'm going to wrap up here because this post has already gone a little long. Again, assuming you're using version control, we'll do a commit, push, and then a merge through a pull request.

git add . && git commit -a -m "Added Foundation" && git push

This will make sure all of the files are added, commited, and pushed up to the repo. The pull request will be different based on your provider, but here's how to do it in GitHub.

Next time, we'll add some structural components to the Web application to allow us to start adding bigger pieces of information and control the content of the web page it produces.