Forum Discussion
How can I add .NET Framework 4.7.2 to a build_check.yml that accounts only for the .NET Core
Hi MikhailPodolski,
The error you're encountering indicates that the reference assemblies for .NET Framework 4.7.2 are missing in the GitHub Actions environment. This is because your workflow configuration is currently set up to use only .NET Core.
To resolve this issue and build your projects targeting both .NET Core and .NET Framework, you'll need to make a few adjustments to your workflow file. Here's how you can modify your build_check.yml:
name: Build check
on:
pull_request:
jobs:
test:
name: Build check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Restore packages for solution
run: dotnet restore
- name: Build solution (NET Core)
run: dotnet build --no-restore -c debug
- name: Setup .NET Framework
uses: actions/setup-dotnet@v2
with:
dotnet-version: 4.7.2
- name: Build solution (NET Framework)
run: msbuild YourSolution.sln /p:Configuration=Debug
# Uncomment these lines if you want to run tests
# - name: Run tests (NET Core)
# run: dotnet test --no-build -c debug
# - name: Run tests (NET Framework)
# run: vstest.console.exe YourTestProject.dllIn this modified configuration, I've added two sections to the workflow: one for building with .NET Core and another for building with .NET Framework 4.7.2. Make sure to replace YourSolution.sln and YourTestProject.dll with the actual names of your solution and test project files.
You might need to make sure the required SDKs for .NET Core and .NET Framework are available in your workflow. You can refer to the documentation for setup-dotnet to learn more about specifying custom SDK versions or installing missing ones: https://github.com/actions/setup-dotnet.