From 014f8c8384136623001722cc5e268588ab60d42c Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Tue, 20 Dec 2022 12:30:05 +0100 Subject: [PATCH] Add part about temporary global.json files --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 46a0319..8d20db0 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,31 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: ${{ matrix.dotnet }} - - run: dotnet build + - name: Execute dotnet + run: dotnet build +``` +>**Note**: Unless a concrete version is specified in the [`global.json`](https://learn.microsoft.com/en-us/dotnet/core/tools/global-json) file, the latest .NET version installed on the runner (including preinstalled versions) will be used [by default](https://learn.microsoft.com/en-us/dotnet/core/versions/selection#the-sdk-uses-the-latest-installed-version). To control this behavior you may want to use temporary `global.json` files: + +**Matrix testing with temporary global.json creation** +```yml +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + dotnet: [ '2.1.x', '3.1.x', '5.0.x' ] + name: Dotnet ${{ matrix.dotnet }} sample + steps: + - uses: actions/checkout@v3 + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + id: cp310 + with: + dotnet-version: ${{ matrix.dotnet }} + - name: Create temporary global.json + run: echo '{"sdk":{"version": "${{ steps.cp310.outputs.dotnet-version }}"}}' > ./global.json + - name: Execute dotnet + run: dotnet build ``` ## Setting up authentication for nuget feeds