Skip to content

Commit 014f8c8

Browse files
author
IvanZosimov
committed
Add part about temporary global.json files
1 parent 80c862d commit 014f8c8

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

Diff for: README.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,31 @@ jobs:
9797
uses: actions/setup-dotnet@v3
9898
with:
9999
dotnet-version: ${{ matrix.dotnet }}
100-
- run: dotnet build <my project>
100+
- name: Execute dotnet
101+
run: dotnet build <my project>
102+
```
103+
>**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:
104+
105+
**Matrix testing with temporary global.json creation**
106+
```yml
107+
jobs:
108+
build:
109+
runs-on: ubuntu-latest
110+
strategy:
111+
matrix:
112+
dotnet: [ '2.1.x', '3.1.x', '5.0.x' ]
113+
name: Dotnet ${{ matrix.dotnet }} sample
114+
steps:
115+
- uses: actions/checkout@v3
116+
- name: Setup dotnet
117+
uses: actions/setup-dotnet@v3
118+
id: cp310
119+
with:
120+
dotnet-version: ${{ matrix.dotnet }}
121+
- name: Create temporary global.json
122+
run: echo '{"sdk":{"version": "${{ steps.cp310.outputs.dotnet-version }}"}}' > ./global.json
123+
- name: Execute dotnet
124+
run: dotnet build <my project>
101125
```
102126
## Setting up authentication for nuget feeds
103127

0 commit comments

Comments
 (0)