How can I add .NET Framework 4.7.2 to a build_check.yml that accounts only for the .NET Core

Mikhail 41 Reputation points
2023-07-08T01:26:20.6066667+00:00
I have a .NET solution that have several projects, built in .NET Core and in the .NET 4.7.2. All those projects are built and run fine on my local environment.

However, when I push this solution to a GitHub, the build in the GitHub fails

error MSB3644: The reference assemblies for .NETFramework,Version=v4.7.2 were not found.

I examined the build_check.yml uploaded to GitHub, and noticed that this file is missing a reference to a .NET Framework 4.7.2.

I am posting the contents of the build_check.yml below. What is the right syntax to add .NET Framework 4.7.2 to it?

name: Build check

on:
  pull_request:

jobs:
  test:
    name: Build check
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: |
          6.0.x
          7.0.x
    - name: Restore packages for solution
      run: dotnet restore
    - name: Build solution
      run: dotnet build --no-restore -c debug
#    - name: Run tests
#      run: dotnet test --no-build -c debug
Developer technologies .NET .NET Runtime
Developer technologies .NET Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-07-08T18:52:39.67+00:00

    As the default GitHub build environment is Linux, You can not build a 4.* app or library only .net core apps and libraries.

    if you can convert your 4.7 libraries to .netstandard you could build them, but the libraries coukd not reference any 4.* libraries.

    your other option is to use a window runner build machine:

    https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.