✅ YES, we can! And I will show you how I did it.
I recently had to deal with a legacy code base of a .Net Full Framework project.
The source code was versioned on GitHub and there was a pull request and code review flow for integrating source code into the main branch. However, there were no checks to verify the code that was being integrated, which would allow source code that did not compile, or that broke unit tests, to be included in our main branch without any alerts.
The absence of quick feedback on the health of the integrated source code created some sense of insecurity in the developers during the approval of the pull requests, since problems inserted through the addition of new code could take much longer than desired to be identified.
In order to improve our workflow, I thought about creating a CI workflow with GitHub Actions to speed up the flow of feedback during our source code integrations.
When checking the documentation of GitHub Actions, I realized that there was no template for creating a workflow for .Net Full Framework projects. And then I asked the same question at the beginning of this text:
Can we create GitHub Actions to Build and Test .Net Full Framework projects?
Throughout my research journey, I discovered some resources, both official and from the community:
The use of the above actions allowed me to create the CI pipeline for my .Net Full Framework project. I configured the CI pipeline to be triggered by each new
pull request in the main branch, as shown in the
ci.yml file below:
Below, step-by-step explanation of the
Define the name of the GitHub Action.
name: Build and Tests
Set that the actions should be triggered by
pushand creation of
pull requestsfor the branch
main(default branch of this project).
on: push: branches: [ main ] pull_request: branches: [ main ]
The build and test will be performed on a Windows operating system, because we are dealing with .Net Full Framework (which does not support other operating systems).
jobs: build: runs-on: windows-latest
Define the section that will group all the steps performed, detailed in the next items.
Checkout the code.
- uses: actions/checkout@v2
MSBuild setup, for later use.
- name: Setup MSBuild uses: microsoft/setup-msbuild@v1
Nuget setup, for later use.
- name: Setup NuGet uses: NuGetemail@example.com
VSTest setup, for later use.
- name: Setup VSTest uses: darenm/Setup-VSTest@v1
Navigate to the GitHub workspace to start the restore, build and test of the application.
- name: Navigate to Workspace run: cd $GITHUB_WORKSPACE
nugetto restore packages used by the application.
- name: Restore Packages run: nuget restore Sandbox.sln
Build the solution with
msbuild.exe, release mode.
- name: Build Solution run: | msbuild.exe Sandbox.sln /p:platform="Any CPU" /p:configuration="Release"
Run the tests of the
- name: Run Tests run: vstest.console.exe .\tests\Sandbox.Tests\bin\Release\Sandbox.Tests.dll
After we implanted our CI pipeline, just open a
pull request too see the result of our implementation.
When analyzing the checks tab, we can verify the execution step-by-step.
If there was any failure, on this page it would be possible to check which step was broken and analyze the logs to identify the error.
Are you curious about the project? This is the repository where all the source code is available:
GitHub Actions for .Net Full Framework: Build & Test
This repository aims to show how to create GitHub Actions to Build and Test a .Net Full Framework Web API project.
Dealing with legacy code can be very complicated, so proposing workflow improvements can help us dramatically change the reality of the project, by encouraging quick feedback and mitigating points of insecurity that harm the development team.
GitHub Actions are very useful tools for automating CI processes. Although it does not contain an initial template in the official documentation, it is possible to create workflows with GitHub Actions for .Net Full Framework, thanks to the official actions and also those created and made available by the community.
I had some work to get my CI pipeline viable, if you have any problems in the implementation of yours and want to share in the comments of this post, I will be happy to help you.
Bye! 😉 😘
⚠️ It is worth remembering that, before using the workflow, it is important to check if it and its dependencies are in accordance with the project policies where you want to apply them. ⚠️