Getting a complete CI/CD pipeline for your .NET Aspire solution doesn't have to be complicated. I've created a template that gives you everything you need to get started in minutes.
Watch the Video
Part 1: The Ready-to-Use Template
I've built a .NET Aspire template that comes with everything configured and ready to go. Here's what you get:
What's Included
- A classic .NET Aspire Starter project (API and frontend)
- Unit tests using xUnit (easily adaptable to other testing frameworks)
- Complete
.gitlab-ci.yml
pipeline configuration - Security scanning and secret detection
- All documentation you need
What the Pipeline Does
The pipeline runs two main jobs automatically:
- Build: Compiles your code
- Test: Runs all unit tests, scans for vulnerabilities, and checks for accidentally committed secrets (API keys, passwords, etc.)
You can see all test results directly in GitLab's interface, making it easy to track your project's health.
How to Get Started
It's simple:
- Clone the template repository: cloud5mins/aspire-template
- Replace the sample project with your own .NET Aspire code
- Push to your GitLab repository
- Watch your CI/CD pipeline run automatically
That's it! You immediately get automated builds, testing, and security scanning.
Pro Tip: The best time to set up CI/CD is when you're just starting your project because everything is still simple.
Part 2: Building the Template with GitLab Duo
Now let me share my experience creating this template using GitLab's AI assistant, GitLab Duo.
Starting Simple, Growing Smart
I didn't build this complex pipeline all at once. I started with something very basic and used GitLab Duo to gradually add features. The AI helped me:
- Add secret detection when I asked: "How can I scan for accidentally committed secrets?"
- Fix test execution issues when my unit tests weren't running properly
- Optimize the pipeline structure for better performance
Working with GitLab in VS Code
While you can edit .gitlab-ci.yml
files directly in GitLab's web interface, I prefer VS Code. Here's my setup:
- Install the official GitLab extension from the VS Code marketplace
Once you've signed in, this extension gives you:
- Direct access to GitLab issues and work items
- AI-powered chat with GitLab Duo
GitLab Duo in Action
GitLab Duo became my pair programming partner. Here's how I used it:
Understanding Code: I could type /explain
and ask Duo to explain what any part of my pipeline configuration does by highlighting that section.
Solving Problems: When my solution didn't compile, I described the issue to Duo and got specific suggestions. For example, it helped me realize some projects weren't in .NET 9 because dotnet build
required the Aspire workload. I could either keep my project in .NET 8 and add a before_script
instruction to install the workload or upgrade to .NET 9; I picked the latest.
Adding Features: I started with just build and test, then incrementally asked Duo to help me add security scanning, secret detection, and better error handling.
Adding Context: Using /include
to add the project file or the .gitlab-ci.yml
file while asking questions helped Duo understand the context better.
Learn More with the Docs: During my journey, I knew Duo wasn't just making things up as it was referencing the documentation. I could continue my learning there and read more examples of how before_script
is used in different contexts.
The AI-Assisted Development Experience
What impressed me most was how GitLab Duo helped me learn while building. Instead of just copying configurations from documentation, each conversation taught me something new about GitLab CI/CD best practices.
Conclusion
I think this template can be useful for anyone starting a .NET Aspire project. Ready to try it? Clone the template at cloud5mins/aspire-template and start building with confidence.
Whether you're new to .NET Aspire or CI/CD, this template gives you a good foundation. And if you want to customize it further, GitLab Duo is there to help you understand and modify the configuration.
If you think we should add more features or improve the template, feel free to open an issue in the repository. Your feedback is always welcome!
Thanks to David Fowler for his feedback!