actions / setup-dotnet

Set up your GitHub Actions workflow with a specific version of the .NET core sdk
MIT License
919 stars 452 forks source link

Install runs twice after update from v3 to v4 #491

Closed bkoelman closed 6 months ago

bkoelman commented 7 months ago

Description:

After update from v3 to v4, it looks like the install runs twice.

Github Actions step:

    - name: Setup .NET
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: |
          6.0.x
          8.0.x

Original output:

Run actions/setup-dotnet@v[3](https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb/actions/runs/7041019307/job/19162902448#step:2:3)
  with:
    dotnet-version: 6.0.x
  8.0.x

    cache: false
  env:
    DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
    DOTNET_CLI_TELEMETRY_OPTOUT: true
/home/runner/work/_actions/actions/setup-dotnet/v3/externals/install-dotnet.sh --channel 6.0
dotnet-install: .NET Core SDK with version '6.0.[4](https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb/actions/runs/7041019307/job/19162902448#step:2:4)1[7](https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb/actions/runs/7041019307/job/19162902448#step:2:7)' is already installed.
/home/runner/work/_actions/actions/setup-dotnet/v3/externals/install-dotnet.sh --channel [8](https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb/actions/runs/7041019307/job/19162902448#step:2:8).0
dotnet-install: .NET Core SDK with version '8.0.[10](https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb/actions/runs/7041019307/job/19162902448#step:2:11)0' is already installed.

New output:

Run actions/setup-dotnet@v[4](https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb/actions/runs/7089943142/job/19313357238?pr=38#step:2:4)
  with:
    dotnet-version: [6](https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb/actions/runs/7089943142/job/19313357238?pr=38#step:2:6).0.x
  8.0.x

    cache: false
  env:
    DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
    DOTNET_CLI_TELEMETRY_OPTOUT: true
/home/runner/work/_actions/actions/setup-dotnet/v4/externals/install-dotnet.sh --skip-non-versioned-files --runtime dotnet --channel LTS
dotnet-install: .NET Core Runtime with version '8.0.0' is already installed.
/home/runner/work/_actions/actions/setup-dotnet/v4/externals/install-dotnet.sh --skip-non-versioned-files --channel 6.0
dotnet-install: .NET Core SDK with version '6.0.41[7](https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb/actions/runs/7089943142/job/19313357238?pr=38#step:2:7)' is already installed.
/home/runner/work/_actions/actions/setup-dotnet/v4/externals/install-dotnet.sh --skip-non-versioned-files --runtime dotnet --channel LTS
dotnet-install: .NET Core Runtime with version '[8](https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb/actions/runs/7089943142/job/19313357238?pr=38#step:2:8).0.0' is already installed.
/home/runner/work/_actions/actions/setup-dotnet/v4/externals/install-dotnet.sh --skip-non-versioned-files --channel 8.0
dotnet-install: .NET Core SDK with version '8.0.[10](https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb/actions/runs/7089943142/job/19313357238?pr=38#step:2:11)0' is already installed.

Task version: v4.0.0

Platform:

Runner type:

Repro steps:
Example at https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb/actions/runs/7089943142/job/19313357238?pr=38.

Expected behavior: Installation occurs once per target framework.

Actual behavior: Installation occurs twice per target framework.

dusan-trickovic commented 7 months ago

Hello, @bkoelman! Thank you for reporting this issue, we will look into it and see what can be done :)

aparnajyothi-y commented 6 months ago

Thank you for creating the issue, @bkoelman! ​ This is the expected behavior for setup-dotnet@v4. Install script runs two times with different settings:

  1. Minimal installation of the latest runtime version in order to obtain latest stable version of the dotnet executable
  2. Installation of the required SDK ​ This approach was introduced in order to fix the issue #387.
    setup-dotnet@v3 used to overwrite dotnet executable on each action run, which was causing action to fail on some occasions due to executable being still in use. In setup-dotnet@v4 we solved this issue by adding another install-script run that installs LTS version of dotnet executable and uses it for all subsequent dotnet installations. (#433) The first install-script run conducts the actual download only once per workflow. ​ If you have any other concerns regarding install-script running twice, please feel free to share them!
bkoelman commented 6 months ago

Thanks for looking into this. The duplicate installation does not pose any problems, it just came as a surprise. Now I understand it's intentional and was done to fix a problem, so I'm fine with it. It would be worth mentioning this in the release notes though.

aparnajyothi-y commented 6 months ago

Added this expected behaviour to the release notes of v4.0.0 and closing this issue. Thank you.

bkoelman commented 6 months ago

Thanks

VAllens commented 5 months ago

However, even after I create the global.json file specifying that I want to use version 7.0, it still always installs the latest version(8.0), for me, before finally installing the version specified by the dotnet-version parameter(7.0) for me. This is unnecessary, it wastes a lot of my time, especially with a slow network, and it doesn't seem to cache the installer packages and the install directory for me.

zeeshanpolaris commented 3 months ago

However, even after I create the global.json file specifying that I want to use version 7.0, it still always installs the latest version(8.0), for me, before finally installing the version specified by the dotnet-version parameter(7.0) for me. This is unnecessary, it wastes a lot of my time, especially with a slow network, and it doesn't seem to cache the installer packages and the install directory for me.

I have noticed same