From a77dbf07aa217b2264fc05b4a780f2dbbffd09b3 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Tue, 27 Sep 2022 15:13:09 +0200 Subject: [PATCH 01/22] Implement dotnet-version output --- action.yml | 3 +++ dist/index.js | 25 ++++++++++++++++++++++++- src/installer.ts | 22 ++++++++++++++++++++++ src/setup-dotnet.ts | 12 +++++++++++- 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index f259c3bb7..dafec8689 100644 --- a/action.yml +++ b/action.yml @@ -17,6 +17,9 @@ inputs: description: 'Optional OWNER for using packages from GitHub Package Registry organizations/users other than the current repository''s owner. Only used if a GPR URL is also provided in source-url' config-file: description: 'Optional NuGet.config location, if your NuGet.config isn''t located in the root of the repo.' +outputs: + dotnet-version: + description: 'Contains the installed by action .NET SDK version for reuse.' runs: using: 'node16' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index 9e6f7b426..26214d0ab 100644 --- a/dist/index.js +++ b/dist/index.js @@ -356,8 +356,25 @@ class DotnetCoreInstaller { if (exitCode) { throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`); } + return this.outputDotnetVersion(stdout); }); } + outputDotnetVersion(logs) { + let resolvedVersion = ''; + const installedByScriptPattern = /Installed version is (?\d+\.\d+\.\d.*)$/m; + const preinstalledOnRunnerPattern = /.NET Core SDK with version '(?\d+\.\d+\.\d.*)'/m; + let regExpressions = [ + installedByScriptPattern, + preinstalledOnRunnerPattern + ]; + for (let regExp of regExpressions) { + if (regExp.test(logs)) { + resolvedVersion = logs.match(regExp).groups.version; + break; + } + } + return resolvedVersion; + } } exports.DotnetCoreInstaller = DotnetCoreInstaller; DotnetCoreInstaller.installationDirectoryWindows = path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet'); @@ -408,6 +425,7 @@ const core = __importStar(__nccwpck_require__(2186)); const installer_1 = __nccwpck_require__(1480); const fs = __importStar(__nccwpck_require__(7147)); const path_1 = __importDefault(__nccwpck_require__(1017)); +const semver_1 = __importDefault(__nccwpck_require__(5911)); const auth = __importStar(__nccwpck_require__(8527)); const qualityOptions = [ 'daily', @@ -429,6 +447,7 @@ function run() { // Proxy, auth, (etc) are still set up, even if no version is identified // const versions = core.getMultilineInput('dotnet-version'); + let installedDotnetVersions = []; const globalJsonFileInput = core.getInput('global-json-file'); if (globalJsonFileInput) { const globalJsonPath = path_1.default.join(process.cwd(), globalJsonFileInput); @@ -454,7 +473,8 @@ function run() { const uniqueVersions = new Set(versions); for (const version of uniqueVersions) { dotnetInstaller = new installer_1.DotnetCoreInstaller(version, quality); - yield dotnetInstaller.installDotnet(); + let installedVersion = yield dotnetInstaller.installDotnet(); + installedDotnetVersions.push(installedVersion); } installer_1.DotnetCoreInstaller.addToPath(); } @@ -463,6 +483,9 @@ function run() { if (sourceUrl) { auth.configAuthentication(sourceUrl, configFile); } + core.setOutput('dotnet-version', semver_1.default.maxSatisfying(installedDotnetVersions, '*', { + includePrerelease: true + })); const matchersPath = path_1.default.join(__dirname, '..', '.github'); core.info(`##[add-matcher]${path_1.default.join(matchersPath, 'csc.json')}`); } diff --git a/src/installer.ts b/src/installer.ts index 24bab1b68..abf54ac87 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -238,5 +238,27 @@ export class DotnetCoreInstaller { if (exitCode) { throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`); } + + return this.outputDotnetVersion(stdout); + } + + private outputDotnetVersion(logs: string): string { + let resolvedVersion: string = ''; + const installedByScriptPattern = /Installed version is (?\d+\.\d+\.\d.*)$/m; + const preinstalledOnRunnerPattern = /.NET Core SDK with version '(?\d+\.\d+\.\d.*)'/m; + + let regExpressions: RegExp[] = [ + installedByScriptPattern, + preinstalledOnRunnerPattern + ]; + + for (let regExp of regExpressions) { + if (regExp.test(logs)) { + resolvedVersion = logs.match(regExp)!.groups!.version; + break; + } + } + + return resolvedVersion; } } diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index 23063621a..eccdc2603 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -2,6 +2,7 @@ import * as core from '@actions/core'; import {DotnetCoreInstaller} from './installer'; import * as fs from 'fs'; import path from 'path'; +import semver from 'semver'; import * as auth from './authutil'; const qualityOptions = [ @@ -26,6 +27,7 @@ export async function run() { // Proxy, auth, (etc) are still set up, even if no version is identified // const versions = core.getMultilineInput('dotnet-version'); + let installedDotnetVersions: string[] = []; const globalJsonFileInput = core.getInput('global-json-file'); if (globalJsonFileInput) { @@ -60,7 +62,8 @@ export async function run() { const uniqueVersions = new Set(versions); for (const version of uniqueVersions) { dotnetInstaller = new DotnetCoreInstaller(version, quality); - await dotnetInstaller.installDotnet(); + let installedVersion = await dotnetInstaller.installDotnet(); + installedDotnetVersions.push(installedVersion); } DotnetCoreInstaller.addToPath(); } @@ -71,6 +74,13 @@ export async function run() { auth.configAuthentication(sourceUrl, configFile); } + core.setOutput( + 'dotnet-version', + semver.maxSatisfying(installedDotnetVersions, '*', { + includePrerelease: true + }) + ); + const matchersPath = path.join(__dirname, '..', '.github'); core.info(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`); } catch (error) { From 3f8992a9dad5671a01e5d582ed94b24692921f8d Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Tue, 27 Sep 2022 15:13:58 +0200 Subject: [PATCH 02/22] Add e2e test for the dotnet-version output --- .github/workflows/workflow.yml | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index eb9241f7e..bf98a7ce5 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -237,6 +237,60 @@ jobs: $version = & dotnet --version Write-Host "Installed version: $version" if (-not ($version.Contains("preview") -or $version.Contains("rc"))) { throw "Unexpected version" } + + test-dotnet-version-output-during-single-version-installation: + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest, windows-latest, macOS-latest] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Clear toolcache + shell: pwsh + run: __tests__/clear-toolcache.ps1 ${{ runner.os }} + + - name: Setup dotnet 6.0.401 + uses: ./ + id: step1 + with: + dotnet-version: "6.0.401" + + - name: Verify value of the dotnet-version output + shell: pwsh + run: | + $version = & dotnet --version + Write-Host "Installed version: $version" + if (-not ($version -eq '${{steps.step1.outputs.dotnet-version}}')) { throw "Unexpected output value" } + + test-dotnet-version-output-during-multiple-version-installation: + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest, windows-latest, macOS-latest] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Clear toolcache + shell: pwsh + run: __tests__/clear-toolcache.ps1 ${{ runner.os }} + + - name: Setup dotnet 6.0.401, 5.0.408, 7.0.100-rc.1.22431.12 + uses: ./ + id: step2 + with: + dotnet-version: | + 7.0.100-rc.1.22431.12 + 6.0.401 + 5.0.408 + + - name: Verify value of the dotnet-version output + shell: pwsh + run: | + $version = "7.0.100-rc.1.22431.12" + if (-not ($version -eq '${{steps.step2.outputs.dotnet-version}}')) { throw "Unexpected output value" } test-proxy: runs-on: ubuntu-latest From f2b7c181bee13989083653cd9c7c7836cdbc2fe4 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Tue, 27 Sep 2022 15:14:41 +0200 Subject: [PATCH 03/22] Update documentation --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index 087097486..aea9f83f3 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,41 @@ 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. +# Outputs and environment variables + +## Outputs + +### `dotnet-version` + +Using **dotnet-version** output it's possible to get the installed by action .NET SDK version. + +**Single version installation** + +In case of a single version installation, `dotnet-version` contains the version that is installed by the action. + +```yaml + - uses: actions/setup-dotnet@v3 + id: cp310 + with: + dotnet-version: 3.1.422 + - run: echo '${{ steps.cp310.outputs.dotnet-version }}' # outputs 3.1.422 +``` + +**Multiple version installation** + +In case of a multiple version installation, `dotnet-version` contains the latest version that is installed by the action. + +```yaml + - uses: actions/setup-dotnet@v3 + id: cp310 + with: + dotnet-version: | + 3.1.422 + 5.0.408 + - run: echo '${{ steps.cp310.outputs.dotnet-version }}' # outputs 5.0.408 +``` + + ## Environment variables Some environment variables may be necessary for your particular case or to improve logging. Some examples are listed below, but the full list with complete details can be found here: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables From 6eb9549b622b5721132fd4a66a83537a1b04c0a3 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Tue, 27 Sep 2022 16:41:42 +0200 Subject: [PATCH 04/22] Fix review points --- dist/index.js | 6 +++--- src/installer.ts | 2 +- src/setup-dotnet.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/index.js b/dist/index.js index 26214d0ab..a167ab0c3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -363,7 +363,7 @@ class DotnetCoreInstaller { let resolvedVersion = ''; const installedByScriptPattern = /Installed version is (?\d+\.\d+\.\d.*)$/m; const preinstalledOnRunnerPattern = /.NET Core SDK with version '(?\d+\.\d+\.\d.*)'/m; - let regExpressions = [ + const regExpressions = [ installedByScriptPattern, preinstalledOnRunnerPattern ]; @@ -447,7 +447,7 @@ function run() { // Proxy, auth, (etc) are still set up, even if no version is identified // const versions = core.getMultilineInput('dotnet-version'); - let installedDotnetVersions = []; + const installedDotnetVersions = []; const globalJsonFileInput = core.getInput('global-json-file'); if (globalJsonFileInput) { const globalJsonPath = path_1.default.join(process.cwd(), globalJsonFileInput); @@ -473,7 +473,7 @@ function run() { const uniqueVersions = new Set(versions); for (const version of uniqueVersions) { dotnetInstaller = new installer_1.DotnetCoreInstaller(version, quality); - let installedVersion = yield dotnetInstaller.installDotnet(); + const installedVersion = yield dotnetInstaller.installDotnet(); installedDotnetVersions.push(installedVersion); } installer_1.DotnetCoreInstaller.addToPath(); diff --git a/src/installer.ts b/src/installer.ts index abf54ac87..b9eedb9f3 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -247,7 +247,7 @@ export class DotnetCoreInstaller { const installedByScriptPattern = /Installed version is (?\d+\.\d+\.\d.*)$/m; const preinstalledOnRunnerPattern = /.NET Core SDK with version '(?\d+\.\d+\.\d.*)'/m; - let regExpressions: RegExp[] = [ + const regExpressions: RegExp[] = [ installedByScriptPattern, preinstalledOnRunnerPattern ]; diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index eccdc2603..6246b3bdb 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -27,7 +27,7 @@ export async function run() { // Proxy, auth, (etc) are still set up, even if no version is identified // const versions = core.getMultilineInput('dotnet-version'); - let installedDotnetVersions: string[] = []; + const installedDotnetVersions: string[] = []; const globalJsonFileInput = core.getInput('global-json-file'); if (globalJsonFileInput) { @@ -62,7 +62,7 @@ export async function run() { const uniqueVersions = new Set(versions); for (const version of uniqueVersions) { dotnetInstaller = new DotnetCoreInstaller(version, quality); - let installedVersion = await dotnetInstaller.installDotnet(); + const installedVersion = await dotnetInstaller.installDotnet(); installedDotnetVersions.push(installedVersion); } DotnetCoreInstaller.addToPath(); From 68d994cec26b920461c53e070593db83753bb98f Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Wed, 28 Sep 2022 10:57:54 +0200 Subject: [PATCH 05/22] Add unit-tests --- __tests__/installer.test.ts | 17 +++++++++++++++-- __tests__/setup-dotnet.test.ts | 17 +++++++++++++++++ src/installer.ts | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts index 9d94eca21..79a90c34b 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -107,6 +107,15 @@ describe('DotnetCoreInstaller tests', () => { expect(process.env.PATH?.startsWith(toolDir)).toBe(true); }, 600000); //This needs some time to download on "slower" internet connections + it('Returns string with installed SDK version', async () => { + const version = '3.1.120'; + let installedVersion: string; + + installedVersion = await getDotnet(version); + + expect(installedVersion).toBe('3.1.120'); + }, 600000); + it('Throws if no location contains correct dotnet version', async () => { await expect(async () => { await getDotnet('1000.0.0'); @@ -267,11 +276,15 @@ function normalizeFileContents(contents: string): string { .replace(new RegExp('\r', 'g'), '\n'); } -async function getDotnet(version: string, quality: string = ''): Promise { +async function getDotnet( + version: string, + quality: string = '' +): Promise { const dotnetInstaller = new installer.DotnetCoreInstaller( version, quality as QualityOptions ); - await dotnetInstaller.installDotnet(); + const installedVersion = await dotnetInstaller.installDotnet(); installer.DotnetCoreInstaller.addToPath(); + return installedVersion; } diff --git a/__tests__/setup-dotnet.test.ts b/__tests__/setup-dotnet.test.ts index 4cd84b6c1..2b3df167f 100644 --- a/__tests__/setup-dotnet.test.ts +++ b/__tests__/setup-dotnet.test.ts @@ -1,4 +1,5 @@ import * as io from '@actions/io'; +import * as core from '@actions/core'; import fs from 'fs'; import os from 'os'; import path from 'path'; @@ -20,6 +21,8 @@ if (IS_WINDOWS) { const tempDir = path.join(__dirname, 'runner', 'temp2'); describe('setup-dotnet tests', () => { + let getMultilineInputSpy = jest.spyOn(core, 'getMultilineInput'); + beforeAll(async () => { process.env.RUNNER_TOOL_CACHE = toolDir; process.env.DOTNET_INSTALL_DIR = toolDir; @@ -59,4 +62,18 @@ describe('setup-dotnet tests', () => { expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true); } }, 400000); + + it('Sets output with the installed version', async () => { + const versions = ['3.1.201', '6.0.401']; + + let setOutputSpy = jest.spyOn(core, 'getMultilineInput'); + + getMultilineInputSpy.mockImplementation(() => { + return versions; + }); + + await setup.run(); + + expect(setOutputSpy).toBeCalledWith('dotnet-version', '3.1.201'); + }, 400000); }); diff --git a/src/installer.ts b/src/installer.ts index b9eedb9f3..3d94a5d3d 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -164,7 +164,7 @@ export class DotnetCoreInstaller { } } - public async installDotnet() { + public async installDotnet(): Promise { const windowsDefaultOptions = [ '-NoLogo', '-Sta', From 92ff81074f3b1733ef5f5aea34d512d30f9043a0 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Wed, 28 Sep 2022 11:08:35 +0200 Subject: [PATCH 06/22] Fix unit-tests --- __tests__/setup-dotnet.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/__tests__/setup-dotnet.test.ts b/__tests__/setup-dotnet.test.ts index 2b3df167f..ac99415ac 100644 --- a/__tests__/setup-dotnet.test.ts +++ b/__tests__/setup-dotnet.test.ts @@ -22,6 +22,7 @@ const tempDir = path.join(__dirname, 'runner', 'temp2'); describe('setup-dotnet tests', () => { let getMultilineInputSpy = jest.spyOn(core, 'getMultilineInput'); + let setOutputSpy = jest.spyOn(core, 'setOutput'); beforeAll(async () => { process.env.RUNNER_TOOL_CACHE = toolDir; @@ -66,8 +67,6 @@ describe('setup-dotnet tests', () => { it('Sets output with the installed version', async () => { const versions = ['3.1.201', '6.0.401']; - let setOutputSpy = jest.spyOn(core, 'getMultilineInput'); - getMultilineInputSpy.mockImplementation(() => { return versions; }); From 12c47bed3ca8e9bb0be8d7aca14dd3d44b5c5be0 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Wed, 28 Sep 2022 11:11:10 +0200 Subject: [PATCH 07/22] Fix typo in the unit-test --- __tests__/setup-dotnet.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/__tests__/setup-dotnet.test.ts b/__tests__/setup-dotnet.test.ts index ac99415ac..ac799503b 100644 --- a/__tests__/setup-dotnet.test.ts +++ b/__tests__/setup-dotnet.test.ts @@ -64,7 +64,7 @@ describe('setup-dotnet tests', () => { } }, 400000); - it('Sets output with the installed version', async () => { + it('Sets output with the latest installed by action version', async () => { const versions = ['3.1.201', '6.0.401']; getMultilineInputSpy.mockImplementation(() => { @@ -73,6 +73,6 @@ describe('setup-dotnet tests', () => { await setup.run(); - expect(setOutputSpy).toBeCalledWith('dotnet-version', '3.1.201'); + expect(setOutputSpy).toBeCalledWith('dotnet-version', '6.0.401'); }, 400000); }); From 75d47e04fb37f2e19ce885f1cb895db1bd78d933 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Wed, 28 Sep 2022 13:44:37 +0200 Subject: [PATCH 08/22] Change logic of outputting when global.json is used --- dist/index.js | 9 +++++++-- src/setup-dotnet.ts | 19 ++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/dist/index.js b/dist/index.js index a167ab0c3..bf3e1cd7f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -483,9 +483,14 @@ function run() { if (sourceUrl) { auth.configAuthentication(sourceUrl, configFile); } - core.setOutput('dotnet-version', semver_1.default.maxSatisfying(installedDotnetVersions, '*', { + const comparisonRange = globalJsonFileInput + ? versions.at(-1) + : '*'; + const includePrereleaseOption = { includePrerelease: true - })); + }; + const versionToOutput = semver_1.default.maxSatisfying(installedDotnetVersions, comparisonRange, includePrereleaseOption); + core.setOutput('dotnet-version', versionToOutput); const matchersPath = path_1.default.join(__dirname, '..', '.github'); core.info(`##[add-matcher]${path_1.default.join(matchersPath, 'csc.json')}`); } diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index 6246b3bdb..5cdb88093 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -74,13 +74,22 @@ export async function run() { auth.configAuthentication(sourceUrl, configFile); } - core.setOutput( - 'dotnet-version', - semver.maxSatisfying(installedDotnetVersions, '*', { - includePrerelease: true - }) + const comparisonRange: string = globalJsonFileInput + ? versions.at(-1)! + : '*'; + + const includePrereleaseOption = { + includePrerelease: true + }; + + const versionToOutput = semver.maxSatisfying( + installedDotnetVersions, + comparisonRange, + includePrereleaseOption ); + core.setOutput('dotnet-version', versionToOutput); + const matchersPath = path.join(__dirname, '..', '.github'); core.info(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`); } catch (error) { From b74b8e018ae53df0c34553c28340aa4e9610e94b Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Wed, 28 Sep 2022 14:10:10 +0200 Subject: [PATCH 09/22] Refactor code --- dist/index.js | 7 +++---- src/setup-dotnet.ts | 10 ++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/dist/index.js b/dist/index.js index bf3e1cd7f..5a43f0cd7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -484,12 +484,11 @@ function run() { auth.configAuthentication(sourceUrl, configFile); } const comparisonRange = globalJsonFileInput - ? versions.at(-1) + ? versions[versions.length - 1] : '*'; - const includePrereleaseOption = { + const versionToOutput = semver_1.default.maxSatisfying(installedDotnetVersions, comparisonRange, { includePrerelease: true - }; - const versionToOutput = semver_1.default.maxSatisfying(installedDotnetVersions, comparisonRange, includePrereleaseOption); + }); core.setOutput('dotnet-version', versionToOutput); const matchersPath = path_1.default.join(__dirname, '..', '.github'); core.info(`##[add-matcher]${path_1.default.join(matchersPath, 'csc.json')}`); diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index 5cdb88093..ba2e419e2 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -75,17 +75,15 @@ export async function run() { } const comparisonRange: string = globalJsonFileInput - ? versions.at(-1)! + ? versions[versions.length - 1]! : '*'; - const includePrereleaseOption = { - includePrerelease: true - }; - const versionToOutput = semver.maxSatisfying( installedDotnetVersions, comparisonRange, - includePrereleaseOption + { + includePrerelease: true + } ); core.setOutput('dotnet-version', versionToOutput); From 1d0f2c615d23d71910eb3e53fa6ebfd0832c5b85 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Wed, 28 Sep 2022 14:35:29 +0200 Subject: [PATCH 10/22] Add unit-test --- __tests__/setup-dotnet.test.ts | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/__tests__/setup-dotnet.test.ts b/__tests__/setup-dotnet.test.ts index ac799503b..ff3eb5ad0 100644 --- a/__tests__/setup-dotnet.test.ts +++ b/__tests__/setup-dotnet.test.ts @@ -21,9 +21,12 @@ if (IS_WINDOWS) { const tempDir = path.join(__dirname, 'runner', 'temp2'); describe('setup-dotnet tests', () => { + let getInputSpy = jest.spyOn(core, 'getInput'); let getMultilineInputSpy = jest.spyOn(core, 'getMultilineInput'); let setOutputSpy = jest.spyOn(core, 'setOutput'); + let inputs = {} as any; + beforeAll(async () => { process.env.RUNNER_TOOL_CACHE = toolDir; process.env.DOTNET_INSTALL_DIR = toolDir; @@ -64,15 +67,32 @@ describe('setup-dotnet tests', () => { } }, 400000); - it('Sets output with the latest installed by action version', async () => { - const versions = ['3.1.201', '6.0.401']; + it("Sets output with the latest installed by action version if global.json file isn't specified", async () => { + inputs['dotnet-version'] = ['3.1.201', '6.0.401']; - getMultilineInputSpy.mockImplementation(() => { - return versions; - }); + getMultilineInputSpy.mockImplementation(input => inputs[input]); await setup.run(); expect(setOutputSpy).toBeCalledWith('dotnet-version', '6.0.401'); }, 400000); + + it("Sets output with the version specified in global.json, if it's present", async () => { + const globalJsonPath = path.join(process.cwd(), 'global.json'); + const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version": "3.0.103"${os.EOL}}${os.EOL}}`; + if (!fs.existsSync(globalJsonPath)) { + fs.writeFileSync(globalJsonPath, jsonContents); + } + + inputs['dotnet-version'] = ['3.1.201', '6.0.401']; + inputs['global-json-file'] = globalJsonPath; + + getMultilineInputSpy.mockImplementation(input => inputs[input]); + + getInputSpy.mockImplementation(input => inputs[input]); + + await setup.run(); + + expect(setOutputSpy).toBeCalledWith('dotnet-version', '3.0.103'); + }, 400000); }); From 1717505b7094b0277c12b4b73ef39e994d378fdb Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Wed, 28 Sep 2022 15:00:52 +0200 Subject: [PATCH 11/22] Fix unit-test --- __tests__/setup-dotnet.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__tests__/setup-dotnet.test.ts b/__tests__/setup-dotnet.test.ts index ff3eb5ad0..1b2e3cf7a 100644 --- a/__tests__/setup-dotnet.test.ts +++ b/__tests__/setup-dotnet.test.ts @@ -85,7 +85,7 @@ describe('setup-dotnet tests', () => { } inputs['dotnet-version'] = ['3.1.201', '6.0.401']; - inputs['global-json-file'] = globalJsonPath; + inputs['global-json-file'] = './global.json'; getMultilineInputSpy.mockImplementation(input => inputs[input]); From 9a0437f372734b04439c2e7ed99935abeec2fbd0 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Wed, 28 Sep 2022 16:43:09 +0200 Subject: [PATCH 12/22] Update documentation --- README.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index aea9f83f3..87fbf995b 100644 --- a/README.md +++ b/README.md @@ -147,11 +147,11 @@ steps: ### `dotnet-version` -Using **dotnet-version** output it's possible to get the installed by action .NET SDK version. +Using the **dotnet-version** output it's possible to get the installed by the action .NET SDK version. **Single version installation** -In case of a single version installation, `dotnet-version` contains the version that is installed by the action. +In case of a single version installation, the `dotnet-version` output contains the version that is installed by the action. ```yaml - uses: actions/setup-dotnet@v3 @@ -163,7 +163,7 @@ In case of a single version installation, `dotnet-version` contains the version **Multiple version installation** -In case of a multiple version installation, `dotnet-version` contains the latest version that is installed by the action. +In case of a multiple version installation, the `dotnet-version` output contains the latest version that is installed by the action. ```yaml - uses: actions/setup-dotnet@v3 @@ -174,7 +174,20 @@ In case of a multiple version installation, `dotnet-version` contains the latest 5.0.408 - run: echo '${{ steps.cp310.outputs.dotnet-version }}' # outputs 5.0.408 ``` +**Installation from global.json** +When the `dotnet-version` input is used along withthe `global-json-file` input, the `dotnet-version` output contains the version resolved from the `global.json`. + +```yaml + - uses: actions/setup-dotnet@v3 + id: cp310 + with: + dotnet-version: | + 3.1.422 + 5.0.408 + global-json-file: "./global.json" # contains version 2.2.207 + - run: echo '${{ steps.cp310.outputs.dotnet-version }}' # outputs 2.2.207 +``` ## Environment variables From 3fa46bb101dd31bf53a105c28f9802a4a9ac0d31 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Wed, 28 Sep 2022 16:44:51 +0200 Subject: [PATCH 13/22] Fix typo in the documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 87fbf995b..c802711b7 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ In case of a multiple version installation, the `dotnet-version` output contains ``` **Installation from global.json** -When the `dotnet-version` input is used along withthe `global-json-file` input, the `dotnet-version` output contains the version resolved from the `global.json`. +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`. ```yaml - uses: actions/setup-dotnet@v3 From 168eb53ca5da36975ebdf2534526483200e8cac5 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Thu, 29 Sep 2022 13:15:50 +0200 Subject: [PATCH 14/22] Change logic for getting the installed version --- dist/index.js | 43 ++++++++++++++++++++++++------------------- src/installer.ts | 46 ++++++++++++++++++++++++++-------------------- src/utils.ts | 1 + 3 files changed, 51 insertions(+), 39 deletions(-) diff --git a/dist/index.js b/dist/index.js index 5a43f0cd7..5eced1bcf 100644 --- a/dist/index.js +++ b/dist/index.js @@ -189,6 +189,7 @@ const exec = __importStar(__nccwpck_require__(1514)); const io = __importStar(__nccwpck_require__(7436)); const hc = __importStar(__nccwpck_require__(6255)); const fs_1 = __nccwpck_require__(7147); +const promises_1 = __nccwpck_require__(3292); const path_1 = __importDefault(__nccwpck_require__(1017)); const semver_1 = __importDefault(__nccwpck_require__(5911)); const utils_1 = __nccwpck_require__(918); @@ -284,8 +285,8 @@ class DotnetCoreInstaller { } else { // This is the default set in install-dotnet.sh - core.addPath(path_1.default.join(process.env['HOME'] + '', '.dotnet')); - core.exportVariable('DOTNET_ROOT', path_1.default.join(process.env['HOME'] + '', '.dotnet')); + core.addPath(DotnetCoreInstaller.installationDirectoryMac); + core.exportVariable('DOTNET_ROOT', DotnetCoreInstaller.installationDirectoryMac); } } } @@ -351,34 +352,29 @@ class DotnetCoreInstaller { if (utils_1.IS_LINUX) { scriptArguments.push('--install-dir', DotnetCoreInstaller.installationDirectoryLinux); } + if (utils_1.IS_MAC) { + scriptArguments.push('--install-dir', DotnetCoreInstaller.installationDirectoryMac); + } } const { exitCode, stdout } = yield exec.getExecOutput(`"${scriptPath}"`, scriptArguments, { ignoreReturnCode: true }); if (exitCode) { throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`); } - return this.outputDotnetVersion(stdout); + return this.outputDotnetVersion(dotnetVersion.value, scriptArguments[scriptArguments.length - 1]); }); } - outputDotnetVersion(logs) { - let resolvedVersion = ''; - const installedByScriptPattern = /Installed version is (?\d+\.\d+\.\d.*)$/m; - const preinstalledOnRunnerPattern = /.NET Core SDK with version '(?\d+\.\d+\.\d.*)'/m; - const regExpressions = [ - installedByScriptPattern, - preinstalledOnRunnerPattern - ]; - for (let regExp of regExpressions) { - if (regExp.test(logs)) { - resolvedVersion = logs.match(regExp).groups.version; - break; - } - } - return resolvedVersion; + outputDotnetVersion(version, installationPath) { + return __awaiter(this, void 0, void 0, function* () { + let versionsOnRunner = yield promises_1.readdir(installationPath); + let installedVersion = semver_1.default.maxSatisfying(versionsOnRunner, version); + return installedVersion; + }); } } exports.DotnetCoreInstaller = DotnetCoreInstaller; DotnetCoreInstaller.installationDirectoryWindows = path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet'); DotnetCoreInstaller.installationDirectoryLinux = '/usr/share/dotnet'; +DotnetCoreInstaller.installationDirectoryMac = path_1.default.join(process.env['HOME'] + '', '.dotnet'); /***/ }), @@ -525,9 +521,10 @@ run(); "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.IS_LINUX = exports.IS_WINDOWS = void 0; +exports.IS_MAC = exports.IS_LINUX = exports.IS_WINDOWS = void 0; exports.IS_WINDOWS = process.platform === 'win32'; exports.IS_LINUX = process.platform === 'linux'; +exports.IS_MAC = process.platform === 'darwin'; /***/ }), @@ -25715,6 +25712,14 @@ module.exports = require("fs"); /***/ }), +/***/ 3292: +/***/ ((module) => { + +"use strict"; +module.exports = require("fs/promises"); + +/***/ }), + /***/ 3685: /***/ ((module) => { diff --git a/src/installer.ts b/src/installer.ts index 3d94a5d3d..f0698f6e5 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -4,9 +4,10 @@ import * as exec from '@actions/exec'; import * as io from '@actions/io'; import * as hc from '@actions/http-client'; import {chmodSync} from 'fs'; +import {readdir} from 'fs/promises'; import path from 'path'; import semver from 'semver'; -import {IS_LINUX, IS_WINDOWS} from './utils'; +import {IS_LINUX, IS_WINDOWS, IS_MAC} from './utils'; import {QualityOptions} from './setup-dotnet'; export interface DotnetVersion { @@ -116,6 +117,10 @@ export class DotnetCoreInstaller { 'dotnet' ); private static readonly installationDirectoryLinux = '/usr/share/dotnet'; + private static readonly installationDirectoryMac = path.join( + process.env['HOME'] + '', + '.dotnet' + ); static addToPath() { if (process.env['DOTNET_INSTALL_DIR']) { @@ -136,10 +141,10 @@ export class DotnetCoreInstaller { ); } else { // This is the default set in install-dotnet.sh - core.addPath(path.join(process.env['HOME'] + '', '.dotnet')); + core.addPath(DotnetCoreInstaller.installationDirectoryMac); core.exportVariable( 'DOTNET_ROOT', - path.join(process.env['HOME'] + '', '.dotnet') + DotnetCoreInstaller.installationDirectoryMac ); } } @@ -229,6 +234,13 @@ export class DotnetCoreInstaller { DotnetCoreInstaller.installationDirectoryLinux ); } + + if (IS_MAC) { + scriptArguments.push( + '--install-dir', + DotnetCoreInstaller.installationDirectoryMac + ); + } } const {exitCode, stdout} = await exec.getExecOutput( `"${scriptPath}"`, @@ -239,26 +251,20 @@ export class DotnetCoreInstaller { throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`); } - return this.outputDotnetVersion(stdout); + return this.outputDotnetVersion( + dotnetVersion.value, + scriptArguments[scriptArguments.length - 1] + ); } - private outputDotnetVersion(logs: string): string { - let resolvedVersion: string = ''; - const installedByScriptPattern = /Installed version is (?\d+\.\d+\.\d.*)$/m; - const preinstalledOnRunnerPattern = /.NET Core SDK with version '(?\d+\.\d+\.\d.*)'/m; - - const regExpressions: RegExp[] = [ - installedByScriptPattern, - preinstalledOnRunnerPattern - ]; + private async outputDotnetVersion( + version, + installationPath + ): Promise { + let versionsOnRunner: string[] = await readdir(installationPath); - for (let regExp of regExpressions) { - if (regExp.test(logs)) { - resolvedVersion = logs.match(regExp)!.groups!.version; - break; - } - } + let installedVersion = semver.maxSatisfying(versionsOnRunner, version)!; - return resolvedVersion; + return installedVersion; } } diff --git a/src/utils.ts b/src/utils.ts index 77886ce0e..ff20ee303 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,2 +1,3 @@ export const IS_WINDOWS = process.platform === 'win32'; export const IS_LINUX = process.platform === 'linux'; +export const IS_MAC = process.platform === 'darwin'; From eb389a26999e1ab3f68d32a230ed0e681d500948 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Thu, 29 Sep 2022 13:33:35 +0200 Subject: [PATCH 15/22] Fix wrong path --- dist/index.js | 2 +- src/installer.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 5eced1bcf..ce3c07fd7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -365,7 +365,7 @@ class DotnetCoreInstaller { } outputDotnetVersion(version, installationPath) { return __awaiter(this, void 0, void 0, function* () { - let versionsOnRunner = yield promises_1.readdir(installationPath); + let versionsOnRunner = yield promises_1.readdir(path_1.default.join(installationPath, 'sdk')); let installedVersion = semver_1.default.maxSatisfying(versionsOnRunner, version); return installedVersion; }); diff --git a/src/installer.ts b/src/installer.ts index f0698f6e5..6f5a8b13a 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -261,7 +261,9 @@ export class DotnetCoreInstaller { version, installationPath ): Promise { - let versionsOnRunner: string[] = await readdir(installationPath); + let versionsOnRunner: string[] = await readdir( + path.join(installationPath, 'sdk') + ); let installedVersion = semver.maxSatisfying(versionsOnRunner, version)!; From 57ce9fed6b3d79b0938c73b21e685130736c298f Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Thu, 29 Sep 2022 13:51:12 +0200 Subject: [PATCH 16/22] Fix logic --- dist/index.js | 2 +- src/installer.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index ce3c07fd7..9f10f0196 100644 --- a/dist/index.js +++ b/dist/index.js @@ -337,7 +337,7 @@ class DotnetCoreInstaller { // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used scriptPath = (yield io.which('pwsh', false)) || (yield io.which('powershell', true)); - scriptArguments = [...windowsDefaultOptions, scriptArguments.join(' ')]; + scriptArguments = windowsDefaultOptions.concat(scriptArguments); } else { fs_1.chmodSync(escapedScript, '777'); diff --git a/src/installer.ts b/src/installer.ts index 6f5a8b13a..589fe39c6 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -214,7 +214,7 @@ export class DotnetCoreInstaller { // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used scriptPath = (await io.which('pwsh', false)) || (await io.which('powershell', true)); - scriptArguments = [...windowsDefaultOptions, scriptArguments.join(' ')]; + scriptArguments = windowsDefaultOptions.concat(scriptArguments); } else { chmodSync(escapedScript, '777'); scriptPath = await io.which(escapedScript, true); From 40d37ff84f17a2f1dff9394f93b8022205bcee05 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Thu, 29 Sep 2022 13:55:50 +0200 Subject: [PATCH 17/22] Fix inconsistency withing scriptArguments --- dist/index.js | 2 +- src/installer.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 9f10f0196..e9d78cfa7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -333,7 +333,7 @@ class DotnetCoreInstaller { if (process.env['no_proxy'] != null) { scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); } - scriptArguments.push(`-InstallDir '${DotnetCoreInstaller.installationDirectoryWindows}'`); + scriptArguments.push('-InstallDir', DotnetCoreInstaller.installationDirectoryWindows); // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used scriptPath = (yield io.which('pwsh', false)) || (yield io.which('powershell', true)); diff --git a/src/installer.ts b/src/installer.ts index 589fe39c6..cce97da2d 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -209,7 +209,8 @@ export class DotnetCoreInstaller { } scriptArguments.push( - `-InstallDir '${DotnetCoreInstaller.installationDirectoryWindows}'` + '-InstallDir', + DotnetCoreInstaller.installationDirectoryWindows ); // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used scriptPath = From cd706db55800a321aaab725dd30910c082858483 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Thu, 29 Sep 2022 14:04:33 +0200 Subject: [PATCH 18/22] Fix issue with quotes --- dist/index.js | 2 +- src/installer.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index e9d78cfa7..7e051ae1d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -333,7 +333,7 @@ class DotnetCoreInstaller { if (process.env['no_proxy'] != null) { scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); } - scriptArguments.push('-InstallDir', DotnetCoreInstaller.installationDirectoryWindows); + scriptArguments.push('-InstallDir', `'${DotnetCoreInstaller.installationDirectoryWindows}'`); // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used scriptPath = (yield io.which('pwsh', false)) || (yield io.which('powershell', true)); diff --git a/src/installer.ts b/src/installer.ts index cce97da2d..8b4ee3837 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -210,7 +210,7 @@ export class DotnetCoreInstaller { scriptArguments.push( '-InstallDir', - DotnetCoreInstaller.installationDirectoryWindows + `'${DotnetCoreInstaller.installationDirectoryWindows}'` ); // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used scriptPath = From 72e061af643c18ca27bc2541619783c1ed55088b Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Thu, 29 Sep 2022 14:28:15 +0200 Subject: [PATCH 19/22] Fix issue with quotes --- dist/index.js | 2 +- src/installer.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 7e051ae1d..88fb1fb53 100644 --- a/dist/index.js +++ b/dist/index.js @@ -333,7 +333,7 @@ class DotnetCoreInstaller { if (process.env['no_proxy'] != null) { scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); } - scriptArguments.push('-InstallDir', `'${DotnetCoreInstaller.installationDirectoryWindows}'`); + scriptArguments.push('-InstallDir', `${DotnetCoreInstaller.installationDirectoryWindows}`); // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used scriptPath = (yield io.which('pwsh', false)) || (yield io.which('powershell', true)); diff --git a/src/installer.ts b/src/installer.ts index 8b4ee3837..b0c980c21 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -210,7 +210,7 @@ export class DotnetCoreInstaller { scriptArguments.push( '-InstallDir', - `'${DotnetCoreInstaller.installationDirectoryWindows}'` + `${DotnetCoreInstaller.installationDirectoryWindows}` ); // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used scriptPath = From f64af7ff2cb9301b5d56a71bf2d12f949a96a17b Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Thu, 29 Sep 2022 14:48:08 +0200 Subject: [PATCH 20/22] Fix issue with quotes --- dist/index.js | 2 +- src/installer.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 88fb1fb53..9fc65f9ea 100644 --- a/dist/index.js +++ b/dist/index.js @@ -365,7 +365,7 @@ class DotnetCoreInstaller { } outputDotnetVersion(version, installationPath) { return __awaiter(this, void 0, void 0, function* () { - let versionsOnRunner = yield promises_1.readdir(path_1.default.join(installationPath, 'sdk')); + let versionsOnRunner = yield promises_1.readdir(path_1.default.join(installationPath.replace(/'/g, ''), 'sdk')); let installedVersion = semver_1.default.maxSatisfying(versionsOnRunner, version); return installedVersion; }); diff --git a/src/installer.ts b/src/installer.ts index b0c980c21..8fc8b0b34 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -263,7 +263,7 @@ export class DotnetCoreInstaller { installationPath ): Promise { let versionsOnRunner: string[] = await readdir( - path.join(installationPath, 'sdk') + path.join(installationPath.replace(/'/g, ''), 'sdk') ); let installedVersion = semver.maxSatisfying(versionsOnRunner, version)!; From 4d8de26495877ad2da058b73671b94e95c843801 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Thu, 29 Sep 2022 14:53:24 +0200 Subject: [PATCH 21/22] Fix issue with quotes --- dist/index.js | 2 +- src/installer.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 9fc65f9ea..673fd8de8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -333,7 +333,7 @@ class DotnetCoreInstaller { if (process.env['no_proxy'] != null) { scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); } - scriptArguments.push('-InstallDir', `${DotnetCoreInstaller.installationDirectoryWindows}`); + scriptArguments.push('-InstallDir', `'${DotnetCoreInstaller.installationDirectoryWindows}'`); // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used scriptPath = (yield io.which('pwsh', false)) || (yield io.which('powershell', true)); diff --git a/src/installer.ts b/src/installer.ts index 8fc8b0b34..bfd62a4a6 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -210,7 +210,7 @@ export class DotnetCoreInstaller { scriptArguments.push( '-InstallDir', - `${DotnetCoreInstaller.installationDirectoryWindows}` + `'${DotnetCoreInstaller.installationDirectoryWindows}'` ); // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used scriptPath = From 855515f5da77fbc8ff0a982a703d13b4e297edbf Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Thu, 29 Sep 2022 15:57:23 +0200 Subject: [PATCH 22/22] Fix version satisfying logic --- dist/index.js | 4 +++- src/installer.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 673fd8de8..217682101 100644 --- a/dist/index.js +++ b/dist/index.js @@ -366,7 +366,9 @@ class DotnetCoreInstaller { outputDotnetVersion(version, installationPath) { return __awaiter(this, void 0, void 0, function* () { let versionsOnRunner = yield promises_1.readdir(path_1.default.join(installationPath.replace(/'/g, ''), 'sdk')); - let installedVersion = semver_1.default.maxSatisfying(versionsOnRunner, version); + let installedVersion = semver_1.default.maxSatisfying(versionsOnRunner, version, { + includePrerelease: true + }); return installedVersion; }); } diff --git a/src/installer.ts b/src/installer.ts index bfd62a4a6..041b65579 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -266,7 +266,9 @@ export class DotnetCoreInstaller { path.join(installationPath.replace(/'/g, ''), 'sdk') ); - let installedVersion = semver.maxSatisfying(versionsOnRunner, version)!; + let installedVersion = semver.maxSatisfying(versionsOnRunner, version, { + includePrerelease: true + })!; return installedVersion; }