diff --git a/src/installer.ts b/src/installer.ts index cd1f7ed..c46b9b9 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -274,18 +274,11 @@ export class DotnetCoreInstaller { } constructor( - private version: string, + private dotnetVersion: DotnetVersion, private quality: QualityOptions, - private preferInstalled = false ) {} public async installDotnet(): Promise { - const versionResolver = new DotnetVersionResolver( - this.version, - this.preferInstalled - ); - const dotnetVersion = await versionResolver.createDotnetVersion(); - /** * Install dotnet runitme first in order to get * the latest stable version of dotnet CLI @@ -321,7 +314,7 @@ export class DotnetCoreInstaller { IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files' ) // Use version provided by user - .useVersion(dotnetVersion, this.quality) + .useVersion(this.dotnetVersion, this.quality) .execute(); if (dotnetInstallOutput.exitCode) { diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index 292e6da..3ade9d9 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -1,5 +1,5 @@ import * as core from '@actions/core'; -import {DotnetCoreInstaller, DotnetInstallDir} from './installer'; +import {DotnetCoreInstaller, DotnetInstallDir, DotnetVersionResolver} from './installer'; import * as fs from 'fs'; import path from 'path'; import semver from 'semver'; @@ -68,12 +68,14 @@ export async function run() { } let dotnetInstaller: DotnetCoreInstaller; + let dotnetVersionResolver: DotnetVersionResolver; + const uniqueVersions = new Set(versions); for (const version of uniqueVersions) { + dotnetVersionResolver = new DotnetVersionResolver(version, preferInstalled); dotnetInstaller = new DotnetCoreInstaller( - version, + await dotnetVersionResolver.createDotnetVersion(), quality, - preferInstalled ); const installedVersion = await dotnetInstaller.installDotnet(); installedDotnetVersions.push(installedVersion);