Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -590,3 +590,36 @@ jobs:
- name: Verify dotnet (higher version)
shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^${{ matrix.lower-version }}$", "^${{ matrix.higher-version }}$"

test-setup-with-workloads-input:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system:
[ubuntu-latest, windows-latest, macos-15-intel, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Clear toolcache
shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}

- name: Setup dotnet 9.0 with workloads
uses: ./
id: setup-dotnet
with:
dotnet-version: '9.0'
workloads: wasm-tools
- name: Verify workload
shell: pwsh
run: |
$output = dotnet workload list | Out-String
Write-Host "Workload list output:"
Write-Host $output
if ($output -notmatch "wasm-tools") {
throw "Expected workload 'wasm-tools' not found"
}
- name: Verify dotnet
shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^9\.0"
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,22 @@ steps:
```
> **Note**: It's the only way to push a package to nuget.org feed for macOS/Linux machines due to API key config store limitations.

## Using the `workloads` input
The `workloads` input allows you to install .NET workloads as part of the SDK setup. Workloads provide additional platform tools and dependencies for frameworks. This action automatically runs `dotnet workload update` before installing the specified workloads to ensure manifests are refreshed and existing workloads are updated to their latest compatible versions.

```yaml
steps:
- uses: actions/checkout@v5
- name: Setup .NET with workloads
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x'
workloads: workload1, workload2 # Specify the workloads required for the project, such as wasm-tools, maui, etc.
- run: dotnet build <my project>
```

> **Note**: Ensure workloads are compatible with your runner's OS, architecture, and .NET SDK version before enabling workload installation. Some workloads may require additional installation time due to large toolchain downloads.

# Outputs and environment variables

## Outputs
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ inputs:
cache-dependency-path:
description: 'Used to specify the path to a dependency file: packages.lock.json. Supports wildcards or a list of file names for caching multiple dependencies.'
required: false
workloads:
description: 'Optional SDK workloads to install for additional platform support. Examples: wasm-tools, maui, aspire.'
required: false
outputs:
cache-hit:
description: 'A boolean value to indicate if a cache was hit.'
Expand Down
19 changes: 19 additions & 0 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57145,6 +57145,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.run = run;
const core = __importStar(__nccwpck_require__(42186));
const exec = __importStar(__nccwpck_require__(71514));
const installer_1 = __nccwpck_require__(12574);
const fs = __importStar(__nccwpck_require__(57147));
const path_1 = __importDefault(__nccwpck_require__(71017));
Expand Down Expand Up @@ -57206,6 +57207,24 @@ async function run() {
installedDotnetVersions.push(installedVersion);
}
installer_1.DotnetInstallDir.addToPath();
const workloadsInput = core.getInput('workloads');
if (workloadsInput) {
const workloads = workloadsInput
.split(',')
.map(w => w.trim())
.filter(Boolean);
if (workloads.length) {
try {
core.info(`Refreshing workload manifests...`);
await exec.exec('dotnet', ['workload', 'update']);
core.info(`Installing workloads: ${workloads.join(', ')}`);
await exec.exec('dotnet', ['workload', 'install', ...workloads]);
}
catch (err) {
throw new Error(`Failed to install workloads [${workloads.join(', ')}]: ${err}`);
}
}
}
}
const sourceUrl = core.getInput('source-url');
const configFile = core.getInput('config-file');
Expand Down
23 changes: 23 additions & 0 deletions src/setup-dotnet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import {DotnetCoreInstaller, DotnetInstallDir} from './installer';
import * as fs from 'fs';
import path from 'path';
Expand Down Expand Up @@ -74,6 +75,28 @@ export async function run() {
installedDotnetVersions.push(installedVersion);
}
DotnetInstallDir.addToPath();

const workloadsInput = core.getInput('workloads');
if (workloadsInput) {
const workloads = workloadsInput
.split(',')
.map(w => w.trim())
.filter(Boolean);

if (workloads.length) {
try {
core.info(`Refreshing workload manifests...`);
await exec.exec('dotnet', ['workload', 'update']);

core.info(`Installing workloads: ${workloads.join(', ')}`);
await exec.exec('dotnet', ['workload', 'install', ...workloads]);
} catch (err) {
throw new Error(
`Failed to install workloads [${workloads.join(', ')}]: ${err}`
);
}
}
}
}

const sourceUrl: string = core.getInput('source-url');
Expand Down
Loading