@@ -17,6 +17,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
17
17
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
18
18
const core = __importStar ( require ( "@actions/core" ) ) ;
19
19
const installer = __importStar ( require ( "./installer" ) ) ;
20
+ const fs = __importStar ( require ( "fs" ) ) ;
20
21
const path = __importStar ( require ( "path" ) ) ;
21
22
function run ( ) {
22
23
return __awaiter ( this , void 0 , void 0 , function * ( ) {
@@ -25,7 +26,17 @@ function run() {
25
26
// Version is optional. If supplied, install / use from the tool cache
26
27
// If not supplied then task is still used to setup proxy, auth, etc...
27
28
//
28
- const version = core . getInput ( 'version' ) ;
29
+ let version = core . getInput ( 'version' ) ;
30
+ if ( ! version ) {
31
+ // Try to fall back to global.json
32
+ const globalJsonPath = path . join ( process . cwd ( ) , 'global.json' ) ;
33
+ if ( fs . existsSync ( globalJsonPath ) ) {
34
+ const globalJson = JSON . parse ( fs . readFileSync ( globalJsonPath , { encoding : 'utf8' } ) ) ;
35
+ if ( globalJson . sdk && globalJson . sdk . version ) {
36
+ version = globalJson . sdk . version ;
37
+ }
38
+ }
39
+ }
29
40
if ( version ) {
30
41
const dotnetInstaller = new installer . DotnetCoreInstaller ( version ) ;
31
42
yield dotnetInstaller . installDotnet ( ) ;
0 commit comments