mirror of
https://github.com/actions/setup-dotnet.git
synced 2025-08-20 07:35:10 +00:00
Merge remote-tracking branch 'origin/main' into sxs-with-fallback
This commit is contained in:
commit
277403db88
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a bug report
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
<!--
|
||||
* Please share short description of the problem
|
||||
-->
|
||||
|
||||
### Details
|
||||
|
||||
<!--
|
||||
* Include the relevant yaml, platform, and dotnet versions in use
|
||||
* If an error occurred on a public action, please share a link
|
||||
* Include any error messages received in text (search does not work for images)
|
||||
* Was this a regression from previous behavior?
|
||||
-->
|
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: .NET issues
|
||||
url: https://github.com/dotnet/runtime#filing-issues
|
||||
about: Issues with the runtime, class libraries, frameworks, and SDK should be addressed directly with the .NET team. Documentation on filing issues can be found here.
|
2
.github/workflows/workflow.yml
vendored
2
.github/workflows/workflow.yml
vendored
@ -4,7 +4,7 @@ on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- releases/*
|
||||
|
||||
jobs:
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
# dev dependencies are *not* checked in
|
||||
global.json
|
||||
lib/
|
||||
node_modules/
|
||||
__tests__/runner/*
|
||||
|
33
README.md
33
README.md
@ -17,10 +17,10 @@ See [action.yml](action.yml)
|
||||
Basic:
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/checkout@main
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '3.1.201' # SDK Version to use.
|
||||
dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel
|
||||
- run: dotnet build <my project>
|
||||
```
|
||||
|
||||
@ -31,10 +31,10 @@ jobs:
|
||||
runs-on: ubuntu-16.04
|
||||
strategy:
|
||||
matrix:
|
||||
dotnet: [ '2.2.103', '3.1.201' ]
|
||||
dotnet: [ '2.2.103', '3.0', '3.1.x' ]
|
||||
name: Dotnet ${{ matrix.dotnet }} sample
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/checkout@main
|
||||
- name: Setup dotnet
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
@ -45,11 +45,11 @@ jobs:
|
||||
Authentication for nuget feeds:
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/checkout@main
|
||||
# Authenticates packages to push to GPR
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '3.1.201' # SDK Version to use.
|
||||
dotnet-version: '3.1.x' # SDK Version to use.
|
||||
source-url: https://nuget.pkg.github.com/<owner>/index.json
|
||||
env:
|
||||
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
@ -69,6 +69,27 @@ steps:
|
||||
run: dotnet nuget push <my project>/bin/Release/*.nupkg
|
||||
```
|
||||
|
||||
## Environment Variables to use with dotnet
|
||||
|
||||
Some environment variables may be necessary for your particular case or to improve logging. Some examples are listed below, but the full list with complete details can be found here: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet#environment-variables
|
||||
|
||||
- DOTNET_NOLOGO - removes logo and telemetry message from first run of dotnet cli (default: false)
|
||||
- DOTNET_CLI_TELEMETRY_OPTOUT - opt-out of telemetry being sent to Microsoft (default: false)
|
||||
- DOTNET_MULTILEVEL_LOOKUP - configures whether the global install location is used as a fall-back (default: true)
|
||||
|
||||
Example usage:
|
||||
```
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DOTNET_NOLOGO: true
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '3.1.100' # SDK Version to use.
|
||||
```
|
||||
|
||||
# License
|
||||
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||
|
23
__tests__/csc.test.ts
Normal file
23
__tests__/csc.test.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import fs = require('fs');
|
||||
|
||||
describe('csc tests', () => {
|
||||
it('Valid regular expression', async () => {
|
||||
var cscFile = require('../.github/csc.json');
|
||||
var regex = cscFile['problemMatcher'][0]['pattern'][0]['regexp'];
|
||||
|
||||
console.log(regex);
|
||||
var re = new RegExp(regex);
|
||||
|
||||
// Ideally we would verify that this
|
||||
var stringsToMatch = [
|
||||
'Program.cs(10,79): error CS1002: ; expected [/Users/zacharyeisinger/Documents/repo/setup-dotnet/__tests__/sample-broken-csproj/sample.csproj]',
|
||||
"S:\\Msbuild\\src\\Build\\Evaluation\\ExpressionShredder.cs(33,7): error CS1003: Syntax error, ',' expected [S:\\msbuild\\src\\Build\\Microsoft.Build.csproj > Properties:prop]"
|
||||
];
|
||||
|
||||
stringsToMatch.forEach(string => {
|
||||
var matchStr = string.match(re);
|
||||
console.log(matchStr);
|
||||
expect(matchStr).toEqual(expect.anything());
|
||||
});
|
||||
}, 10000);
|
||||
});
|
@ -3,13 +3,73 @@ import fs = require('fs');
|
||||
import path = require('path');
|
||||
import hc = require('@actions/http-client');
|
||||
|
||||
import each from 'jest-each';
|
||||
|
||||
const toolDir = path.join(__dirname, 'runner', 'tools');
|
||||
const tempDir = path.join(__dirname, 'runner', 'temp');
|
||||
|
||||
process.env['RUNNER_TOOL_CACHE'] = toolDir;
|
||||
process.env['RUNNER_TEMP'] = tempDir;
|
||||
import * as setup from '../src/setup-dotnet';
|
||||
import * as installer from '../src/installer';
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
|
||||
describe('version tests', () => {
|
||||
each(['3.1.999', '3.1.101-preview.3']).test(
|
||||
"Exact version '%s' should be the same",
|
||||
vers => {
|
||||
let versInfo = new installer.DotNetVersionInfo(vers);
|
||||
|
||||
expect(versInfo.isExactVersion()).toBe(true);
|
||||
expect(versInfo.version()).toBe(vers);
|
||||
}
|
||||
);
|
||||
|
||||
each([['3.1.x', '3.1'], ['1.1.*', '1.1'], ['2.0', '2.0']]).test(
|
||||
"Generic version '%s' should be '%s'",
|
||||
(vers, resVers) => {
|
||||
let versInfo = new installer.DotNetVersionInfo(vers);
|
||||
|
||||
expect(versInfo.isExactVersion()).toBe(false);
|
||||
expect(versInfo.version()).toBe(resVers);
|
||||
}
|
||||
);
|
||||
|
||||
each([
|
||||
'',
|
||||
'.',
|
||||
'..',
|
||||
' . ',
|
||||
'. ',
|
||||
' .',
|
||||
' . . ',
|
||||
' .. ',
|
||||
' . ',
|
||||
'-1.-1',
|
||||
'-1',
|
||||
'-1.-1.-1',
|
||||
'..3',
|
||||
'1..3',
|
||||
'1..',
|
||||
'.2.3',
|
||||
'.2.x',
|
||||
'1',
|
||||
'2.x',
|
||||
'*.*.1',
|
||||
'*.1',
|
||||
'*.',
|
||||
'1.2.',
|
||||
'1.2.-abc',
|
||||
'a.b',
|
||||
'a.b.c',
|
||||
'a.b.c-preview',
|
||||
' 0 . 1 . 2 '
|
||||
]).test("Malformed version '%s' should throw", vers => {
|
||||
expect(() => new installer.DotNetVersionInfo(vers)).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('installer tests', () => {
|
||||
beforeAll(async () => {
|
||||
process.env.RUNNER_TOOL_CACHE = toolDir;
|
||||
@ -28,6 +88,51 @@ describe('installer tests', () => {
|
||||
}
|
||||
}, 30000);
|
||||
|
||||
it('Resolving a normal generic version works', async () => {
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller('3.1.x');
|
||||
let versInfo = await dotnetInstaller.resolveInfos(
|
||||
['win-x64'],
|
||||
new installer.DotNetVersionInfo('3.1.x')
|
||||
);
|
||||
|
||||
expect(versInfo.resolvedVersion.startsWith('3.1.'));
|
||||
}, 100000);
|
||||
|
||||
it('Resolving a nonexistent generic version fails', async () => {
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller('999.1.x');
|
||||
try {
|
||||
await dotnetInstaller.resolveInfos(
|
||||
['win-x64'],
|
||||
new installer.DotNetVersionInfo('999.1.x')
|
||||
);
|
||||
fail();
|
||||
} catch {
|
||||
expect(true);
|
||||
}
|
||||
}, 100000);
|
||||
|
||||
it('Resolving a exact stable version works', async () => {
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller('3.1.201');
|
||||
let versInfo = await dotnetInstaller.resolveInfos(
|
||||
['win-x64'],
|
||||
new installer.DotNetVersionInfo('3.1.201')
|
||||
);
|
||||
|
||||
expect(versInfo.resolvedVersion).toBe('3.1.201');
|
||||
}, 100000);
|
||||
|
||||
it('Resolving a exact preview version works', async () => {
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||
'5.0.0-preview.4'
|
||||
);
|
||||
let versInfo = await dotnetInstaller.resolveInfos(
|
||||
['win-x64'],
|
||||
new installer.DotNetVersionInfo('5.0.0-preview.4')
|
||||
);
|
||||
|
||||
expect(versInfo.resolvedVersion).toBe('5.0.0-preview.4');
|
||||
}, 100000);
|
||||
|
||||
it('Acquires version of dotnet if no matching version is installed', async () => {
|
||||
await getDotnet('3.1.201');
|
||||
expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).toBe(true);
|
||||
@ -36,6 +141,25 @@ describe('installer tests', () => {
|
||||
} else {
|
||||
expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
|
||||
}
|
||||
}, 400000); //This needs some time to download on "slower" internet connections
|
||||
|
||||
it('Acquires version of dotnet if no matching version is installed', async () => {
|
||||
const dotnetDir = path.join(toolDir, 'dncs', '2.2.105', os.arch());
|
||||
|
||||
const globalJsonPath = path.join(process.cwd(), 'global.json');
|
||||
const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version": "2.2.105"${os.EOL}}${os.EOL}}`;
|
||||
if (!fs.existsSync(globalJsonPath)) {
|
||||
fs.writeFileSync(globalJsonPath, jsonContents);
|
||||
}
|
||||
await setup.run();
|
||||
|
||||
expect(fs.existsSync(`${dotnetDir}.complete`)).toBe(true);
|
||||
if (IS_WINDOWS) {
|
||||
expect(fs.existsSync(path.join(dotnetDir, 'dotnet.exe'))).toBe(true);
|
||||
} else {
|
||||
expect(fs.existsSync(path.join(dotnetDir, 'dotnet'))).toBe(true);
|
||||
}
|
||||
fs.unlinkSync(globalJsonPath);
|
||||
}, 100000);
|
||||
|
||||
it('Throws if no location contains correct dotnet version', async () => {
|
||||
|
@ -4,9 +4,9 @@ author: 'GitHub'
|
||||
branding:
|
||||
icon: play
|
||||
color: green
|
||||
inputs:
|
||||
inputs:
|
||||
dotnet-version:
|
||||
description: 'SDK version to use. Example: 2.2.104'
|
||||
description: 'SDK version to use. Examples: 2.2.104, 3.1, 3.1.x'
|
||||
source-url:
|
||||
description: 'Optional package source for which to set up authentication. Will consult any existing NuGet.config in the root of the repo and provide a temporary NuGet.config using the NUGET_AUTH_TOKEN environment variable as a ClearTextPassword'
|
||||
owner:
|
||||
|
1847
dist/index.js
vendored
1847
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,24 @@
|
||||
# Contributors
|
||||
|
||||
Thank you for contributing! This action is targetted around setting up the dotnet cli and related sdks for GitHub actions. As part of that we use proxy settings (for self-hosted runners) and set-up nuget authentication for private feeds.
|
||||
|
||||
# Checkin
|
||||
If you would like to contribute there are a few things to consider:
|
||||
|
||||
- Do checkin source (src)
|
||||
- Do checkin build output (lib)
|
||||
- Do checkin runtime node_modules
|
||||
- Do not checkin
|
||||
## Commands to use
|
||||
|
||||
# Adding a dev dependency
|
||||
- npm run build - Compiles the action into a single js file at dist/index.js (Please check in the changes made by this command)
|
||||
- npm run test - Runs all tests under __tests__
|
||||
- npm run format - Runs formatting required to pass the lint test (Please check in the changes made by this command)
|
||||
- npm run update-installers - Updates the install-dotnet scripts in externals (Please check in the changes made by this command)
|
||||
|
||||
Remember to update .gitignore.
|
||||
## To check in or not to check in
|
||||
|
||||
# Updating toolkit dependency
|
||||
- Do check in source (src)
|
||||
- Do check in index file (dist)
|
||||
- Do check in updates to install-dotnet scripts (externals)
|
||||
- Do not check in build output (lib)
|
||||
- Do not check in runtime (node_modules)
|
||||
|
||||
Until released publically, update tgz packages in toolkit
|
||||
## Writing tests
|
||||
|
||||
With any contribution please take time to consider how this can be tested to maintain high quality. Current tests can be found in the folder __tests__ for examples.
|
||||
|
1574
externals/install-dotnet.ps1
vendored
1574
externals/install-dotnet.ps1
vendored
File diff suppressed because it is too large
Load Diff
7722
package-lock.json
generated
7722
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
25
package.json
25
package.json
@ -11,6 +11,13 @@
|
||||
"test": "jest",
|
||||
"update-installers": "nwget https://dot.net/v1/dotnet-install.ps1 -O externals/install-dotnet.ps1 && nwget https://dot.net/v1/dotnet-install.sh -O externals/install-dotnet.sh"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"//": "Tests are not run at push time since they can take 2-4 minutes to complete",
|
||||
"pre-commit": "npm run format",
|
||||
"pre-push": "npm run format-check"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/actions/setup-dotnet.git"
|
||||
@ -26,21 +33,23 @@
|
||||
"@actions/core": "^1.2.2",
|
||||
"@actions/exec": "^1.0.3",
|
||||
"@actions/github": "^1.1.0",
|
||||
"@actions/http-client": "^1.0.6",
|
||||
"@actions/http-client": "^1.0.8",
|
||||
"@actions/io": "^1.0.2",
|
||||
"fast-xml-parser": "^3.15.1",
|
||||
"semver": "^6.3.0",
|
||||
"xmlbuilder": "^13.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^24.0.13",
|
||||
"@types/node": "^12.0.4",
|
||||
"@types/jest": "^25.2.3",
|
||||
"@types/node": "^12.12.42",
|
||||
"@types/semver": "^6.0.0",
|
||||
"@zeit/ncc": "^0.21.0",
|
||||
"jest": "^24.9.0",
|
||||
"jest-circus": "^24.7.1",
|
||||
"husky": "^4.2.5",
|
||||
"jest": "^26.0.1",
|
||||
"jest-circus": "^26.0.1",
|
||||
"prettier": "^1.17.1",
|
||||
"ts-jest": "^24.0.2",
|
||||
"typescript": "^3.5.1",
|
||||
"typed-rest-client": "^1.5.0",
|
||||
"ts-jest": "^26.0.0",
|
||||
"typescript": "^3.9.3",
|
||||
"wget-improved": "^3.0.2"
|
||||
},
|
||||
"jest": {
|
||||
|
111
src/installer.ts
111
src/installer.ts
@ -1,16 +1,115 @@
|
||||
// Load tempDirectory before it gets wiped by tool-cache
|
||||
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as io from '@actions/io';
|
||||
import {chmodSync} from 'fs';
|
||||
import * as path from 'path';
|
||||
import {ExecOptions} from '@actions/exec/lib/interfaces';
|
||||
import * as semver from 'semver';
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
|
||||
if (!tempDirectory) {
|
||||
let baseLocation;
|
||||
if (IS_WINDOWS) {
|
||||
// On windows use the USERPROFILE env variable
|
||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
||||
} else {
|
||||
if (process.platform === 'darwin') {
|
||||
baseLocation = '/Users';
|
||||
} else {
|
||||
baseLocation = '/home';
|
||||
}
|
||||
}
|
||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the inputted version information
|
||||
*/
|
||||
export class DotNetVersionInfo {
|
||||
private fullversion: string;
|
||||
private isExactVersionSet: boolean = false;
|
||||
|
||||
constructor(version: string) {
|
||||
// Check for exact match
|
||||
if (semver.valid(semver.clean(version) || '') != null) {
|
||||
this.fullversion = semver.clean(version) as string;
|
||||
this.isExactVersionSet = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//Note: No support for previews when using generic
|
||||
let parts: string[] = version.split('.');
|
||||
|
||||
if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat();
|
||||
|
||||
if (parts.length == 3 && parts[2] !== 'x' && parts[2] !== '*') {
|
||||
this.throwInvalidVersionFormat();
|
||||
}
|
||||
|
||||
let major = this.getVersionNumberOrThrow(parts[0]);
|
||||
let minor = this.getVersionNumberOrThrow(parts[1]);
|
||||
|
||||
this.fullversion = major + '.' + minor;
|
||||
}
|
||||
|
||||
private getVersionNumberOrThrow(input: string): number {
|
||||
try {
|
||||
if (!input || input.trim() === '') this.throwInvalidVersionFormat();
|
||||
|
||||
let number = Number(input);
|
||||
|
||||
if (Number.isNaN(number) || number < 0) this.throwInvalidVersionFormat();
|
||||
|
||||
return number;
|
||||
} catch {
|
||||
this.throwInvalidVersionFormat();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private throwInvalidVersionFormat() {
|
||||
throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*';
|
||||
}
|
||||
|
||||
/**
|
||||
* If true exacatly one version should be resolved
|
||||
*/
|
||||
public isExactVersion(): boolean {
|
||||
return this.isExactVersionSet;
|
||||
}
|
||||
|
||||
public version(): string {
|
||||
return this.fullversion;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a resolved version from the Web-Api
|
||||
*/
|
||||
class ResolvedVersionInfo {
|
||||
downloadUrls: string[];
|
||||
resolvedVersion: string;
|
||||
|
||||
constructor(downloadUrls: string[], resolvedVersion: string) {
|
||||
if (downloadUrls.length === 0) {
|
||||
throw 'DownloadUrls can not be empty';
|
||||
}
|
||||
|
||||
if (!resolvedVersion) {
|
||||
throw 'Resolved version is invalid';
|
||||
}
|
||||
|
||||
this.downloadUrls = downloadUrls;
|
||||
this.resolvedVersion = resolvedVersion;
|
||||
}
|
||||
}
|
||||
|
||||
export class DotnetCoreInstaller {
|
||||
constructor(version: string = '', jsonfile: string = '') {
|
||||
constructor(version: string) {
|
||||
this.version = version;
|
||||
this.jsonfile = jsonfile;
|
||||
}
|
||||
|
||||
public async installDotnet() {
|
||||
@ -24,7 +123,6 @@ export class DotnetCoreInstaller {
|
||||
envVariables[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_WINDOWS) {
|
||||
let escapedScript = path
|
||||
.join(__dirname, '..', 'externals', 'install-dotnet.ps1')
|
||||
@ -33,9 +131,6 @@ export class DotnetCoreInstaller {
|
||||
if (this.version) {
|
||||
command += ` -Version ${this.version}`;
|
||||
}
|
||||
if (this.jsonfile) {
|
||||
command += ` -jsonfile ${this.jsonfile}`;
|
||||
}
|
||||
|
||||
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
||||
const powershellPath = await io.which('powershell', true);
|
||||
@ -75,9 +170,6 @@ export class DotnetCoreInstaller {
|
||||
if (this.version) {
|
||||
scriptArguments.push('--version', this.version);
|
||||
}
|
||||
if (this.jsonfile) {
|
||||
scriptArguments.push('--jsonfile', this.jsonfile);
|
||||
}
|
||||
|
||||
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
||||
resultCode = await exec.exec(`"${scriptPath}"`, scriptArguments, {
|
||||
@ -96,5 +188,4 @@ export class DotnetCoreInstaller {
|
||||
}
|
||||
|
||||
private version: string;
|
||||
private jsonfile: string;
|
||||
}
|
||||
|
@ -7,25 +7,30 @@ import * as auth from './authutil';
|
||||
export async function run() {
|
||||
try {
|
||||
//
|
||||
// Version is optional. If supplied, install / use from the tool cache
|
||||
// If not supplied then task is still used to setup proxy, auth, etc...
|
||||
// dotnet-version is optional, but needs to be provided for most use cases.
|
||||
// If supplied, install / use from the tool cache.
|
||||
// If not supplied, look for version in ./global.json.
|
||||
// If a valid version still can't be identified, nothing will be installed.
|
||||
// Proxy, auth, (etc) are still set up, even if no version is identified
|
||||
//
|
||||
let version: string = core.getInput('dotnet-version');
|
||||
let version = core.getInput('dotnet-version');
|
||||
if (!version) {
|
||||
// Try to fall back to global.json
|
||||
core.debug('No version found, trying to find version from global.json');
|
||||
const globalJsonPath = path.join(process.cwd(), 'global.json');
|
||||
if (fs.existsSync(globalJsonPath)) {
|
||||
const globalJson = JSON.parse(
|
||||
fs.readFileSync(globalJsonPath, {encoding: 'utf8'})
|
||||
);
|
||||
if (globalJson.sdk && globalJson.sdk.version) {
|
||||
version = globalJson.sdk.version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version) {
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(version);
|
||||
await dotnetInstaller.installDotnet();
|
||||
} else {
|
||||
// Try to fall back to global.json
|
||||
core.debug('No version found, falling back to global.json');
|
||||
const globalJsonPath = path.join(process.cwd(), 'global.json');
|
||||
if (fs.existsSync(globalJsonPath)) {
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||
undefined,
|
||||
globalJsonPath
|
||||
);
|
||||
await dotnetInstaller.installDotnet();
|
||||
}
|
||||
}
|
||||
|
||||
const sourceUrl: string = core.getInput('source-url');
|
||||
@ -34,8 +39,6 @@ export async function run() {
|
||||
auth.configAuthentication(sourceUrl, configFile);
|
||||
}
|
||||
|
||||
// TODO: setup proxy from runner proxy config
|
||||
|
||||
const matchersPath = path.join(__dirname, '..', '.github');
|
||||
console.log(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`);
|
||||
} catch (error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user