It can feel like a lot to get started with GitHub Actions or Azure Pipelines – it’s a whole new skillset. Because the alternatives for deployment are so easy (right-click publish for example), teams sometimes question whether implementing a pipeline is worth the effort. It might be agreed that CI/CD is a “good thing”, but is it the most important thing right now?
Even as a “seasoned builder-of-pipelines”, I often spend a lot of time with a failing build before it finally “goes green” and I can move on!
Making it easy in Visual Studio
When I joined the Cloud Advocacy team at Microsoft as a DevOps specialist, one of my advocacy teammates was Tim Heuer. We had some… robust… discussions about how important a full end-to-end DevOps pipeline was. I’ve always been on the side of building a full pipeline from day 1, but especially for small projects, he was less convinced. Right-click publish worked fine for him! The learning curve was too steep for what seemed a small benefit.
Fast-forward to today, and Tim is on the .NET team at Microsoft. One big focus of his is flattening that learning curve. His team (as well as many other teams at Microsoft) have been working hard to make it as simple as possible for .NET developer to build CI/CD pipelines. They want people to be successful in a way that gives them all the benefits of DevOps!
Back in September 2020, the Visual Studio team announced a new feature for ASP.NET Core projects. Essentially, it allowed Visual Studio users to right-click-publish, but rather than just pushing to prod, they’d be able to generate a GitHub Actions workflow!
But .NET is a true cross-platform framework now, and not everyone has (or needs) Visual Studio installed. Personally, I haven’t had Visual Studio installed on my primary machine for over a year! So while this is a great feature, it’s not one I use, and it doesn’t work for an increasing number of .NET developers.
dotnet new workflow
I recently came across a tweet from Tim where he submitted a pull request to a project to add a CI pipeline (definitely not the Tim I first met!) For people familiar with GitHub Actions, it was a fairly straightforward addition, but if not, that learning curve is steep! More impressive than the PR is the fact Tim’s starting point was a generated workflow using the dotnet
CLI and a template he wrote!
How do I use it?
The template is fairly simple – it just creates a GitHub Actions workflow file in the correct location (assuming you run it in the root of your repository) that will build and test your .NET project. While it doesn’t do a lot on the surface, it’s perfect to get you over that steep learning curve!
Tim blogged about it in more detail, but here are the basics:
To use it, navigate to the root of your repo and type dotnet new workflow
in your console of choice.
If you don’t have the template installed already, you get clear instructions on how to install it. It’s a single command – dotnet new -i TimHeuer.GitHubActions.Templates::1.0.4
– but the version may be different. Run that command and then dotnet new workflow
again.
What you’ll get is a straightforward GitHub Actions workflow to build and test your .NET application. Keep in mind this is a starting point. It’s not going to do everything you might want, but it’s a solid base to build from.
At time of writing there are two additional arguments you can specify: – -sdk
or --sdk-version
lets you choose the .NET SDK – -b
or --branch
lets you choose the branch that will trigger your workflow
More for .NET devs
These are just two of the blog posts Tim has written lately on using GitHub Actions for .NET. Check them out on his blog!
0 comments