Skip to content

Unable to test using older target frameworks following setup #136

Closed

Description

@JimBobSquarePants

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

Activity

  1. changed the title [-]Unable to test using target older frameworks following setup[/-] [+]Unable to test using older target frameworks following setup[/+] on Oct 15, 2020
  2. pensono commented on Nov 25, 2020

    @pensono

    I have also encountered this.

    • Installed .NET 5.0 SDK
    • Project and tests target netcoreapp3.1

    Error:

    The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.
      - The following frameworks were found:
          5.0.0 at [/home/runner/.dotnet/shared/Microsoft.NETCore.App]
    
  3. vsafonkin commented on Feb 10, 2021

    @vsafonkin

    Hi @JimBobSquarePants , is this issue still actual for you?

  4. JimBobSquarePants commented on Feb 10, 2021

    @JimBobSquarePants
    Author
  5. vsafonkin commented on Feb 10, 2021

    @vsafonkin

    The thing is the setup task installs dotnet to user' directory and add this directory to PATH, so all pre-installed dotnet versions stop working. You should use setup task twice to install both needed dotnet versions.

  6. JimBobSquarePants commented on Feb 10, 2021

    @JimBobSquarePants
    Author

    You can’t do that if multi targeting. If you install the lower target then your higher target won’t build. This used to all work then it didn’t, hence the issue.

  7. vsafonkin commented on Feb 11, 2021

    @vsafonkin

    Why not? I mean, you should install all required versions explicitly:
    https://github.com/vsafonkin/SetupDotNetActionFailRepro/actions/runs/557050694

  8. JimBobSquarePants commented on Feb 12, 2021

    @JimBobSquarePants
    Author

    I could have sworn with previous versions running multiple installs simply overwrote the path to the previous and continued to break things!

    Anyway... If that works now that's fine by me. It's a shame that we have to do this now though since the syntax is clunky and it massively slows down build times.

  9. vsafonkin commented on Feb 12, 2021

    @vsafonkin

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

  10. JimBobSquarePants commented on Feb 12, 2021

    @JimBobSquarePants
    Author

    I'll close this for now then since there's a valid workaround. Thanks for your help!

  11. visschersm commented on Aug 24, 2021

    @visschersm

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions