mirror of
https://github.com/actions/setup-dotnet.git
synced 2026-02-07 04:28:18 +00:00
Add support for workloads input (#693)
* Add workloads input * fix typo * resloves conflicts * Doc update --------- Co-authored-by: gowridurgad <gowridurgad@gmail.com>
This commit is contained in:
33
.github/workflows/e2e-tests.yml
vendored
33
.github/workflows/e2e-tests.yml
vendored
@@ -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
README.md
16
README.md
@@ -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
|
||||
|
||||
@@ -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.'
|
||||
|
||||
19
dist/setup/index.js
vendored
19
dist/setup/index.js
vendored
@@ -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));
|
||||
@@ -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');
|
||||
|
||||
@@ -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';
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user