mirror of
https://github.com/actions/setup-dotnet.git
synced 2025-08-20 23:50:19 +00:00
support specifying global.json location with global-json-file input
This commit is contained in:
parent
9283a8cf7a
commit
e7077ab2c6
10
README.md
10
README.md
@ -51,6 +51,16 @@ steps:
|
|||||||
include-prerelease: true
|
include-prerelease: true
|
||||||
- run: dotnet build <my project>
|
- run: dotnet build <my project>
|
||||||
```
|
```
|
||||||
|
global.json in a subdirectory:
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-dotnet@v2
|
||||||
|
with:
|
||||||
|
global-json-file: csharp/global.json
|
||||||
|
- run: dotnet build <my project>
|
||||||
|
working-directory: csharp
|
||||||
|
```
|
||||||
|
|
||||||
Matrix Testing:
|
Matrix Testing:
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -7,6 +7,8 @@ branding:
|
|||||||
inputs:
|
inputs:
|
||||||
dotnet-version:
|
dotnet-version:
|
||||||
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'
|
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'
|
||||||
|
global-json-file:
|
||||||
|
description: 'Optional global.json location, if your global.json it''t located in the root of the repo.'
|
||||||
source-url:
|
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'
|
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:
|
owner:
|
||||||
|
10
dist/index.js
vendored
10
dist/index.js
vendored
@ -9115,11 +9115,21 @@ function run() {
|
|||||||
//
|
//
|
||||||
// dotnet-version is optional, but needs to be provided for most use cases.
|
// dotnet-version is optional, but needs to be provided for most use cases.
|
||||||
// If supplied, install / use from the tool cache.
|
// If supplied, install / use from the tool cache.
|
||||||
|
// global-version-file may be specified to point to a specific global.json
|
||||||
|
// and will be used to install an additional version.
|
||||||
// If not supplied, look for version in ./global.json.
|
// If not supplied, look for version in ./global.json.
|
||||||
// If a valid version still can't be identified, nothing will be installed.
|
// 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
|
// Proxy, auth, (etc) are still set up, even if no version is identified
|
||||||
//
|
//
|
||||||
let versions = core.getMultilineInput('dotnet-version');
|
let versions = core.getMultilineInput('dotnet-version');
|
||||||
|
const globalJsonFileInput = core.getInput('global-json-file');
|
||||||
|
if (globalJsonFileInput) {
|
||||||
|
const globalJsonPath = path.join(process.cwd(), globalJsonFileInput);
|
||||||
|
if (!fs.existsSync(globalJsonPath)) {
|
||||||
|
throw new Error(`The specified global.json file '${globalJsonFileInput}' does not exist`);
|
||||||
|
}
|
||||||
|
versions.push(getVersionFromGlobalJson(globalJsonPath));
|
||||||
|
}
|
||||||
if (!versions.length) {
|
if (!versions.length) {
|
||||||
// Try to fall back to global.json
|
// Try to fall back to global.json
|
||||||
core.debug('No version found, trying to find version from global.json');
|
core.debug('No version found, trying to find version from global.json');
|
||||||
|
@ -9,11 +9,25 @@ export async function run() {
|
|||||||
//
|
//
|
||||||
// dotnet-version is optional, but needs to be provided for most use cases.
|
// dotnet-version is optional, but needs to be provided for most use cases.
|
||||||
// If supplied, install / use from the tool cache.
|
// If supplied, install / use from the tool cache.
|
||||||
|
// global-version-file may be specified to point to a specific global.json
|
||||||
|
// and will be used to install an additional version.
|
||||||
// If not supplied, look for version in ./global.json.
|
// If not supplied, look for version in ./global.json.
|
||||||
// If a valid version still can't be identified, nothing will be installed.
|
// 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
|
// Proxy, auth, (etc) are still set up, even if no version is identified
|
||||||
//
|
//
|
||||||
let versions = core.getMultilineInput('dotnet-version');
|
let versions = core.getMultilineInput('dotnet-version');
|
||||||
|
|
||||||
|
const globalJsonFileInput = core.getInput('global-json-file');
|
||||||
|
if (globalJsonFileInput) {
|
||||||
|
const globalJsonPath = path.join(process.cwd(), globalJsonFileInput);
|
||||||
|
if (!fs.existsSync(globalJsonPath)) {
|
||||||
|
throw new Error(
|
||||||
|
`The specified global.json file '${globalJsonFileInput}' does not exist`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
versions.push(getVersionFromGlobalJson(globalJsonPath));
|
||||||
|
}
|
||||||
|
|
||||||
if (!versions.length) {
|
if (!versions.length) {
|
||||||
// Try to fall back to global.json
|
// Try to fall back to global.json
|
||||||
core.debug('No version found, trying to find version from global.json');
|
core.debug('No version found, trying to find version from global.json');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user