Eliminate hard dependency on version resolver in installer

This commit is contained in:
Nikolai Laevskii 2023-09-04 06:03:28 +02:00
parent 9191e7ea2f
commit d903b6184b
2 changed files with 7 additions and 12 deletions

View File

@ -274,18 +274,11 @@ export class DotnetCoreInstaller {
}
constructor(
private version: string,
private dotnetVersion: DotnetVersion,
private quality: QualityOptions,
private preferInstalled = false
) {}
public async installDotnet(): Promise<string | null> {
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) {

View File

@ -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<string>(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);