I’ve recently been playing with GitHub actions. Having been around the block a few times, I’ve seen a fair few methods of building and deploying software, and of those, a fair few that are automated in some way. Oddly, debugging these things seems to be in the same place it was around 10 years ago: you see an error, try to work out what caused it, fix it, and run the build / deploy, rinse and repeat.
In some respects, this process may have actually become harder to debug since the days of TFS (at least with TFS, you could connect to the server and see why the software wasn’t building).
Anyway, onto GitHub actions
I’ve been trying to set-up an automated CI/CD pipeline for a new utility that I’ve been playing with.
After I’d configured a basic build, I started getting the following error:
MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
So, I thought future me (and perhaps one or two other people) may like to see the process that I went through to resolve (or at least to diagnose) this.
1. Git Bash
Your build is very likely trying to run on a Linux platform. If you have a look at your build file, it will tell you (or, more accurately, you will tell it) where it’s building:
So, the first step is to load up bash and manually type in the commands that the build is executing, one at a time. Again, these are all in the build file:
Make sure that you do this from the root directory, in case your problem relates to the path.
2. Add Debug Steps
Assuming that you’ve done step one and everything is working, the next stage is to start adding some logging. I strongly suspect that someone reading this will tell me there’s an easier way to go about this (please tell me there’s an easier way to go about this!) but this is how I went about adding tracing:
steps: - uses: actions/checkout@v2 - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: dotnet-version: 3.1.101 - name: where are we run: pwd - name: list some key files run: ls -lrt - name: try a different die run: ls -lrt websitemeta - name: Install dependencies run: dotnet restore ./websitemeta/
As you can see, I was working under the assumption that my build was failing because the directory paths were incorrect. In fact, the paths were fine:
With the logging stage, there’s two ways to look at this 1. You’re closely following the scientific method of establishing a hypothesis and testing it; or 2. You’re blindly logging as much information as you can to try and extract a clue.
You’d be surprised how quickly 1 turns into 2!
3. Remember the platform that you’re running on
Okay, so in Step 1, I stated that you should try running the build in bash; but remember that, despite the Unix like interface, you’re still on Windows. As you can see from my build file, my build is on Ubuntu. In my particular case, this held the key - in fact, my build was failing because I’d used the wrong case for the directory path.
This is also true for your tests; for example, if you’ve hard-coded a directory path like this in your test:
string path = "tmp\\myfile.txt";
It will fail, because in Unix, it would be:
string path = "tmp/myfile.txt";