mirror of
https://github.com/actions/setup-dotnet.git
synced 2024-11-25 12:53:06 +07:00
Add feature of prefering already installed versions
This commit is contained in:
parent
faa2990a1a
commit
e4db8cc43a
22
.github/workflows/test-dotnet.yml
vendored
22
.github/workflows/test-dotnet.yml
vendored
@ -41,3 +41,25 @@ jobs:
|
|||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
__tests__/verify-dotnet.ps1 -Patterns "^${{ matrix.dotnet-version }}"
|
__tests__/verify-dotnet.ps1 -Patterns "^${{ matrix.dotnet-version }}"
|
||||||
|
setup-versions-prefer-installed:
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
dotnet-version: ['2.1', '2.2', '3.0', '3.1', '5.0', '6.0', '7.0', '8.0']
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Clear toolcache
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
|
- name: Setup dotnet ${{ matrix.dotnet-version }}
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
dotnet-version: ${{ matrix.dotnet-version }}
|
||||||
|
prefer-installed: true
|
||||||
|
- name: Verify installed version
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
__tests__/verify-dotnet.ps1 -Patterns "^${{ matrix.dotnet-version }}"
|
||||||
|
@ -9,6 +9,10 @@ inputs:
|
|||||||
description: 'Optional SDK version(s) to use. If not provided, will install global.json version when available. Examples: 2.2.104, 3.1, 3.1.x, 3.x, 6.0.2xx'
|
description: 'Optional SDK version(s) to use. If not provided, will install global.json version when available. Examples: 2.2.104, 3.1, 3.1.x, 3.x, 6.0.2xx'
|
||||||
dotnet-quality:
|
dotnet-quality:
|
||||||
description: 'Optional quality of the build. The possible values are: daily, signed, validated, preview, ga.'
|
description: 'Optional quality of the build. The possible values are: daily, signed, validated, preview, ga.'
|
||||||
|
prefer-installed:
|
||||||
|
description: 'Optional flag to prefer an already installed version of the SDK (when partial version syntax is used). If not provided, latest version with specified quality will be installed.'
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
global-json-file:
|
global-json-file:
|
||||||
description: 'Optional global.json location, if your global.json isn''t located in the root of the repo.'
|
description: 'Optional global.json location, if your global.json isn''t located in the root of the repo.'
|
||||||
source-url:
|
source-url:
|
||||||
|
426
dist/cache-save/index.js
vendored
426
dist/cache-save/index.js
vendored
@ -58523,91 +58523,91 @@ exports["default"] = _default;
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
}
|
}
|
||||||
Object.defineProperty(o, k2, desc);
|
Object.defineProperty(o, k2, desc);
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.run = void 0;
|
exports.run = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
const node_fs_1 = __importDefault(__nccwpck_require__(7561));
|
const node_fs_1 = __importDefault(__nccwpck_require__(7561));
|
||||||
const cache_utils_1 = __nccwpck_require__(1678);
|
const cache_utils_1 = __nccwpck_require__(1678);
|
||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||||
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
||||||
// throw an uncaught exception. Instead of failing this action, just warn.
|
// throw an uncaught exception. Instead of failing this action, just warn.
|
||||||
process.on('uncaughtException', e => {
|
process.on('uncaughtException', e => {
|
||||||
const warningPrefix = '[warning]';
|
const warningPrefix = '[warning]';
|
||||||
core.info(`${warningPrefix}${e.message}`);
|
core.info(`${warningPrefix}${e.message}`);
|
||||||
});
|
});
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
if (core.getBooleanInput('cache')) {
|
if (core.getBooleanInput('cache')) {
|
||||||
yield cachePackages();
|
yield cachePackages();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.run = run;
|
exports.run = run;
|
||||||
const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () {
|
const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const state = core.getState(constants_1.State.CacheMatchedKey);
|
const state = core.getState(constants_1.State.CacheMatchedKey);
|
||||||
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
|
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
|
||||||
if (!primaryKey) {
|
if (!primaryKey) {
|
||||||
core.info('Primary key was not generated, not saving cache.');
|
core.info('Primary key was not generated, not saving cache.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { 'global-packages': cachePath } = yield (0, cache_utils_1.getNuGetFolderPath)();
|
const { 'global-packages': cachePath } = yield (0, cache_utils_1.getNuGetFolderPath)();
|
||||||
if (!node_fs_1.default.existsSync(cachePath)) {
|
if (!node_fs_1.default.existsSync(cachePath)) {
|
||||||
throw new Error(`Cache folder path is retrieved for .NET CLI but doesn't exist on disk: ${cachePath}`);
|
throw new Error(`Cache folder path is retrieved for .NET CLI but doesn't exist on disk: ${cachePath}`);
|
||||||
}
|
}
|
||||||
if (primaryKey === state) {
|
if (primaryKey === state) {
|
||||||
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
|
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const cacheId = yield cache.saveCache([cachePath], primaryKey);
|
const cacheId = yield cache.saveCache([cachePath], primaryKey);
|
||||||
if (cacheId == -1) {
|
if (cacheId == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
core.info(`Cache saved with the key: ${primaryKey}`);
|
core.info(`Cache saved with the key: ${primaryKey}`);
|
||||||
});
|
});
|
||||||
run();
|
run();
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -58616,114 +58616,114 @@ run();
|
|||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
}
|
}
|
||||||
Object.defineProperty(o, k2, desc);
|
Object.defineProperty(o, k2, desc);
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.isCacheFeatureAvailable = exports.getNuGetFolderPath = void 0;
|
exports.isCacheFeatureAvailable = exports.getNuGetFolderPath = void 0;
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const exec = __importStar(__nccwpck_require__(1514));
|
const exec = __importStar(__nccwpck_require__(1514));
|
||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
/**
|
/**
|
||||||
* Get NuGet global packages, cache, and temp folders from .NET CLI.
|
* Get NuGet global packages, cache, and temp folders from .NET CLI.
|
||||||
* @returns (Folder Name)-(Path) mappings
|
* @returns (Folder Name)-(Path) mappings
|
||||||
* @see https://docs.microsoft.com/nuget/consume-packages/managing-the-global-packages-and-cache-folders
|
* @see https://docs.microsoft.com/nuget/consume-packages/managing-the-global-packages-and-cache-folders
|
||||||
* @example
|
* @example
|
||||||
* Windows
|
* Windows
|
||||||
* ```json
|
* ```json
|
||||||
* {
|
* {
|
||||||
* "http-cache": "C:\\Users\\user1\\AppData\\Local\\NuGet\\v3-cache",
|
* "http-cache": "C:\\Users\\user1\\AppData\\Local\\NuGet\\v3-cache",
|
||||||
* "global-packages": "C:\\Users\\user1\\.nuget\\packages\\",
|
* "global-packages": "C:\\Users\\user1\\.nuget\\packages\\",
|
||||||
* "temp": "C:\\Users\\user1\\AppData\\Local\\Temp\\NuGetScratch",
|
* "temp": "C:\\Users\\user1\\AppData\\Local\\Temp\\NuGetScratch",
|
||||||
* "plugins-cache": "C:\\Users\\user1\\AppData\\Local\\NuGet\\plugins-cache"
|
* "plugins-cache": "C:\\Users\\user1\\AppData\\Local\\NuGet\\plugins-cache"
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* Mac/Linux
|
* Mac/Linux
|
||||||
* ```json
|
* ```json
|
||||||
* {
|
* {
|
||||||
* "http-cache": "/home/user1/.local/share/NuGet/v3-cache",
|
* "http-cache": "/home/user1/.local/share/NuGet/v3-cache",
|
||||||
* "global-packages": "/home/user1/.nuget/packages/",
|
* "global-packages": "/home/user1/.nuget/packages/",
|
||||||
* "temp": "/tmp/NuGetScratch",
|
* "temp": "/tmp/NuGetScratch",
|
||||||
* "plugins-cache": "/home/user1/.local/share/NuGet/plugins-cache"
|
* "plugins-cache": "/home/user1/.local/share/NuGet/plugins-cache"
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
const getNuGetFolderPath = () => __awaiter(void 0, void 0, void 0, function* () {
|
const getNuGetFolderPath = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const { stdout, stderr, exitCode } = yield exec.getExecOutput(constants_1.cliCommand, undefined, { ignoreReturnCode: true, silent: true });
|
const { stdout, stderr, exitCode } = yield exec.getExecOutput(constants_1.cliCommand, undefined, { ignoreReturnCode: true, silent: true });
|
||||||
if (exitCode) {
|
if (exitCode) {
|
||||||
throw new Error(!stderr.trim()
|
throw new Error(!stderr.trim()
|
||||||
? `The '${constants_1.cliCommand}' command failed with exit code: ${exitCode}`
|
? `The '${constants_1.cliCommand}' command failed with exit code: ${exitCode}`
|
||||||
: stderr);
|
: stderr);
|
||||||
}
|
}
|
||||||
const result = {
|
const result = {
|
||||||
'http-cache': '',
|
'http-cache': '',
|
||||||
'global-packages': '',
|
'global-packages': '',
|
||||||
temp: '',
|
temp: '',
|
||||||
'plugins-cache': ''
|
'plugins-cache': ''
|
||||||
};
|
};
|
||||||
const regex = /(?:^|\s)(?<key>[a-z-]+): (?<path>.+[/\\].+)$/gm;
|
const regex = /(?:^|\s)(?<key>[a-z-]+): (?<path>.+[/\\].+)$/gm;
|
||||||
let match;
|
let match;
|
||||||
while ((match = regex.exec(stdout)) !== null) {
|
while ((match = regex.exec(stdout)) !== null) {
|
||||||
const key = match.groups.key;
|
const key = match.groups.key;
|
||||||
if (key in result) {
|
if (key in result) {
|
||||||
result[key] = match.groups.path;
|
result[key] = match.groups.path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
exports.getNuGetFolderPath = getNuGetFolderPath;
|
exports.getNuGetFolderPath = getNuGetFolderPath;
|
||||||
function isCacheFeatureAvailable() {
|
function isCacheFeatureAvailable() {
|
||||||
if (cache.isFeatureAvailable()) {
|
if (cache.isFeatureAvailable()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (isGhes()) {
|
if (isGhes()) {
|
||||||
core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
|
core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
|
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
||||||
/**
|
/**
|
||||||
* Returns this action runs on GitHub Enterprise Server or not.
|
* Returns this action runs on GitHub Enterprise Server or not.
|
||||||
* (port from https://github.com/actions/toolkit/blob/457303960f03375db6f033e214b9f90d79c3fe5c/packages/cache/src/internal/cacheUtils.ts#L134)
|
* (port from https://github.com/actions/toolkit/blob/457303960f03375db6f033e214b9f90d79c3fe5c/packages/cache/src/internal/cacheUtils.ts#L134)
|
||||||
*/
|
*/
|
||||||
function isGhes() {
|
function isGhes() {
|
||||||
const url = process.env['GITHUB_SERVER_URL'] || 'https://github.com';
|
const url = process.env['GITHUB_SERVER_URL'] || 'https://github.com';
|
||||||
return new URL(url).hostname.toUpperCase() !== 'GITHUB.COM';
|
return new URL(url).hostname.toUpperCase() !== 'GITHUB.COM';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -58732,26 +58732,26 @@ function isGhes() {
|
|||||||
/***/ ((__unused_webpack_module, exports) => {
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.Outputs = exports.State = exports.cliCommand = exports.lockFilePatterns = void 0;
|
exports.Outputs = exports.State = exports.cliCommand = exports.lockFilePatterns = void 0;
|
||||||
/** NuGet lock file patterns */
|
/** NuGet lock file patterns */
|
||||||
exports.lockFilePatterns = ['packages.lock.json'];
|
exports.lockFilePatterns = ['packages.lock.json'];
|
||||||
/**
|
/**
|
||||||
* .NET CLI command to list local NuGet resources.
|
* .NET CLI command to list local NuGet resources.
|
||||||
* @see https://docs.microsoft.com/dotnet/core/tools/dotnet-nuget-locals
|
* @see https://docs.microsoft.com/dotnet/core/tools/dotnet-nuget-locals
|
||||||
*/
|
*/
|
||||||
exports.cliCommand = 'dotnet nuget locals all --list --force-english-output';
|
exports.cliCommand = 'dotnet nuget locals all --list --force-english-output';
|
||||||
var State;
|
var State;
|
||||||
(function (State) {
|
(function (State) {
|
||||||
State["CachePrimaryKey"] = "CACHE_KEY";
|
State["CachePrimaryKey"] = "CACHE_KEY";
|
||||||
State["CacheMatchedKey"] = "CACHE_RESULT";
|
State["CacheMatchedKey"] = "CACHE_RESULT";
|
||||||
})(State = exports.State || (exports.State = {}));
|
})(State = exports.State || (exports.State = {}));
|
||||||
var Outputs;
|
var Outputs;
|
||||||
(function (Outputs) {
|
(function (Outputs) {
|
||||||
Outputs["CacheHit"] = "cache-hit";
|
Outputs["CacheHit"] = "cache-hit";
|
||||||
Outputs["DotnetVersion"] = "dotnet-version";
|
Outputs["DotnetVersion"] = "dotnet-version";
|
||||||
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
99
dist/setup/index.js
vendored
99
dist/setup/index.js
vendored
@ -72745,6 +72745,77 @@ var Outputs;
|
|||||||
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 2971:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.matchVersionToList = exports.listSdks = void 0;
|
||||||
|
const exec = __importStar(__nccwpck_require__(1514));
|
||||||
|
const listSdks = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const { stdout, exitCode } = yield exec.getExecOutput('dotnet', ['--list-sdks'], {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
});
|
||||||
|
if (exitCode) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return (stdout
|
||||||
|
.trim()
|
||||||
|
.split('\n')
|
||||||
|
.map(versionInfo => versionInfo.trim())
|
||||||
|
.map(versionInfo => versionInfo.split(' ')[0])
|
||||||
|
// reverses output so newer versions are first
|
||||||
|
.reverse());
|
||||||
|
});
|
||||||
|
exports.listSdks = listSdks;
|
||||||
|
/**
|
||||||
|
* Function that matches string like that
|
||||||
|
* '3.1', '3.1.x', '3', '3.x', '6.0.4xx' to
|
||||||
|
* correct version number like '3.1.201', '3.1.201', '3.1.201', '3.1.201', '6.0.402'
|
||||||
|
*/
|
||||||
|
const matchVersionToList = (version, versions) => {
|
||||||
|
const versionRegex = new RegExp(`^${version.replace(/x/g, '\\d+')}`);
|
||||||
|
const matchedVersion = versions.find(v => versionRegex.test(v));
|
||||||
|
return matchedVersion;
|
||||||
|
};
|
||||||
|
exports.matchVersionToList = matchVersionToList;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 2574:
|
/***/ 2574:
|
||||||
@ -72799,10 +72870,12 @@ const path_1 = __importDefault(__nccwpck_require__(1017));
|
|||||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||||
const semver_1 = __importDefault(__nccwpck_require__(5911));
|
const semver_1 = __importDefault(__nccwpck_require__(5911));
|
||||||
const utils_1 = __nccwpck_require__(1314);
|
const utils_1 = __nccwpck_require__(1314);
|
||||||
|
const dotnet_utils_1 = __nccwpck_require__(2971);
|
||||||
const QUALITY_INPUT_MINIMAL_MAJOR_TAG = 6;
|
const QUALITY_INPUT_MINIMAL_MAJOR_TAG = 6;
|
||||||
const LATEST_PATCH_SYNTAX_MINIMAL_MAJOR_TAG = 5;
|
const LATEST_PATCH_SYNTAX_MINIMAL_MAJOR_TAG = 5;
|
||||||
class DotnetVersionResolver {
|
class DotnetVersionResolver {
|
||||||
constructor(version) {
|
constructor(version, preferInstalled = false) {
|
||||||
|
this.preferInstalled = preferInstalled;
|
||||||
this.inputVersion = version.trim();
|
this.inputVersion = version.trim();
|
||||||
this.resolvedArgument = { type: '', value: '', qualityFlag: false };
|
this.resolvedArgument = { type: '', value: '', qualityFlag: false };
|
||||||
}
|
}
|
||||||
@ -72813,10 +72886,20 @@ class DotnetVersionResolver {
|
|||||||
}
|
}
|
||||||
if (semver_1.default.valid(this.inputVersion)) {
|
if (semver_1.default.valid(this.inputVersion)) {
|
||||||
this.createVersionArgument();
|
this.createVersionArgument();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
if (!this.preferInstalled) {
|
||||||
yield this.createChannelArgument();
|
yield this.createChannelArgument();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
const requestedVersion = this.inputVersion;
|
||||||
|
const installedVersions = yield (0, dotnet_utils_1.listSdks)();
|
||||||
|
const matchingInstalledVersion = (0, dotnet_utils_1.matchVersionToList)(requestedVersion, installedVersions);
|
||||||
|
if (matchingInstalledVersion === undefined) {
|
||||||
|
this.createChannelArgument();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.createVersionArgument(matchingInstalledVersion);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
isNumericTag(versionTag) {
|
isNumericTag(versionTag) {
|
||||||
@ -72831,9 +72914,9 @@ class DotnetVersionResolver {
|
|||||||
}
|
}
|
||||||
return majorTag ? true : false;
|
return majorTag ? true : false;
|
||||||
}
|
}
|
||||||
createVersionArgument() {
|
createVersionArgument(updatedVersion) {
|
||||||
this.resolvedArgument.type = 'version';
|
this.resolvedArgument.type = 'version';
|
||||||
this.resolvedArgument.value = this.inputVersion;
|
this.resolvedArgument.value = updatedVersion !== null && updatedVersion !== void 0 ? updatedVersion : this.inputVersion;
|
||||||
}
|
}
|
||||||
createChannelArgument() {
|
createChannelArgument() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
@ -72993,13 +73076,14 @@ DotnetInstallDir.dirPath = process.env['DOTNET_INSTALL_DIR']
|
|||||||
? DotnetInstallDir.convertInstallPathToAbsolute(process.env['DOTNET_INSTALL_DIR'])
|
? DotnetInstallDir.convertInstallPathToAbsolute(process.env['DOTNET_INSTALL_DIR'])
|
||||||
: DotnetInstallDir.default[utils_1.PLATFORM];
|
: DotnetInstallDir.default[utils_1.PLATFORM];
|
||||||
class DotnetCoreInstaller {
|
class DotnetCoreInstaller {
|
||||||
constructor(version, quality) {
|
constructor(version, quality, preferInstalled = false) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
|
this.preferInstalled = preferInstalled;
|
||||||
}
|
}
|
||||||
installDotnet() {
|
installDotnet() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const versionResolver = new DotnetVersionResolver(this.version);
|
const versionResolver = new DotnetVersionResolver(this.version, this.preferInstalled);
|
||||||
const dotnetVersion = yield versionResolver.createDotnetVersion();
|
const dotnetVersion = yield versionResolver.createDotnetVersion();
|
||||||
/**
|
/**
|
||||||
* Install dotnet runitme first in order to get
|
* Install dotnet runitme first in order to get
|
||||||
@ -73148,13 +73232,14 @@ function run() {
|
|||||||
}
|
}
|
||||||
if (versions.length) {
|
if (versions.length) {
|
||||||
const quality = core.getInput('dotnet-quality');
|
const quality = core.getInput('dotnet-quality');
|
||||||
|
const preferInstalled = core.getBooleanInput('prefer-installed');
|
||||||
if (quality && !qualityOptions.includes(quality)) {
|
if (quality && !qualityOptions.includes(quality)) {
|
||||||
throw new Error(`Value '${quality}' is not supported for the 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`);
|
throw new Error(`Value '${quality}' is not supported for the 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`);
|
||||||
}
|
}
|
||||||
let dotnetInstaller;
|
let dotnetInstaller;
|
||||||
const uniqueVersions = new Set(versions);
|
const uniqueVersions = new Set(versions);
|
||||||
for (const version of uniqueVersions) {
|
for (const version of uniqueVersions) {
|
||||||
dotnetInstaller = new installer_1.DotnetCoreInstaller(version, quality);
|
dotnetInstaller = new installer_1.DotnetCoreInstaller(version, quality, preferInstalled);
|
||||||
const installedVersion = yield dotnetInstaller.installDotnet();
|
const installedVersion = yield dotnetInstaller.installDotnet();
|
||||||
installedDotnetVersions.push(installedVersion);
|
installedDotnetVersions.push(installedVersion);
|
||||||
}
|
}
|
||||||
|
37
src/dotnet-utils.ts
Normal file
37
src/dotnet-utils.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
|
export const listSdks = async () => {
|
||||||
|
const {stdout, exitCode} = await exec.getExecOutput(
|
||||||
|
'dotnet',
|
||||||
|
['--list-sdks'],
|
||||||
|
{
|
||||||
|
ignoreReturnCode: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (exitCode) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
stdout
|
||||||
|
.trim()
|
||||||
|
.split('\n')
|
||||||
|
.map(versionInfo => versionInfo.trim())
|
||||||
|
.map(versionInfo => versionInfo.split(' ')[0])
|
||||||
|
// reverses output so newer versions are first
|
||||||
|
.reverse()
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that matches string like that
|
||||||
|
* '3.1', '3.1.x', '3', '3.x', '6.0.4xx' to
|
||||||
|
* correct version number like '3.1.201', '3.1.201', '3.1.201', '3.1.201', '6.0.402'
|
||||||
|
*/
|
||||||
|
export const matchVersionToList = (version: string, versions: string[]) => {
|
||||||
|
const versionRegex = new RegExp(`^${version.replace(/x/g, '\\d+')}`);
|
||||||
|
const matchedVersion = versions.find(v => versionRegex.test(v));
|
||||||
|
|
||||||
|
return matchedVersion;
|
||||||
|
};
|
@ -9,6 +9,7 @@ import os from 'os';
|
|||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import {IS_WINDOWS, PLATFORM} from './utils';
|
import {IS_WINDOWS, PLATFORM} from './utils';
|
||||||
import {QualityOptions} from './setup-dotnet';
|
import {QualityOptions} from './setup-dotnet';
|
||||||
|
import {listSdks, matchVersionToList} from './dotnet-utils';
|
||||||
|
|
||||||
export interface DotnetVersion {
|
export interface DotnetVersion {
|
||||||
type: string;
|
type: string;
|
||||||
@ -22,7 +23,7 @@ export class DotnetVersionResolver {
|
|||||||
private inputVersion: string;
|
private inputVersion: string;
|
||||||
private resolvedArgument: DotnetVersion;
|
private resolvedArgument: DotnetVersion;
|
||||||
|
|
||||||
constructor(version: string) {
|
constructor(version: string, private preferInstalled = false) {
|
||||||
this.inputVersion = version.trim();
|
this.inputVersion = version.trim();
|
||||||
this.resolvedArgument = {type: '', value: '', qualityFlag: false};
|
this.resolvedArgument = {type: '', value: '', qualityFlag: false};
|
||||||
}
|
}
|
||||||
@ -33,11 +34,30 @@ export class DotnetVersionResolver {
|
|||||||
`The 'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B, A.B.x, A, A.x, A.B.Cxx`
|
`The 'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B, A.B.x, A, A.x, A.B.Cxx`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (semver.valid(this.inputVersion)) {
|
if (semver.valid(this.inputVersion)) {
|
||||||
this.createVersionArgument();
|
this.createVersionArgument();
|
||||||
} else {
|
return;
|
||||||
await this.createChannelArgument();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.preferInstalled) {
|
||||||
|
await this.createChannelArgument();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestedVersion = this.inputVersion;
|
||||||
|
const installedVersions = await listSdks();
|
||||||
|
const matchingInstalledVersion = matchVersionToList(
|
||||||
|
requestedVersion,
|
||||||
|
installedVersions
|
||||||
|
);
|
||||||
|
|
||||||
|
if (matchingInstalledVersion === undefined) {
|
||||||
|
this.createChannelArgument();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.createVersionArgument(matchingInstalledVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
private isNumericTag(versionTag): boolean {
|
private isNumericTag(versionTag): boolean {
|
||||||
@ -59,9 +79,9 @@ export class DotnetVersionResolver {
|
|||||||
return majorTag ? true : false;
|
return majorTag ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createVersionArgument() {
|
private createVersionArgument(updatedVersion?: string) {
|
||||||
this.resolvedArgument.type = 'version';
|
this.resolvedArgument.type = 'version';
|
||||||
this.resolvedArgument.value = this.inputVersion;
|
this.resolvedArgument.value = updatedVersion ?? this.inputVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async createChannelArgument() {
|
private async createChannelArgument() {
|
||||||
@ -253,10 +273,17 @@ export class DotnetCoreInstaller {
|
|||||||
DotnetInstallDir.setEnvironmentVariable();
|
DotnetInstallDir.setEnvironmentVariable();
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private version: string, private quality: QualityOptions) {}
|
constructor(
|
||||||
|
private version: string,
|
||||||
|
private quality: QualityOptions,
|
||||||
|
private preferInstalled = false
|
||||||
|
) {}
|
||||||
|
|
||||||
public async installDotnet(): Promise<string | null> {
|
public async installDotnet(): Promise<string | null> {
|
||||||
const versionResolver = new DotnetVersionResolver(this.version);
|
const versionResolver = new DotnetVersionResolver(
|
||||||
|
this.version,
|
||||||
|
this.preferInstalled
|
||||||
|
);
|
||||||
const dotnetVersion = await versionResolver.createDotnetVersion();
|
const dotnetVersion = await versionResolver.createDotnetVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,6 +59,7 @@ export async function run() {
|
|||||||
|
|
||||||
if (versions.length) {
|
if (versions.length) {
|
||||||
const quality = core.getInput('dotnet-quality') as QualityOptions;
|
const quality = core.getInput('dotnet-quality') as QualityOptions;
|
||||||
|
const preferInstalled = core.getBooleanInput('prefer-installed');
|
||||||
|
|
||||||
if (quality && !qualityOptions.includes(quality)) {
|
if (quality && !qualityOptions.includes(quality)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -69,7 +70,11 @@ export async function run() {
|
|||||||
let dotnetInstaller: DotnetCoreInstaller;
|
let dotnetInstaller: DotnetCoreInstaller;
|
||||||
const uniqueVersions = new Set<string>(versions);
|
const uniqueVersions = new Set<string>(versions);
|
||||||
for (const version of uniqueVersions) {
|
for (const version of uniqueVersions) {
|
||||||
dotnetInstaller = new DotnetCoreInstaller(version, quality);
|
dotnetInstaller = new DotnetCoreInstaller(
|
||||||
|
version,
|
||||||
|
quality,
|
||||||
|
preferInstalled
|
||||||
|
);
|
||||||
const installedVersion = await dotnetInstaller.installDotnet();
|
const installedVersion = await dotnetInstaller.installDotnet();
|
||||||
installedDotnetVersions.push(installedVersion);
|
installedDotnetVersions.push(installedVersion);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user