mirror of
https://github.com/actions/setup-dotnet.git
synced 2025-08-23 00:50:19 +00:00
Merge 70a19cc0ab9192f41061fb1200e564691fe0b1d9 into 926f4420227aaf87acf2840f360e4f2475f13b3b
This commit is contained in:
commit
8e3e667a5a
11
README.md
11
README.md
@ -30,6 +30,17 @@ steps:
|
|||||||
```
|
```
|
||||||
> **Warning**: Unless a concrete version is specified in the [`global.json`](https://learn.microsoft.com/en-us/dotnet/core/tools/global-json) file, **_the latest .NET version installed on the runner (including preinstalled versions) will be used [by default](https://learn.microsoft.com/en-us/dotnet/core/versions/selection#the-sdk-uses-the-latest-installed-version)_**. Please refer to the [documentation](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software) for the currently preinstalled .NET SDK versions.
|
> **Warning**: Unless a concrete version is specified in the [`global.json`](https://learn.microsoft.com/en-us/dotnet/core/tools/global-json) file, **_the latest .NET version installed on the runner (including preinstalled versions) will be used [by default](https://learn.microsoft.com/en-us/dotnet/core/versions/selection#the-sdk-uses-the-latest-installed-version)_**. Please refer to the [documentation](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software) for the currently preinstalled .NET SDK versions.
|
||||||
|
|
||||||
|
**Specific architecture:**
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-dotnet@v2
|
||||||
|
with:
|
||||||
|
dotnet-version: '6.0.x'
|
||||||
|
architecture: 'x86'
|
||||||
|
- run: dotnet build <my project>
|
||||||
|
```
|
||||||
|
|
||||||
**Multiple version installation**:
|
**Multiple version installation**:
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
|
@ -107,6 +107,24 @@ describe('DotnetCoreInstaller tests', () => {
|
|||||||
expect(process.env.PATH?.startsWith(toolDir)).toBe(true);
|
expect(process.env.PATH?.startsWith(toolDir)).toBe(true);
|
||||||
}, 600000); //This needs some time to download on "slower" internet connections
|
}, 600000); //This needs some time to download on "slower" internet connections
|
||||||
|
|
||||||
|
it('Acquires architecture-specific version of dotnet if no matching version is installed', async () => {
|
||||||
|
await getDotnet('3.1', '', 'x64');
|
||||||
|
var directory = fs
|
||||||
|
.readdirSync(path.join(toolDir, 'sdk'))
|
||||||
|
.filter(fn => fn.startsWith('3.1.'));
|
||||||
|
expect(directory.length > 0).toBe(true);
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
|
||||||
|
} else {
|
||||||
|
expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(process.env.DOTNET_ROOT).toBeDefined;
|
||||||
|
expect(process.env.PATH).toBeDefined;
|
||||||
|
expect(process.env.DOTNET_ROOT).toBe(toolDir);
|
||||||
|
expect(process.env.PATH?.startsWith(toolDir)).toBe(true);
|
||||||
|
}, 600000); //This needs some time to download on "slower" internet connections
|
||||||
|
|
||||||
it('Returns string with installed SDK version', async () => {
|
it('Returns string with installed SDK version', async () => {
|
||||||
const version = '3.1.120';
|
const version = '3.1.120';
|
||||||
let installedVersion: string;
|
let installedVersion: string;
|
||||||
@ -278,11 +296,13 @@ function normalizeFileContents(contents: string): string {
|
|||||||
|
|
||||||
async function getDotnet(
|
async function getDotnet(
|
||||||
version: string,
|
version: string,
|
||||||
quality: string = ''
|
quality: string = '',
|
||||||
|
architecture: string = ''
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||||
version,
|
version,
|
||||||
quality as QualityOptions
|
quality as QualityOptions,
|
||||||
|
architecture
|
||||||
);
|
);
|
||||||
const installedVersion = await dotnetInstaller.installDotnet();
|
const installedVersion = await dotnetInstaller.installDotnet();
|
||||||
installer.DotnetCoreInstaller.addToPath();
|
installer.DotnetCoreInstaller.addToPath();
|
||||||
|
@ -17,6 +17,9 @@ inputs:
|
|||||||
description: 'Optional OWNER for using packages from GitHub Package Registry organizations/users other than the current repository''s owner. Only used if a GPR URL is also provided in source-url'
|
description: 'Optional OWNER for using packages from GitHub Package Registry organizations/users other than the current repository''s owner. Only used if a GPR URL is also provided in source-url'
|
||||||
config-file:
|
config-file:
|
||||||
description: 'Optional NuGet.config location, if your NuGet.config isn''t located in the root of the repo.'
|
description: 'Optional NuGet.config location, if your NuGet.config isn''t located in the root of the repo.'
|
||||||
|
architecture:
|
||||||
|
description: 'Optional architecture to use. If not provided, will default to the OS architecture.'
|
||||||
|
required: False
|
||||||
outputs:
|
outputs:
|
||||||
dotnet-version:
|
dotnet-version:
|
||||||
description: 'Contains the installed by action .NET SDK version for reuse.'
|
description: 'Contains the installed by action .NET SDK version for reuse.'
|
||||||
|
12
dist/index.js
vendored
12
dist/index.js
vendored
@ -315,9 +315,10 @@ class DotnetVersionResolver {
|
|||||||
exports.DotnetVersionResolver = DotnetVersionResolver;
|
exports.DotnetVersionResolver = DotnetVersionResolver;
|
||||||
DotnetVersionResolver.DotNetCoreIndexUrl = 'https://dotnetcli.azureedge.net/dotnet/release-metadata/releases-index.json';
|
DotnetVersionResolver.DotNetCoreIndexUrl = 'https://dotnetcli.azureedge.net/dotnet/release-metadata/releases-index.json';
|
||||||
class DotnetCoreInstaller {
|
class DotnetCoreInstaller {
|
||||||
constructor(version, quality) {
|
constructor(version, quality, architecture = '') {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
|
this.architecture = architecture;
|
||||||
}
|
}
|
||||||
static convertInstallPathToAbsolute(installDir) {
|
static convertInstallPathToAbsolute(installDir) {
|
||||||
let transformedPath;
|
let transformedPath;
|
||||||
@ -392,6 +393,9 @@ class DotnetCoreInstaller {
|
|||||||
if (this.quality) {
|
if (this.quality) {
|
||||||
this.setQuality(dotnetVersion, scriptArguments);
|
this.setQuality(dotnetVersion, scriptArguments);
|
||||||
}
|
}
|
||||||
|
if (this.architecture != '') {
|
||||||
|
scriptArguments.push('--architecture', this.architecture);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
||||||
const getExecOutputOptions = {
|
const getExecOutputOptions = {
|
||||||
@ -511,6 +515,10 @@ function run() {
|
|||||||
//
|
//
|
||||||
const versions = core.getMultilineInput('dotnet-version');
|
const versions = core.getMultilineInput('dotnet-version');
|
||||||
const installedDotnetVersions = [];
|
const installedDotnetVersions = [];
|
||||||
|
let architecture = core.getInput('architecture');
|
||||||
|
if (!architecture) {
|
||||||
|
architecture = '';
|
||||||
|
}
|
||||||
const globalJsonFileInput = core.getInput('global-json-file');
|
const globalJsonFileInput = core.getInput('global-json-file');
|
||||||
if (globalJsonFileInput) {
|
if (globalJsonFileInput) {
|
||||||
const globalJsonPath = path_1.default.join(process.cwd(), globalJsonFileInput);
|
const globalJsonPath = path_1.default.join(process.cwd(), globalJsonFileInput);
|
||||||
@ -538,7 +546,7 @@ function run() {
|
|||||||
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, architecture);
|
||||||
const installedVersion = yield dotnetInstaller.installDotnet();
|
const installedVersion = yield dotnetInstaller.installDotnet();
|
||||||
installedDotnetVersions.push(installedVersion);
|
installedDotnetVersions.push(installedVersion);
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,7 @@ export class DotnetVersionResolver {
|
|||||||
export class DotnetCoreInstaller {
|
export class DotnetCoreInstaller {
|
||||||
private version: string;
|
private version: string;
|
||||||
private quality: QualityOptions;
|
private quality: QualityOptions;
|
||||||
|
private architecture: string;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
const installationDirectoryWindows = path.join(
|
const installationDirectoryWindows = path.join(
|
||||||
@ -140,9 +141,14 @@ export class DotnetCoreInstaller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(version: string, quality: QualityOptions) {
|
constructor(
|
||||||
|
version: string,
|
||||||
|
quality: QualityOptions,
|
||||||
|
architecture: string = ''
|
||||||
|
) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
|
this.architecture = architecture;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static convertInstallPathToAbsolute(installDir: string): string {
|
private static convertInstallPathToAbsolute(installDir: string): string {
|
||||||
@ -230,6 +236,10 @@ export class DotnetCoreInstaller {
|
|||||||
if (this.quality) {
|
if (this.quality) {
|
||||||
this.setQuality(dotnetVersion, scriptArguments);
|
this.setQuality(dotnetVersion, scriptArguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.architecture != '') {
|
||||||
|
scriptArguments.push('--architecture', this.architecture);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
||||||
const getExecOutputOptions = {
|
const getExecOutputOptions = {
|
||||||
|
@ -28,6 +28,11 @@ export async function run() {
|
|||||||
//
|
//
|
||||||
const versions = core.getMultilineInput('dotnet-version');
|
const versions = core.getMultilineInput('dotnet-version');
|
||||||
const installedDotnetVersions: string[] = [];
|
const installedDotnetVersions: string[] = [];
|
||||||
|
let architecture = core.getInput('architecture');
|
||||||
|
|
||||||
|
if (!architecture) {
|
||||||
|
architecture = '';
|
||||||
|
}
|
||||||
|
|
||||||
const globalJsonFileInput = core.getInput('global-json-file');
|
const globalJsonFileInput = core.getInput('global-json-file');
|
||||||
if (globalJsonFileInput) {
|
if (globalJsonFileInput) {
|
||||||
@ -65,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,
|
||||||
|
architecture
|
||||||
|
);
|
||||||
const installedVersion = await dotnetInstaller.installDotnet();
|
const installedVersion = await dotnetInstaller.installDotnet();
|
||||||
installedDotnetVersions.push(installedVersion);
|
installedDotnetVersions.push(installedVersion);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user