Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install runtime only #476

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add option to install runtime only
  • Loading branch information
nikolai-laevskii committed Sep 8, 2023
commit 44d36ccab933ea8c7760aa0ed9d75cd42d08a157
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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'
dotnet-quality:
description: 'Optional quality of the build. The possible values are: daily, signed, validated, preview, ga.'
runtime-only:
description: 'Optional input to install only the runtime, not the SDK.'
required: false
default: false
global-json-file:
description: 'Optional global.json location, if your global.json isn''t located in the root of the repo.'
source-url:
14 changes: 9 additions & 5 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
@@ -72993,9 +72993,10 @@ DotnetInstallDir.dirPath = process.env['DOTNET_INSTALL_DIR']
? DotnetInstallDir.convertInstallPathToAbsolute(process.env['DOTNET_INSTALL_DIR'])
: DotnetInstallDir.default[utils_1.PLATFORM];
class DotnetCoreInstaller {
constructor(dotnetVersion, quality) {
constructor(dotnetVersion, quality, runtimeOnly = false) {
this.dotnetVersion = dotnetVersion;
this.quality = quality;
this.runtimeOnly = runtimeOnly;
}
installDotnet() {
return __awaiter(this, void 0, void 0, function* () {
@@ -73022,12 +73023,15 @@ class DotnetCoreInstaller {
* Install dotnet over the latest version of
* dotnet CLI
*/
const dotnetInstallOutput = yield new DotnetInstallScript()
const dotnetInstallScript = new DotnetInstallScript()
// Don't overwrite CLI because it should be already installed
.useArguments(utils_1.IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files')
// Use version provided by user
.useVersion(this.dotnetVersion, this.quality)
.execute();
.useVersion(this.dotnetVersion, this.quality);
if (this.runtimeOnly) {
dotnetInstallScript.useArguments(utils_1.IS_WINDOWS ? '-Runtime' : '--runtime', 'dotnet');
}
const dotnetInstallOutput = yield dotnetInstallScript.execute();
if (dotnetInstallOutput.exitCode) {
throw new Error(`Failed to install dotnet, exit code: ${dotnetInstallOutput.exitCode}. ${dotnetInstallOutput.stderr}`);
}
@@ -73154,7 +73158,7 @@ function run() {
const uniqueVersions = new Set(versions);
for (const version of uniqueVersions) {
dotnetVersionResolver = new installer_1.DotnetVersionResolver(version);
dotnetInstaller = new installer_1.DotnetCoreInstaller(yield dotnetVersionResolver.createDotnetVersion(), quality);
dotnetInstaller = new installer_1.DotnetCoreInstaller(yield dotnetVersionResolver.createDotnetVersion(), quality, core.getBooleanInput('runtime-only'));
const installedVersion = yield dotnetInstaller.installDotnet();
installedDotnetVersions.push(installedVersion);
}
17 changes: 13 additions & 4 deletions src/installer.ts
Original file line number Diff line number Diff line change
@@ -255,7 +255,8 @@ export class DotnetCoreInstaller {

constructor(
private readonly dotnetVersion: DotnetVersion,
private readonly quality: QualityOptions
private readonly quality: QualityOptions,
private readonly runtimeOnly = false
) {}

public async installDotnet(): Promise<string | null> {
@@ -288,14 +289,22 @@ export class DotnetCoreInstaller {
* Install dotnet over the latest version of
* dotnet CLI
*/
const dotnetInstallOutput = await new DotnetInstallScript()
const dotnetInstallScript = new DotnetInstallScript()
// Don't overwrite CLI because it should be already installed
.useArguments(
IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files'
)
// Use version provided by user
.useVersion(this.dotnetVersion, this.quality)
.execute();
.useVersion(this.dotnetVersion, this.quality);

if (this.runtimeOnly) {
dotnetInstallScript.useArguments(
IS_WINDOWS ? '-Runtime' : '--runtime',
'dotnet'
);
}

const dotnetInstallOutput = await dotnetInstallScript.execute();

if (dotnetInstallOutput.exitCode) {
throw new Error(
3 changes: 2 additions & 1 deletion src/setup-dotnet.ts
Original file line number Diff line number Diff line change
@@ -78,7 +78,8 @@ export async function run() {
dotnetVersionResolver = new DotnetVersionResolver(version);
dotnetInstaller = new DotnetCoreInstaller(
await dotnetVersionResolver.createDotnetVersion(),
quality
quality,
core.getBooleanInput('runtime-only')
);
const installedVersion = await dotnetInstaller.installDotnet();
installedDotnetVersions.push(installedVersion);