Skip to content

Commit e1d3544

Browse files
authored
Merge pull request actions#359 from akv-platform/documentation-clarification
Update README.md to clarify installation process
2 parents 09d024b + 13abe47 commit e1d3544

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

Diff for: README.md

+34-11
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ This action sets up a [.NET CLI](https://github.com/dotnet/sdk) environment for
1010

1111
> **Note**: GitHub hosted runners have some versions of the .NET SDK
1212
preinstalled. Installed versions are subject to change. Please refer to the
13-
documentation
14-
[software installed on github hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software)
13+
documentation:
14+
[Software installed on github hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software)
1515
for .NET SDK versions that are currently available.
1616

1717
## Usage
@@ -27,6 +27,7 @@ steps:
2727
dotnet-version: '3.1.x'
2828
- run: dotnet build <my project>
2929
```
30+
> **Warning**: 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)_**. Please refer to the [documentation](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software) for the currently preinstalled .NET SDK versions.
3031

3132
**Multiple version installation**:
3233
```yml
@@ -40,8 +41,6 @@ steps:
4041
5.0.x
4142
- run: dotnet build <my project>
4243
```
43-
> **Note**: In case multiple versions are installed, the latest .NET version will be used by default unless another version is specified in the `global.json` file.
44-
4544
## Supported version syntax
4645

4746
The `dotnet-version` input supports following syntax:
@@ -97,7 +96,31 @@ jobs:
9796
uses: actions/setup-dotnet@v3
9897
with:
9998
dotnet-version: ${{ matrix.dotnet }}
100-
- run: dotnet build <my project>
99+
- name: Execute dotnet
100+
run: dotnet build <my project>
101+
```
102+
>**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:
103+
104+
**Matrix testing with temporary global.json creation**
105+
```yml
106+
jobs:
107+
build:
108+
runs-on: ubuntu-latest
109+
strategy:
110+
matrix:
111+
dotnet: [ '2.1.x', '3.1.x', '5.0.x' ]
112+
name: Dotnet ${{ matrix.dotnet }} sample
113+
steps:
114+
- uses: actions/checkout@v3
115+
- name: Setup dotnet
116+
uses: actions/setup-dotnet@v3
117+
id: stepid
118+
with:
119+
dotnet-version: ${{ matrix.dotnet }}
120+
- name: Create temporary global.json
121+
run: echo '{"sdk":{"version": "${{ steps.stepid.outputs.dotnet-version }}"}}' > ./global.json
122+
- name: Execute dotnet
123+
run: dotnet build <my project>
101124
```
102125
## Setting up authentication for nuget feeds
103126

@@ -155,10 +178,10 @@ In case of a single version installation, the `dotnet-version` output contains t
155178

156179
```yaml
157180
- uses: actions/setup-dotnet@v3
158-
id: cp310
181+
id: stepid
159182
with:
160183
dotnet-version: 3.1.422
161-
- run: echo '${{ steps.cp310.outputs.dotnet-version }}' # outputs 3.1.422
184+
- run: echo '${{ steps.stepid.outputs.dotnet-version }}' # outputs 3.1.422
162185
```
163186

164187
**Multiple version installation**
@@ -167,26 +190,26 @@ In case of a multiple version installation, the `dotnet-version` output contains
167190

168191
```yaml
169192
- uses: actions/setup-dotnet@v3
170-
id: cp310
193+
id: stepid
171194
with:
172195
dotnet-version: |
173196
3.1.422
174197
5.0.408
175-
- run: echo '${{ steps.cp310.outputs.dotnet-version }}' # outputs 5.0.408
198+
- run: echo '${{ steps.stepid.outputs.dotnet-version }}' # outputs 5.0.408
176199
```
177200
**Installation from global.json**
178201

179202
When the `dotnet-version` input is used along with the `global-json-file` input, the `dotnet-version` output contains the version resolved from the `global.json`.
180203

181204
```yaml
182205
- uses: actions/setup-dotnet@v3
183-
id: cp310
206+
id: stepid
184207
with:
185208
dotnet-version: |
186209
3.1.422
187210
5.0.408
188211
global-json-file: "./global.json" # contains version 2.2.207
189-
- run: echo '${{ steps.cp310.outputs.dotnet-version }}' # outputs 2.2.207
212+
- run: echo '${{ steps.stepid.outputs.dotnet-version }}' # outputs 2.2.207
190213
```
191214

192215
## Environment variables

0 commit comments

Comments
 (0)