Skip to content

Conversation

@nikolai-laevskii
Copy link
Contributor

Description:

  • Updated installers
  • Refactored DotnetCoreInstaller

Refactoring was conducted only for installer.ts module. The most significant changes are in DotnetCoreInstaller class:

  1. Logic related to the install dir was separated and moved to simple static DotnetInstallDir class
  2. 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

Related issue:
Related but does not solve #387, just conducts necessary preparations for further fix. Should be treated as general refactoring.

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

@nikolai-laevskii nikolai-laevskii requested a review from a team as a code owner June 2, 2023 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants