question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to test using older target frameworks following setup

See original GitHub issue

Description

Running dotnet test following setup does not allow testing against specific older frameworks. This used to be possible.

Details

Given the following workflow.

name: .NET Core

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    strategy:
        matrix:
            options:
                - os: windows-latest
                  framework: netcoreapp3.1
                - os: windows-latest
                  framework: netcoreapp2.1

    runs-on: ${{matrix.options.os}}

    steps:
    - uses: actions/checkout@v2

    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 3.1.x

    - name: Install dependencies
      run: dotnet restore

    - name: Build
      run: dotnet build --configuration Release --no-restore -f ${{matrix.options.framework}}

    - name: Test
      run: dotnet test --no-restore --verbosity normal -f ${{matrix.options.framework}}

It used to be possible to specify an older target framework. For example :

dotnet test --no-restore --verbosity normal -f netcoreapp2.1

Now the following exception is returned instead.

Testhost process exited with error: It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.1.0' was not found.
  - The following frameworks were found:
      3.1.9 at [C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\shared\Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.1.0&arch=x64&rid=win10-x64
. Please check the diagnostic logs for more information.

Build works fine and removing this action allows the test command to run as expected.

I’ve created a repository that demonstrates the issue. https://github.com/JimBobSquarePants/SetupDotNetActionFailRepro

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

2reactions
vsafonkincommented, Feb 12, 2021

Most likely a second version of setup task which will be released which will install required dotnet to the directory with pre-installed versions.

1reaction
visschersmcommented, Aug 24, 2021

I just want to say thanks for this solution. Been trying to get my tests back work the entire day and this seems to be the solution.

Still think it is a bit strange that you can build/run/test from the CLI using the latest available SDK to build/test every version below. But it does not work the same way within the github action.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting .NET Framework Targeting Errors - MSBuild
NET Framework applications, open Solution Explorer, choose Show All Files, and then edit the app.config file in the XML editor of Visual Studio....
Read more >
After updated Visual Studio 2019 to 16.4.0 I can't run tests with ...
Visual Studio was configured to run AnyCPU tests as x86, but only the x64 SDK was installed. set VS to use x64 for...
Read more >
.NET Framework 4.7 not listed as a target framework when ...
F.e. if you created a 'Class Library (. NET Core)' Target Framework '. NET Framework 4.7' will not appear on the list although...
Read more >
unittest — Unit testing framework — Python 3.11.1 ...
The setUp() and tearDown() methods allow you to define instructions that will be executed before and after each test method. They are covered...
Read more >
Building Applications for Different .NET Framework Versions
If it is not installed on the target computer, the application will fail to run and prompt the user to install .NET framework...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found