Refactoring was conducted only for installer.ts module. The most significant changes are in DotnetCoreInstaller class:
Logic related to the install dir was separated and moved to simple static DotnetInstallDir class
Logic related to the install script was moved to DotnetInstallScript class, which now allows to invoke install-script multiple times and conditionally apply script arguments.
Example of DotnetInstallScript class usage (just an example code, not how it is actually set here)
// Conditionally invoke install script
if (IS_WINDOWS) {
// initialize DotnetInstallScriptClass
const installScript: Promise<exec.ExecOutput> = await new DotnetInstallScript()
// arguments can be inserted via this method
.useArguments('-Runtime', 'dotnet')
// version can be set via this method, it's just a syntactic sugar over useArguments that will insert arguments based on version provided
.useVersion({ type: '-Channel', value: '6.0', qualityFlag: false })
// useVersion and useArguments methods are chainable
// script then can be then executed with execute method
.execute();
if (installScript.exitCode) { /* handle error */ }
}
const {exitCode, stderr} = await new DotnetInstallScript()
// arguments do not convert automatically due the ambiguity in casing between some (such as -JSonFile and --jsonfile)
.useArguments(IS_WINDOWS ? '-Version' : '--version', '6.0.100')
.execute()
The script preparation is conducted upon calling the constructor and all platform-specific arguments are inserted by default
Description:
Refactoring was conducted only for installer.ts module. The most significant changes are in
DotnetCoreInstaller
class:DotnetInstallDir
classDotnetInstallScript
class, which now allows to invoke install-script multiple times and conditionally apply script arguments.Example of
DotnetInstallScript
class usage (just an example code, not how it is actually set here)The script preparation is conducted upon calling the constructor and all platform-specific arguments are inserted by default
Related issue: Related but does not solve https://github.com/actions/setup-dotnet/issues/387, just conducts necessary preparations for further fix. Should be treated as general refactoring.
Check list: