import * as core from '@actions/core' ; import * as installer from './installer' ; import * as fs from 'fs' ; import * as path from 'path' ; import * as auth from './authutil' ; export async function run ( ) { try { let versions = core . getMultilineInput ( 'dotnet-version' ) ; if ( ! versions . length ) { core . debug ( 'No version found, trying to find version from global.json' ) ; const globalJsonPath = path . join ( process . cwd ( ) , 'global.json' ) ; if ( fs . existsSync ( globalJsonPath ) ) { versions . push ( getVersionFromGlobalJson ( globalJsonPath ) ) ; } } if ( versions . length ) { const includePrerelease = ( core . getInput ( 'include-prerelease' ) || 'false' ) . toLowerCase ( ) === 'true' ; let dotnetInstaller ! ; for ( const version of new Set < string > ( versions ) ) { dotnetInstaller = new installer . DotnetCoreInstaller ( version , includePrerelease ) ; await dotnetInstaller . installDotnet ( ) ; } installer . DotnetCoreInstaller . addToPath ( ) ; } const sourceUrl = core . getInput ( 'source-url' ) ; const configFile = core . getInput ( 'config-file' ) ; if ( sourceUrl ) { auth . configAuthentication ( sourceUrl , configFile ) ; } const matchersPath = path . join ( __dirname , '..' , '.github' ) ; console . log ( `##[add-matcher]${ path . join ( matchersPath , 'csc.json' ) }` ) ; } catch ( error ) { core . setFailed ( error . message ) ; } } function getVersionFromGlobalJson ( globalJsonPath ) { let version = '' ; const globalJson = JSON . parse ( fs . readFileSync ( globalJsonPath , { encoding : 'utf8' } ) . trim ( ) ) ; if ( globalJson . sdk && globalJson . sdk . version ) { version = globalJson . sdk . version ; const rollForward = globalJson . sdk . rollForward ; if ( rollForward && rollForward === 'latestFeature' ) { const [ major , minor ] = version . split ( '.' ) ; version = `${ major }.${ minor }` ; } } return version ; } run ( ) ;