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
4 changes: 2 additions & 2 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,14 @@ jobs:
shell: bash
run: |
mkdir subdirectory
echo '{"sdk":{"version": "3.1.0","rollForward": "latestMajor"}}' > ./subdirectory/global.json
echo '{"sdk":{"version": "8.0.100","rollForward": "latestMajor"}}' > ./subdirectory/global.json
- name: Setup dotnet
uses: ./
with:
global-json-file: ./subdirectory/global.json
- name: Verify dotnet
shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^(?!3)"
run: __tests__/verify-dotnet.ps1 -Patterns "^(?!8)"
Comment thread
priyagupta108 marked this conversation as resolved.

test-setup-global-json-rollforward-latestfeature:
runs-on: ${{ matrix.operating-system }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ steps:
working-directory: csharp
```

> **Note**: The action supports `latest*` variants of the [rollForward](https://learn.microsoft.com/en-us/dotnet/core/tools/global-json#rollforward) field in `global.json`. When set to `latestPatch`, `latestFeature`, `latestMinor`, or `latestMajor`, the action installs the appropriate SDK version.
> **Note**: The action supports `latest*` variants of the [rollForward](https://learn.microsoft.com/en-us/dotnet/core/tools/global-json#rollforward) field in `global.json`. When set to `latestPatch`, `latestFeature`, `latestMinor`, or `latestMajor`, the action installs the appropriate SDK version. For prerelease versions, the exact pinned version is always installed regardless of the `rollForward` setting.

## Caching NuGet Packages
The action has a built-in functionality for caching and restoring dependencies. It uses [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under the hood for caching global packages data but requires less configuration settings. The `cache` input is optional, and caching is turned off by default.
Expand Down
8 changes: 7 additions & 1 deletion dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79244,7 +79244,13 @@ function getVersionFromGlobalJson(globalJsonPath) {
if (globalJson.sdk && globalJson.sdk.version) {
version = globalJson.sdk.version;
const rollForward = globalJson.sdk.rollForward;
if (rollForward) {
if (rollForward && !semver_1.default.prerelease(version)) {
const versionPattern = /^\d+\.\d+\.[1-9]\d{2,}$/;
if (!versionPattern.test(version)) {
throw new Error(`Version '${version}' is not valid for the 'sdk.version' value in global.json. ` +
`When 'rollForward' is specified, a full SDK version is required. ` +
`See: https://learn.microsoft.com/en-us/dotnet/core/tools/global-json`);
}
const [major, minor, featurePatch] = version.split('.');
const feature = featurePatch.substring(0, 1);
switch (rollForward) {
Expand Down
11 changes: 10 additions & 1 deletion src/setup-dotnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,16 @@ function getVersionFromGlobalJson(globalJsonPath: string): string {
if (globalJson.sdk && globalJson.sdk.version) {
version = globalJson.sdk.version;
const rollForward = globalJson.sdk.rollForward;
if (rollForward) {
if (rollForward && !semver.prerelease(version)) {
const versionPattern = /^\d+\.\d+\.[1-9]\d{2,}$/;
if (!versionPattern.test(version)) {
throw new Error(
`Version '${version}' is not valid for the 'sdk.version' value in global.json. ` +
Comment thread
priyagupta108 marked this conversation as resolved.
`When 'rollForward' is specified, a full SDK version is required. ` +
`See: https://learn.microsoft.com/en-us/dotnet/core/tools/global-json`
);
}

const [major, minor, featurePatch] = version.split('.');
const feature = featurePatch.substring(0, 1);

Expand Down
Loading