How can I setup .NET Framework 4.6.1 for MSBuild on GitHub Actions?

614 views Asked by At

When I use the latest setup-dotnet, I get an error:

MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download the .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

I tried both setup-dotnet but it says version 4.6.1 has been deprecated.

2

There are 2 answers

0
szymmirr On

.NET Framework 4.6.1 support is removed in windows-latest, which you're most likely using. You can either:

  • Bump your dotnet Framework version to 4.6.2 (which is supported)
  • Switch to windows-2019 in your .yml file: runs-on: windows-2019
0
Naylor On

The windows-2022 runner does not include the targeting pack for 4.6.1 (since it is out of support). If using a windows-2019 runner is unacceptable you can download and install the targeting pack into the runner.

At the time of writing this works:

    - name: Download 461 targeting pack
      uses: suisei-cn/actions-download-file@818d6b7dc8fe73f2f924b6241f2b1134ca1377d9 # 1.6.0
      id: downloadfile  # Remember to give an ID if you need the output filename
      with:
          url: "https://download.microsoft.com/download/F/1/D/F1DEB8DB-D277-4EF9-9F48-3A65D4D8F965/NDP461-DevPack-KB3105179-ENU.exe"
          target: public/

    - name: Install targeting pack
      shell: cmd
      working-directory: public
      run: NDP461-DevPack-KB3105179-ENU.exe /q