Skip to content

Commit 1ef6df5

Browse files
committed
Install dotnet SDK acrh x64 for MacOS
1 parent 1a77fa6 commit 1ef6df5

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ jobs:
2626
with:
2727
fetch-depth: 0
2828

29+
- name: Install .NET Core SDK [ Version - ${{ matrix.dotnet-version }} ] (MacOS)
30+
if: ${{ runner.os == 'macOS' }}
31+
uses: ./.github/workflows/install-dotnet-core
32+
with:
33+
dotnet-version: ${{ matrix.dotnet-version }}
34+
architecture: x64
35+
2936
- name: Dotnet Version (${{ matrix.dotnet-version }})
37+
if: ${{ runner.os != 'macOS' }}
3038
uses: actions/setup-dotnet@v4
3139
with:
3240
dotnet-version: ${{ matrix.dotnet-version }}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Install .NET Core SDK
2+
description: Installs a specified .NET Core SDK version
3+
4+
inputs:
5+
dotnet-version:
6+
description: The version of .NET SDK to install (e.g., 3.1.426)
7+
required: true
8+
architecture:
9+
description: Target architecture (e.g., x64 or arm64)
10+
required: true
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Resolve .NET Core SDK Version
16+
shell: bash
17+
env:
18+
RAW_INPUT: ${{ inputs.dotnet-version }}
19+
run: |
20+
DOTNET_CHANNEL="${RAW_INPUT%%.x}"
21+
22+
RELEASE_INDEX_URL="https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json"
23+
24+
# Get the URL to the channel-specific releases.json
25+
RELEASES_JSON_URL=$(curl -s $RELEASE_INDEX_URL \
26+
| jq -r --arg ver "$DOTNET_CHANNEL" '
27+
.["releases-index"][]
28+
| select(.["channel-version"] == $ver)
29+
| ."releases.json"')
30+
31+
if [ -z "$RELEASES_JSON_URL" ]; then
32+
echo "Could not resolve releases.json URL for channel $DOTNET_CHANNEL"
33+
exit 1
34+
fi
35+
36+
# Download and extract latest SDK version
37+
DOTNET_VERSION=$(curl -s $RELEASES_JSON_URL \
38+
| jq -r '
39+
.releases[]
40+
| select(.sdk.version != null)
41+
| .sdk.version' \
42+
| sort -Vr \
43+
| head -n1)
44+
45+
if [ -z "$DOTNET_VERSION" ]; then
46+
echo "Could not resolve SDK version from $RELEASES_JSON_URL"
47+
exit 1
48+
fi
49+
50+
echo "Resolved full SDK version: $DOTNET_VERSION"
51+
echo "DOTNET_VERSION=$DOTNET_VERSION" >> $GITHUB_ENV
52+
53+
- name: Install .NET Core SDK [ ${{ inputs.dotnet-version }} ]
54+
shell: bash
55+
run: |
56+
ARCHITECTURE="${{ inputs.architecture }}"
57+
INSTALL_DIR=$HOME/dotnet
58+
59+
echo "Installing .NET SDK $DOTNET_VERSION for $ARCHITECTURE..."
60+
mkdir -p "$INSTALL_DIR"
61+
curl -sSL https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh -o dotnet-install.sh
62+
chmod +x dotnet-install.sh
63+
./dotnet-install.sh --version "$DOTNET_VERSION" --install-dir "$INSTALL_DIR" --architecture "$ARCHITECTURE"
64+
65+
- name: Add dotnet to PATH
66+
shell: bash
67+
run: echo "$HOME/dotnet" >> $GITHUB_PATH
68+
69+
- name: Check .NET SDK
70+
shell: bash
71+
run: |
72+
dotnet --info

0 commit comments

Comments
 (0)