Before we get into the "fun stuff", we need to make sure that we're working off a solid foundation.
More importantly, we need to be able to revert changes when we hork everything up.
I know that if you've made it this far, you've probably seen and used GitHub hundreds of times...but just in case, here's how we're going to do it.
There are a bunch of ways to do this within the GitHub interface. You're really just looking for the "New" button that's stashed all over the place.
That will take you to the screen to create a repository. Usually, I use codenames from one of my favorite podcasts, but since I'm making this one public I thought it would be a good idea to give it a recognizable name.
It's worth noting that I've selected to initialize the repository with a
.gitignore file (for Visual Studio), and a license. This usually sets up a decent path to work forward from and helps you keep most everything clean on your commits and pushes.
Once the repository is set up, you'll just want to clone it to your machines using the
git CLI. (Assuming you have GIT installed)
git clone https://github.com/IanKnighton/RecordCatalog.git
I'm not here to try and evangelize for any particular way of managing your code. However, I do think it's important to always practice some sort of workflow with your code. Yes, it is totally possible to just commit to
master all of the time when you work by yourself, but it's a bad habit to be in when you're working for or with someone else.
HubFlow is a tool that uses the Vincent Driessen's idea of how to with with Git branching and makes it easy to apply to a remote repository like GitHub. It's a very handy tool that I use for all of my projects, no matter how small or silly.
First, you'll need to clone and install HubFlow. Instructions can be found on their GitHub repository.
Once installed, navigate to the repository you cloned and initialize HubFlow.
git hf init
That command should have output similar to this:
Using default branch names. Which branch should be used for tracking production releases? - master Branch name for production releases: [master] Branch name for "next release" development: [develop] How to name your supporting branch prefixes? Feature branches? [feature/] Release branches? [release/] Hotfix branches? [hotfix/] Support branches? [support/] Version tag prefix?  Total 0 (delta 0), reused 0 (delta 0) remote: remote: Create a pull request for 'develop' on GitHub by visiting: remote: https://github.com/IanKnighton/RecordCatalog/pull/new/develop remote: To github.com:IanKnighton/RecordCatalog.git * [new branch] develop -> develop
This should get us started.
I will try to remember, but going forward most everything we will be doing should be done in a feature branch and then merged through the process.
Now we're going to add just empty projects. The idea is that we'll have a database project, a API project, and a web application project. We'll also add an empty set of tests, but we'll see how much testability we can find along the way. We'll also add a solution file. This makes it possible to link everything together, which is required for Visual Studio, but is also handy since you can use
dotnet build and it will build all of the projects at once.
I want the folder to look something like this:
RecordCatalog/ +-- API/ +-- Database/ +-- LICENSE +-- README.md +-- RecordCatalog.sln +-- Tests/ +-- WebApplication
At this point, it's worth noting that I am working in the .Net Core 3 preview. So if you're still using .Net Core 2.x or if you're reading this after .Net Core 3 is out of preview, some things may be different.
Let's start creating the empty applications. First, we'll create a feature branch.
git hf feature start addemptyprojects
Which should have an output similar to this:
Fetching origin Switched to a new branch 'feature/addemptyprojects' Total 0 (delta 0), reused 0 (delta 0) remote: remote: Create a pull request for 'feature/addemptyprojects' on GitHub by visiting: remote: https://github.com/IanKnighton/RecordCatalog/pull/new/feature/addemptyprojects remote: To github.com:IanKnighton/RecordCatalog.git * [new branch] feature/addemptyprojects -> feature/addemptyprojects Summary of actions: - A new branch 'feature/addemptyprojects' was created, based on 'develop' - The branch 'feature/addemptyprojects' has been pushed up to 'origin/feature/addemptyprojects' - You are now on branch 'feature/addemptyprojects' Now, start committing on your feature. When done, create a pull request on GitHub. Once that has been merged, use: git hf feature finish addemptyprojects
In order to use DbUp, we'll need to create a console application.
dotnet new console --name Database
For the API, we'll use the built in project configuration for a web API.
dotnet new webapi --name WebAPI
The web application we'll start with a completely empty web application. We'll eventually add MVC structure, but the MVC project has a bunch of stuff pre-rolled into it that I don't want.
dotnet new web --name WebApplication
Now we'll add an
XUnit test project.
dotnet new xunit --name Tests
Finally, we'll tie everything into a solution file.
dotnet new sln
This will create a file called
RecordCatalog.sln in your root directory.
To link your other files to the solution, you'll use
dotnet sln add with a link to the
dotnet sln add Database/Database.csproj dotnet sln add Tests/Tests.csproj dotnet sln add WebAPI/WebAPI.csproj dotnet sln add WebApplication/WebApplication.csproj
From the root folder, we should now be able to build everything with
dotnet build and have a similar output.
Microsoft (R) Build Engine version 16.0.443+g5775d0d6bb for .NET Core Copyright (C) Microsoft Corporation. All rights reserved. Persisting no-op dg to /Users/ianknighton/Documents/GitHub/RecordCatalog/Database/obj/Database.csproj.nuget.dgspec.json Persisting no-op dg to /Users/ianknighton/Documents/GitHub/RecordCatalog/WebApplication/obj/WebApplication.csproj.nuget.dgspec.json Persisting no-op dg to /Users/ianknighton/Documents/GitHub/RecordCatalog/WebAPI/obj/WebAPI.csproj.nuget.dgspec.json Persisting no-op dg to /Users/ianknighton/Documents/GitHub/RecordCatalog/Tests/obj/Tests.csproj.nuget.dgspec.json Restore completed in 29.54 ms for /Users/ianknighton/Documents/GitHub/RecordCatalog/WebApplication/WebApplication.csproj. Restore completed in 29.55 ms for /Users/ianknighton/Documents/GitHub/RecordCatalog/Database/Database.csproj. Restore completed in 30.67 ms for /Users/ianknighton/Documents/GitHub/RecordCatalog/Tests/Tests.csproj. Restore completed in 29.55 ms for /Users/ianknighton/Documents/GitHub/RecordCatalog/WebAPI/WebAPI.csproj. /usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [/Users/ianknighton/Documents/GitHub/RecordCatalog/WebApplication/WebApplication.csproj] /usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [/Users/ianknighton/Documents/GitHub/RecordCatalog/Tests/Tests.csproj] /usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [/Users/ianknighton/Documents/GitHub/RecordCatalog/WebAPI/WebAPI.csproj] /usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [/Users/ianknighton/Documents/GitHub/RecordCatalog/Database/Database.csproj] Database -> /Users/ianknighton/Documents/GitHub/RecordCatalog/Database/bin/Debug/netcoreapp3.0/Database.dll WebApplication -> /Users/ianknighton/Documents/GitHub/RecordCatalog/WebApplication/bin/Debug/netcoreapp3.0/WebApplication.dll WebAPI -> /Users/ianknighton/Documents/GitHub/RecordCatalog/WebAPI/bin/Debug/netcoreapp3.0/WebAPI.dll Tests -> /Users/ianknighton/Documents/GitHub/RecordCatalog/Tests/bin/Debug/netcoreapp3.0/Tests.dll Build succeeded. 0 Warning(s) 0 Error(s) Time Elapsed 00:00:02.82
At this point, we should have everything we need for the foundation built out. Let's commit the changes and push them up to GitHub.
git add . git commit -a -m "Added Empty Projects" git hf push
This puts everything into GitHub, now we'll need to go to the GitHub repo and make a pull request to merge it into the
Once you've completed the merge, close the feature branch.
git hf feature finish addemptyprojects
As of right now, we have a lot of things but a lot of nothing. In the next post, we'll start working on building out the database a bit. At least enough that we can start putting things together.
See you next week!