Compare commits

..

62 Commits

Author SHA1 Message Date
c0d4ad69d8 Don't need C# analysis for CodeQL 2022-04-29 13:54:18 -04:00
afe2daba1f Create codeql-analysis.yml 2022-04-29 13:48:41 -04:00
5cc895510b Update @zeit/ncc to @vercel/ncc (#290)
* update @zeit/ncc to @vercel/ncc

* rebuild project
2022-04-28 11:37:53 +02:00
158737d5b1 Merge pull request #289 from vsafonkin/v-vsafonkin/update-wget-package
Update vulnerable packages
2022-04-21 13:10:39 +03:00
fcf565ec50 Update vulnerable packages 2022-04-21 11:17:56 +02:00
f078482971 add global-json-file input (#276)
* support specifying global.json location with global-json-file input

* add test workflow jobs for global.json usage

* fix typo in global-json-file description

Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>

Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>
2022-04-18 08:25:56 -04:00
0fb87b12d2 Merge pull request #285 from vsafonkin/v-vsafonkin/add-code-of-conduct
Add code of conduct
2022-04-15 11:03:29 +03:00
4fe7a196b5 Add code of conduct 2022-04-13 16:58:12 +02:00
9283a8cf7a switch side by side testing example to single setup step (#283) 2022-04-11 11:50:34 -04:00
53d632b5c0 Update docs to v2 (#278)
* Update docs to v2

* Bump checkout action to v3

* Update installer scripts

* Replace v2 to vX on the docs, minor fixes

* Remove extra whitespace
2022-04-01 09:48:47 -04:00
9211491ffb Merge pull request #273 from actions/v-vlsafo/update-deps
Update npm dependencies
2022-02-24 18:33:48 +03:00
edfd7b3266 Update licenses 2022-02-24 18:12:33 +03:00
9744af7b74 Update dependencies 2022-02-24 18:04:55 +03:00
7016f85f93 Merge pull request #271 from vsafonkin/v-vlsafo/update-node-version
Update default runtime to node16
2022-02-24 17:29:31 +03:00
d292011f5d Update node version to v16 2022-02-24 11:16:01 +03:00
608ee757cf Merge pull request #270 from snickler/main
Updated dotnet-install scripts to latest version
2022-02-22 16:38:32 +03:00
e54e706650 Updated dotnet-install scripts to latest version 2022-02-19 17:07:00 -05:00
c20f59e04a Avoiding installing the same version multiple times (#252) 2021-12-29 14:07:42 +03:00
13b852df87 Moved checkout above setup step to align with the other samples (#256) 2021-12-28 15:37:44 +03:00
f85bcda870 Fix the Licensed workflow (#258) 2021-12-23 14:35:09 +03:00
499789684c Warn users when installing EOL .NET versions (#245) 2021-11-23 16:58:49 +03:00
76ddd67c90 Fix a space in the documentation (#248) 2021-11-23 16:56:22 +03:00
550702114f Support multiple versions in single invocation (#240) 2021-11-23 13:03:56 +03:00
e3ce4164b3 Merge pull request #238 from vsafonkin/v-vlsafo/fix-dependencies
Update dependencies and installer scripts
2021-10-13 17:24:51 +03:00
463326422f Update jest 2021-10-13 16:35:23 +03:00
547d075822 Revert jest version 2021-10-13 14:58:41 +03:00
fc9265379f Update deps with force 2021-10-13 14:50:32 +03:00
32c76e2669 Update installer scripts 2021-10-13 14:27:43 +03:00
8ca0cf75a1 Update dependencies 2021-10-13 14:20:02 +03:00
7f88dbf08f Merge pull request #231 from actions/dependabot/npm_and_yarn/tmpl-1.0.5
Bump tmpl from 1.0.4 to 1.0.5
2021-10-13 11:12:15 +03:00
af0ed6536b Bump tmpl from 1.0.4 to 1.0.5
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-13 07:14:28 +00:00
9dd9d27e57 Merge pull request #234 from IEvangelist/patch-1
Update README.md
2021-10-12 17:27:43 +03:00
44530e8569 Update README.md
Fix the README.md file to avoid the .NET CLI repo link that is now the .NET SDK repo.
2021-10-05 10:05:48 -05:00
5a3fa01c67 Merge pull request #222 from actions/dependabot/npm_and_yarn/path-parse-1.0.7
Bump path-parse from 1.0.6 to 1.0.7
2021-09-14 10:17:28 +03:00
f2da928c08 Merge pull request #224 from vsafonkin/v-vlsafo/handle-roll-forward-option
Support `rollForward` option from `global.json` file
2021-09-13 10:09:01 +03:00
fb9fd97b03 Merge remote-tracking branch 'upstream/main' into v-vlsafo/handle-roll-forward-option 2021-08-30 17:40:23 +03:00
f0b9e4cf3f Merge pull request #225 from brcrista/brcrista/check-dist
Create check-dist.yml
2021-08-30 17:38:46 +03:00
b66058b059 Build index.js 2021-08-30 17:35:17 +03:00
7323c4e7cb Merge remote-tracking branch 'upstream/main' into v-vlsafo/handle-roll-forward-option 2021-08-30 17:31:17 +03:00
6eab455d72 Merge pull request #226 from vsafonkin/v-vlsafo/update-installers-scripts
Update installers scripts
2021-08-30 17:28:39 +03:00
b2cf6c7cd4 Handle only latestFeature option 2021-08-30 17:27:01 +03:00
ff5b78971e Merge pull request #227 from tomp736/patch-1
Update README.md
2021-08-30 09:57:40 +03:00
e26fc623bc Update README.md
fix docs
2021-08-29 14:56:20 +02:00
e974974b42 Update installers scripts 2021-08-26 12:44:10 +03:00
9969bca445 Fix triggers in licensed.yml 2021-08-25 11:29:43 -04:00
deee0f6246 Add check-dist.yml 2021-08-25 11:29:42 -04:00
33fad1d142 Format code 2021-08-20 17:28:30 +03:00
2c3efd1f04 Improve condition 2021-08-20 17:28:10 +03:00
f3822c3b02 Prettier 2021-08-20 17:13:23 +03:00
5e45b4b591 Remove hardcoded patch version from unit test 2021-08-20 17:11:48 +03:00
b7b99f337e Fix unit test 2021-08-20 16:54:24 +03:00
f92687c910 Minor fix 2021-08-20 16:47:49 +03:00
0067f023d2 Fix unstaged changes in index.js 2021-08-20 16:45:26 +03:00
9480036ff9 Fix unit test 2021-08-20 16:35:44 +03:00
6b8ad2e725 Revert exports in index.js 2021-08-20 15:48:47 +03:00
078f7c4a73 Format code 2021-08-20 15:44:47 +03:00
13fd5bf191 Support rollForward option from global.json 2021-08-20 15:43:49 +03:00
26be14c4e1 Bump path-parse from 1.0.6 to 1.0.7
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-11 08:44:30 +00:00
8309d4ee7e Merge pull request #220 from 0xfeeddeadbeef/patch-1
Update link to dotnet environment variables docs
2021-07-29 10:25:00 +03:00
bab14f40fd Update link to dotnet environment variables docs
Old: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet#environment-variables
New: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables
2021-07-28 14:48:24 +04:00
4b337272b7 Merge pull request #215 from actions/v-vlsafo/action-description
Rework action description
2021-06-28 13:24:33 +03:00
d62c876481 Rework action description 2021-06-28 13:20:36 +03:00
27 changed files with 25692 additions and 18441 deletions

52
.github/workflows/check-dist.yml vendored Normal file
View File

@ -0,0 +1,52 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: Check dist/
on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:
jobs:
check-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: npm
- name: Install dependencies
run: npm ci
- name: Rebuild the dist/ directory
run: npm run build
- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
id: diff
# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/

70
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@ -0,0 +1,70 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '23 19 * * 0'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

View File

@ -1,20 +1,25 @@
name: Licensed name: Licensed
on: on:
push: {branches: main} push:
pull_request: {branches: main} branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs: jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Check licenses name: Check licenses
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- run: npm ci - run: npm ci
- name: Install licensed - name: Install licensed
run: | run: |
cd $RUNNER_TEMP cd $RUNNER_TEMP
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.4.4/licensed-3.4.4-linux-x64.tar.gz
sudo tar -xzf licensed.tar.gz sudo tar -xzf licensed.tar.gz
sudo mv licensed /usr/local/bin/licensed sudo mv licensed /usr/local/bin/licensed
- run: licensed status - run: licensed status

View File

@ -21,7 +21,7 @@ jobs:
dotnet-version: ['2.1', '2.2', '3.0', '3.1', '5.0'] dotnet-version: ['2.1', '2.2', '3.0', '3.1', '5.0']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}

View File

@ -20,11 +20,12 @@ jobs:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Set Node.js 12 - name: Set Node.js 16
uses: actions/setup-node@v1 uses: actions/setup-node@v3
with: with:
node-version: 12.x node-version: 16.x
cache: npm
- run: npm ci - run: npm ci
- run: npm run build - run: npm run build
- run: npm run format-check - run: npm run format-check
@ -33,6 +34,29 @@ jobs:
if: runner.os != 'windows' if: runner.os != 'windows'
run: __tests__/verify-no-unstaged-changes.sh run: __tests__/verify-no-unstaged-changes.sh
test-setup-multiple-versions:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Clear toolcache
shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
- name: Setup dotnet 2.2.402 and 3.1.404
uses: ./
with:
dotnet-version: |
2.2.402
3.1.404
3.0.x
- name: Verify dotnet
shell: pwsh
run: __tests__/verify-dotnet.ps1 2.2.402 3.1.404 '3.0'
test-setup-full-version: test-setup-full-version:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
strategy: strategy:
@ -41,7 +65,7 @@ jobs:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@ -74,7 +98,7 @@ jobs:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@ -99,7 +123,7 @@ jobs:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@ -123,7 +147,7 @@ jobs:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macOS-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Clear toolcache - name: Clear toolcache
shell: pwsh shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }} run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
@ -139,6 +163,32 @@ jobs:
shell: pwsh shell: pwsh
run: __tests__/verify-dotnet.ps1 3.1 2.2 run: __tests__/verify-dotnet.ps1 3.1 2.2
test-setup-global-json-specified-and-version:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Clear toolcache
shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
- name: Write global.json
shell: bash
run: |
mkdir subdirectory
echo '{"sdk":{"version": "2.2","rollForward": "latestFeature"}}' > ./subdirectory/global.json
- name: Setup dotnet
uses: ./
with:
dotnet-version: 3.1
global-json-file: ./subdirectory/global.json
- name: Verify dotnet
shell: pwsh
run: __tests__/verify-dotnet.ps1 2.2 3.1
test-proxy: test-proxy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
@ -154,7 +204,7 @@ jobs:
http_proxy: http://squid-proxy:3128 http_proxy: http://squid-proxy:3128
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Clear tool cache - name: Clear tool cache
run: rm -rf "/usr/share/dotnet" run: rm -rf "/usr/share/dotnet"
- name: Install curl - name: Install curl
@ -178,7 +228,7 @@ jobs:
no_proxy: github.com,dotnetcli.blob.core.windows.net,download.visualstudio.microsoft.com,api.nuget.org,dotnetcli.azureedge.net no_proxy: github.com,dotnetcli.blob.core.windows.net,download.visualstudio.microsoft.com,api.nuget.org,dotnetcli.azureedge.net
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Clear tool cache - name: Clear tool cache
run: rm -rf "/usr/share/dotnet" run: rm -rf "/usr/share/dotnet"
- name: Setup dotnet 3.1.201 - name: Setup dotnet 3.1.201

View File

@ -1,6 +1,6 @@
--- ---
name: "@actions/core" name: "@actions/core"
version: 1.2.6 version: 1.6.0
type: npm type: npm
summary: Actions core lib summary: Actions core lib
homepage: https://github.com/actions/toolkit/tree/main/packages/core homepage: https://github.com/actions/toolkit/tree/main/packages/core

View File

@ -0,0 +1,32 @@
---
name: "@actions/http-client"
version: 1.0.11
type: npm
summary: Actions Http Client
homepage: https://github.com/actions/http-client#readme
license: mit
licenses:
- sources: LICENSE
text: |
Actions Http Client for Node.js
Copyright (c) GitHub, Inc.
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
notices: []

View File

@ -1,6 +1,6 @@
--- ---
name: node-fetch name: node-fetch
version: 2.6.1 version: 2.6.7
type: npm type: npm
summary: A light-weight module that brings window.fetch to node.js summary: A light-weight module that brings window.fetch to node.js
homepage: https://github.com/bitinn/node-fetch homepage: https://github.com/bitinn/node-fetch

30
.licenses/npm/tr46.dep.yml generated Normal file
View File

@ -0,0 +1,30 @@
---
name: tr46
version: 0.0.3
type: npm
summary: An implementation of the Unicode TR46 spec
homepage: https://github.com/Sebmaster/tr46.js#readme
license: mit
licenses:
- sources: Auto-generated MIT license text
text: |
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
notices: []

23
.licenses/npm/webidl-conversions.dep.yml generated Normal file
View File

@ -0,0 +1,23 @@
---
name: webidl-conversions
version: 3.0.1
type: npm
summary: Implements the WebIDL algorithms for converting to and from JavaScript values
homepage:
license: bsd-2-clause
licenses:
- sources: LICENSE.md
text: |
# The BSD 2-Clause License
Copyright (c) 2014, Domenic Denicola
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
notices: []

32
.licenses/npm/whatwg-url.dep.yml generated Normal file
View File

@ -0,0 +1,32 @@
---
name: whatwg-url
version: 5.0.0
type: npm
summary: An implementation of the WHATWG URL Standard's URL API and parsing machinery
homepage:
license: mit
licenses:
- sources: LICENSE.txt
text: |
The MIT License (MIT)
Copyright (c) 20152016 Sebastian Mayr
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
notices: []

76
CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at opensource+actions/setup-dotnet@github.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

View File

@ -1,12 +1,10 @@
# setup-dotnet # setup-dotnet
<p align="left"> [![GitHub Actions Status](https://github.com/actions/setup-dotnet/workflows/Main%20workflow/badge.svg)](https://github.com/actions/setup-dotnet)
<a href="https://github.com/actions/setup-dotnet"><img alt="GitHub Actions status" src="https://github.com/actions/setup-dotnet/workflows/Main%20workflow/badge.svg"></a>
</p>
This action sets up a [dotnet core cli](https://github.com/dotnet/cli) environment for use in actions by: This action sets up a [.NET CLI](https://github.com/dotnet/sdk) environment for use in actions by:
- optionally downloading and caching a version of dotnet by SDK version and adding to PATH - optionally downloading and caching a version(s) of dotnet by SDK version(s) and adding to PATH
- registering problem matchers for error output - registering problem matchers for error output
- setting up authentication to private package sources like GitHub Packages - setting up authentication to private package sources like GitHub Packages
@ -23,23 +21,46 @@ See [action.yml](action.yml)
Basic: Basic:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-dotnet@v1 - uses: actions/setup-dotnet@v2
with: with:
dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel 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> - run: dotnet build <my project>
``` ```
Multiple versions:
> Note: In case multiple versions are installed, the latest .NET version will be used by default unless another version is specified in the `global.json` file.
```yml
steps:
- uses: actions/checkout@v3
- name: Setup dotnet
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
3.1.x
5.0.x
- run: dotnet build <my project>
```
Preview version: Preview version:
```yml ```yml
steps: steps:
- uses: actions@checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-dotnet@v1 - uses: actions/setup-dotnet@v2
with: with:
dotnet-version: '6.0.x' dotnet-version: '6.0.x'
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
@ -51,9 +72,9 @@ jobs:
dotnet: [ '2.1.x', '3.1.x', '5.0.x' ] dotnet: [ '2.1.x', '3.1.x', '5.0.x' ]
name: Dotnet ${{ matrix.dotnet }} sample name: Dotnet ${{ matrix.dotnet }} sample
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Setup dotnet - name: Setup dotnet
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v2
with: with:
dotnet-version: ${{ matrix.dotnet }} dotnet-version: ${{ matrix.dotnet }}
- run: dotnet build <my project> - run: dotnet build <my project>
@ -66,15 +87,13 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Dotnet Side by Side testing sample name: Dotnet Side by Side testing sample
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Setup dotnet - name: Setup dotnet
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v2
with: with:
dotnet-version: '2.1.x' dotnet-version: |
- name: Setup dotnet 2.1.x
uses: actions/setup-dotnet@v1 3.1.x
with:
dotnet-version: '3.1.x'
- run: dotnet build <my project> - run: dotnet build <my project>
- run: dotnet test <my project> - run: dotnet test <my project>
``` ```
@ -82,9 +101,9 @@ jobs:
Authentication for nuget feeds: Authentication for nuget feeds:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
# Authenticates packages to push to GPR # Authenticates packages to push to GPR
- uses: actions/setup-dotnet@v1 - uses: actions/setup-dotnet@v2
with: with:
dotnet-version: '3.1.x' # SDK Version to use. dotnet-version: '3.1.x' # SDK Version to use.
source-url: https://nuget.pkg.github.com/<owner>/index.json source-url: https://nuget.pkg.github.com/<owner>/index.json
@ -97,7 +116,7 @@ steps:
run: dotnet nuget push <my project>/bin/Release/*.nupkg run: dotnet nuget push <my project>/bin/Release/*.nupkg
# Authenticates packages to push to Azure Artifacts # Authenticates packages to push to Azure Artifacts
- uses: actions/setup-dotnet@v1 - uses: actions/setup-dotnet@v2
with: with:
source-url: https://pkgs.dev.azure.com/<your-organization>/_packaging/<your-feed-name>/nuget/v3/index.json source-url: https://pkgs.dev.azure.com/<your-organization>/_packaging/<your-feed-name>/nuget/v3/index.json
env: env:
@ -107,7 +126,7 @@ steps:
# Authenticates packages to push to nuget.org. # Authenticates packages to push to nuget.org.
# It's only the way to push a package to nuget.org feed for macOS/Linux machines due to API key config store limitations. # It's only the way to push a package to nuget.org feed for macOS/Linux machines due to API key config store limitations.
- uses: actions/setup-dotnet@v1 - uses: actions/setup-dotnet@v2
with: with:
dotnet-version: 3.1.x dotnet-version: 3.1.x
- name: Publish the package to nuget.org - name: Publish the package to nuget.org
@ -118,7 +137,7 @@ steps:
## Environment Variables to use with dotnet ## 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 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_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_CLI_TELEMETRY_OPTOUT - opt-out of telemetry being sent to Microsoft (default: false)
@ -132,7 +151,7 @@ build:
DOTNET_NOLOGO: true DOTNET_NOLOGO: true
steps: steps:
- uses: actions/checkout@main - uses: actions/checkout@main
- uses: actions/setup-dotnet@v1 - uses: actions/setup-dotnet@v2
with: with:
dotnet-version: '3.1.x' # SDK Version to use. dotnet-version: '3.1.x' # SDK Version to use.
``` ```

View File

@ -32,6 +32,27 @@ describe('installer tests', () => {
} }
}, 30000); }, 30000);
it('Aquires multiple versions of dotnet', async () => {
const versions = ['2.2.207', '3.1.120'];
for (const version of versions) {
await getDotnet(version);
}
expect(fs.existsSync(path.join(toolDir, 'sdk', '2.2.207'))).toBe(true);
expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.120'))).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);
it('Acquires version of dotnet if no matching version is installed', async () => { it('Acquires version of dotnet if no matching version is installed', async () => {
await getDotnet('3.1.201'); await getDotnet('3.1.201');
expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).toBe(true); expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).toBe(true);
@ -126,4 +147,5 @@ function normalizeFileContents(contents: string): string {
async function getDotnet(version: string): Promise<void> { async function getDotnet(version: string): Promise<void> {
const dotnetInstaller = new installer.DotnetCoreInstaller(version); const dotnetInstaller = new installer.DotnetCoreInstaller(version);
await dotnetInstaller.installDotnet(); await dotnetInstaller.installDotnet();
installer.DotnetCoreInstaller.addToPath();
} }

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.2</TargetFrameworks> <TargetFrameworks>netcoreapp3.1;netcoreapp3.0;netcoreapp2.2</TargetFrameworks>
<RootNamespace>sample_csproj</RootNamespace> <RootNamespace>sample_csproj</RootNamespace>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>

View File

@ -7,6 +7,7 @@ const toolDir = path.join(__dirname, 'runner', 'tools2');
const tempDir = path.join(__dirname, 'runner', 'temp2'); const tempDir = path.join(__dirname, 'runner', 'temp2');
import * as setup from '../src/setup-dotnet'; import * as setup from '../src/setup-dotnet';
import * as dotnetInstaller from '../src/installer';
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
@ -19,7 +20,7 @@ describe('setup-dotnet tests', () => {
await io.rmRF(tempDir); await io.rmRF(tempDir);
}); });
afterAll(async () => { afterEach(async () => {
try { try {
await io.rmRF(path.join(process.cwd(), 'global.json')); await io.rmRF(path.join(process.cwd(), 'global.json'));
await io.rmRF(toolDir); await io.rmRF(toolDir);
@ -44,4 +45,26 @@ describe('setup-dotnet tests', () => {
expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true); expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
} }
}, 400000); }, 400000);
it('Acquires version of dotnet from global.json with rollForward option, install the latest patch', async () => {
const globalJsonPath = path.join(process.cwd(), 'global.json');
const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version":"3.1.201",${os.EOL}"rollForward":"latestFeature"${os.EOL}}${os.EOL}}`;
if (!fs.existsSync(globalJsonPath)) {
fs.writeFileSync(globalJsonPath, jsonContents);
}
const version = '3.1';
const installer = new dotnetInstaller.DotnetCoreInstaller(version);
const patchVersion = await installer.resolveVersion(
new dotnetInstaller.DotNetVersionInfo(version)
);
await setup.run();
expect(fs.existsSync(path.join(toolDir, 'sdk', patchVersion))).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);
}
}, 400000);
}); });

View File

@ -6,6 +6,8 @@ if (!$args[0])
$dotnet = Get-Command dotnet | Select-Object -First 1 | ForEach-Object { $_.Path } $dotnet = Get-Command dotnet | Select-Object -First 1 | ForEach-Object { $_.Path }
Write-Host "Found '$dotnet'" Write-Host "Found '$dotnet'"
if($args.count -eq 1)
{
$version = & $dotnet --version | Out-String | ForEach-Object { $_.Trim() } $version = & $dotnet --version | Out-String | ForEach-Object { $_.Trim() }
Write-Host "Version $version" Write-Host "Version $version"
if (-not ($version.StartsWith($args[0].ToString()))) if (-not ($version.StartsWith($args[0].ToString())))
@ -13,22 +15,24 @@ if (-not ($version.StartsWith($args[0].ToString())))
Write-Host "PATH='$env:PATH'" Write-Host "PATH='$env:PATH'"
throw "Unexpected version" throw "Unexpected version"
} }
}
if ($args[1]) if ($args[1])
{ {
# SDKs are listed on multiple lines with the path afterwards in square brackets # SDKs are listed on multiple lines with the path afterwards in square brackets
$versions = & $dotnet --list-sdks | ForEach-Object { $_.SubString(0, $_.IndexOf('[')).Trim() } $versions = & $dotnet --list-sdks | ForEach-Object { $_.SubString(0, $_.IndexOf('[')).Trim() }
Write-Host "Installed versions: $versions" Write-Host "Installed versions: $versions"
$isInstalledVersion = $false $InstalledVersionCount = 0
foreach($arg in $args){
foreach ($version in $versions) foreach ($version in $versions)
{ {
if ($version.StartsWith($args[1].ToString())) if ($version.StartsWith($arg.ToString()))
{ {
$isInstalledVersion = $true $InstalledVersionCount++
break
} }
} }
if (-not $isInstalledVersion) }
if ( $InstalledVersionCount -ne $args.Count)
{ {
Write-Host "PATH='$env:PATH'" Write-Host "PATH='$env:PATH'"
throw "Unexpected version" throw "Unexpected version"
@ -53,6 +57,13 @@ if ($args[1])
throw "Unexpected output" throw "Unexpected output"
} }
} }
if ($args[2])
{
if ($sample_output -notlike "*Test Run Successful.*Test Run Successful.*Test Run Successful.*")
{
throw "Unexpected output"
}
}
else else
{ {
if ($sample_output -notlike "*Test Run Successful.*") if ($sample_output -notlike "*Test Run Successful.*")

View File

@ -1,12 +1,14 @@
name: 'Setup .NET Core SDK' name: 'Setup .NET Core SDK'
description: 'Used to build and publish .NET source. Set up a specific version of the .NET Core CLI in the PATH and set up authentication to a private NuGet repository' description: 'Used to build and publish .NET source. Set up a specific version of the .NET and authentication to private NuGet repository'
author: 'GitHub' author: 'GitHub'
branding: branding:
icon: play icon: play
color: green color: green
inputs: inputs:
dotnet-version: dotnet-version:
description: 'Optional SDK version 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 isn''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:
@ -17,5 +19,5 @@ inputs:
description: 'Whether prerelease versions should be matched with non-exact versions (for example 5.0.0-preview.6 being matched by 5, 5.0, 5.x or 5.0.x). Defaults to false if not provided.' description: 'Whether prerelease versions should be matched with non-exact versions (for example 5.0.0-preview.6 being matched by 5, 5.0, 5.x or 5.0.x). Defaults to false if not provided.'
required: False required: False
runs: runs:
using: 'node12' using: 'node16'
main: 'dist/index.js' main: 'dist/index.js'

33146
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -26,9 +26,15 @@ With any contribution please take time to consider how this can be tested to mai
## Creating new version ## Creating new version
Details on versioning can be found here: https://github.com/actions/toolkit/blob/main/docs/action-versioning.md Details on versioning can be found here: https://github.com/actions/toolkit/blob/main/docs/action-versioning.md
Create a new release using the UI. Version format should be `v1.x.x`. Creating a new major version requires reaction from users and should be done only with breaking changes. Create a new release using the UI. Version format should be `vX.Y.Z`. Creating a new major version requires reaction from users and should be done only with breaking changes.
Once the new release is created, the v1 tag needs to be updated as well. Once the new release is created, the vX tag needs to be updated as well.
``` ```
git tag -fa v1 -m "Update v1 tag" git tag -fa vX -m "Update vX tag"
git push origin v1 --force git push origin vX --force
```
For example, if you're publishing v2:
```
git tag -fa v2 -m "Update v2 tag"
git push origin v2 --force
``` ```

File diff suppressed because it is too large Load Diff

View File

@ -135,6 +135,31 @@ get_legacy_os_name_from_platform() {
return 1 return 1
} }
get_legacy_os_name() {
eval $invocation
local uname=$(uname)
if [ "$uname" = "Darwin" ]; then
echo "osx"
return 0
elif [ -n "$runtime_id" ]; then
echo $(get_legacy_os_name_from_platform "${runtime_id%-*}" || echo "${runtime_id%-*}")
return 0
else
if [ -e /etc/os-release ]; then
. /etc/os-release
os=$(get_legacy_os_name_from_platform "$ID${VERSION_ID:+.${VERSION_ID}}" || echo "")
if [ -n "$os" ]; then
echo "$os"
return 0
fi
fi
fi
say_verbose "Distribution specific OS name and version could not be detected: UName = $uname"
return 1
}
get_linux_platform_name() { get_linux_platform_name() {
eval $invocation eval $invocation
@ -174,8 +199,8 @@ get_current_os_name() {
echo "freebsd" echo "freebsd"
return 0 return 0
elif [ "$uname" = "Linux" ]; then elif [ "$uname" = "Linux" ]; then
local linux_platform_name local linux_platform_name=""
linux_platform_name="$(get_linux_platform_name)" || { echo "linux" && return 0 ; } linux_platform_name="$(get_linux_platform_name)" || true
if [ "$linux_platform_name" = "rhel.6" ]; then if [ "$linux_platform_name" = "rhel.6" ]; then
echo $linux_platform_name echo $linux_platform_name
@ -196,39 +221,13 @@ get_current_os_name() {
return 1 return 1
} }
get_legacy_os_name() {
eval $invocation
local uname=$(uname)
if [ "$uname" = "Darwin" ]; then
echo "osx"
return 0
elif [ -n "$runtime_id" ]; then
echo $(get_legacy_os_name_from_platform "${runtime_id%-*}" || echo "${runtime_id%-*}")
return 0
else
if [ -e /etc/os-release ]; then
. /etc/os-release
os=$(get_legacy_os_name_from_platform "$ID${VERSION_ID:+.${VERSION_ID}}" || echo "")
if [ -n "$os" ]; then
echo "$os"
return 0
fi
fi
fi
say_verbose "Distribution specific OS name and version could not be detected: UName = $uname"
return 1
}
machine_has() { machine_has() {
eval $invocation eval $invocation
hash "$1" > /dev/null 2>&1 command -v "$1" > /dev/null 2>&1
return $? return $?
} }
check_min_reqs() { check_min_reqs() {
local hasMinimum=false local hasMinimum=false
if machine_has "curl"; then if machine_has "curl"; then
@ -321,11 +320,13 @@ get_normalized_architecture_from_architecture() {
eval $invocation eval $invocation
local architecture="$(to_lowercase "$1")" local architecture="$(to_lowercase "$1")"
case "$architecture" in
\<auto\>) if [[ $architecture == \<auto\> ]]; then
echo "$(get_normalized_architecture_from_architecture "$(get_machine_architecture)")" echo "$(get_machine_architecture)"
return 0 return 0
;; fi
case "$architecture" in
amd64|x64) amd64|x64)
echo "x64" echo "x64"
return 0 return 0
@ -425,6 +426,7 @@ get_normalized_channel() {
get_normalized_product() { get_normalized_product() {
eval $invocation eval $invocation
local product=""
local runtime="$(to_lowercase "$1")" local runtime="$(to_lowercase "$1")"
if [[ "$runtime" == "dotnet" ]]; then if [[ "$runtime" == "dotnet" ]]; then
product="dotnet-runtime" product="dotnet-runtime"
@ -446,7 +448,7 @@ get_normalized_product() {
# args: # args:
# version_text - stdin # version_text - stdin
get_version_from_version_info() { get_version_from_latestversion_file_content() {
eval $invocation eval $invocation
cat | tail -n 1 | sed 's/\r$//' cat | tail -n 1 | sed 's/\r$//'
@ -478,7 +480,7 @@ is_dotnet_package_installed() {
# azure_feed - $1 # azure_feed - $1
# channel - $2 # channel - $2
# normalized_architecture - $3 # normalized_architecture - $3
get_latest_version_info() { get_version_from_latestversion_file() {
eval $invocation eval $invocation
local azure_feed="$1" local azure_feed="$1"
@ -487,24 +489,24 @@ get_latest_version_info() {
local version_file_url=null local version_file_url=null
if [[ "$runtime" == "dotnet" ]]; then if [[ "$runtime" == "dotnet" ]]; then
version_file_url="$uncached_feed/Runtime/$channel/latest.version" version_file_url="$azure_feed/Runtime/$channel/latest.version"
elif [[ "$runtime" == "aspnetcore" ]]; then elif [[ "$runtime" == "aspnetcore" ]]; then
version_file_url="$uncached_feed/aspnetcore/Runtime/$channel/latest.version" version_file_url="$azure_feed/aspnetcore/Runtime/$channel/latest.version"
elif [ -z "$runtime" ]; then elif [ -z "$runtime" ]; then
version_file_url="$uncached_feed/Sdk/$channel/latest.version" version_file_url="$azure_feed/Sdk/$channel/latest.version"
else else
say_err "Invalid value for \$runtime" say_err "Invalid value for \$runtime"
return 1 return 1
fi fi
say_verbose "get_latest_version_info: latest url: $version_file_url" say_verbose "get_version_from_latestversion_file: latest url: $version_file_url"
download "$version_file_url" download "$version_file_url" || return $?
return $? return 0
} }
# args: # args:
# json_file - $1 # json_file - $1
parse_jsonfile_for_version() { parse_globaljson_file_for_version() {
eval $invocation eval $invocation
local json_file="$1" local json_file="$1"
@ -560,9 +562,9 @@ get_specific_version_from_version() {
if [ -z "$json_file" ]; then if [ -z "$json_file" ]; then
if [[ "$version" == "latest" ]]; then if [[ "$version" == "latest" ]]; then
local version_info local version_info
version_info="$(get_latest_version_info "$azure_feed" "$channel" "$normalized_architecture" false)" || return 1 version_info="$(get_version_from_latestversion_file "$azure_feed" "$channel" "$normalized_architecture" false)" || return 1
say_verbose "get_specific_version_from_version: version_info=$version_info" say_verbose "get_specific_version_from_version: version_info=$version_info"
echo "$version_info" | get_version_from_version_info echo "$version_info" | get_version_from_latestversion_file_content
return 0 return 0
else else
echo "$version" echo "$version"
@ -570,7 +572,7 @@ get_specific_version_from_version() {
fi fi
else else
local version_info local version_info
version_info="$(parse_jsonfile_for_version "$json_file")" || return 1 version_info="$(parse_globaljson_file_for_version "$json_file")" || return 1
echo "$version_info" echo "$version_info"
return 0 return 0
fi fi
@ -635,14 +637,16 @@ get_specific_product_version() {
if machine_has "curl" if machine_has "curl"
then then
specific_product_version=$(curl -s --fail "${download_link}${feed_credential}") if ! specific_product_version=$(curl -s --fail "${download_link}${feed_credential}" 2>&1); then
if [ $? = 0 ]; then continue
else
echo "${specific_product_version//[$'\t\r\n']}" echo "${specific_product_version//[$'\t\r\n']}"
return 0 return 0
fi fi
elif machine_has "wget" elif machine_has "wget"
then then
specific_product_version=$(wget -qO- "${download_link}${feed_credential}") specific_product_version=$(wget -qO- "${download_link}${feed_credential}" 2>&1)
if [ $? = 0 ]; then if [ $? = 0 ]; then
echo "${specific_product_version//[$'\t\r\n']}" echo "${specific_product_version//[$'\t\r\n']}"
return 0 return 0
@ -907,7 +911,7 @@ get_http_header_curl() {
fi fi
curl_options="-I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 " curl_options="-I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 "
curl $curl_options "$remote_path_with_credential" || return 1 curl $curl_options "$remote_path_with_credential" 2>&1 || return 1
return 0 return 0
} }
@ -918,15 +922,25 @@ get_http_header_wget() {
eval $invocation eval $invocation
local remote_path="$1" local remote_path="$1"
local disable_feed_credential="$2" local disable_feed_credential="$2"
local wget_options="-q -S --spider --tries 5 "
local wget_options_extra=''
# Test for options that aren't supported on all wget implementations.
if [[ $(wget -h 2>&1 | grep -E 'waitretry|connect-timeout') ]]; then
wget_options_extra="--waitretry 2 --connect-timeout 15 "
else
say "wget extra options are unavailable for this environment"
fi
remote_path_with_credential="$remote_path" remote_path_with_credential="$remote_path"
if [ "$disable_feed_credential" = false ]; then if [ "$disable_feed_credential" = false ]; then
remote_path_with_credential+="$feed_credential" remote_path_with_credential+="$feed_credential"
fi fi
wget_options="-q -S --spider --tries 5 --waitretry 2 --connect-timeout 15 " wget $wget_options $wget_options_extra "$remote_path_with_credential" 2>&1
wget $wget_options "$remote_path_with_credential" 2>&1 || return 1
return 0 return $?
} }
# args: # args:
@ -988,9 +1002,9 @@ downloadcurl() {
local curl_options="--retry 20 --retry-delay 2 --connect-timeout 15 -sSL -f --create-dirs " local curl_options="--retry 20 --retry-delay 2 --connect-timeout 15 -sSL -f --create-dirs "
local failed=false local failed=false
if [ -z "$out_path" ]; then if [ -z "$out_path" ]; then
curl $curl_options "$remote_path_with_credential" || failed=true curl $curl_options "$remote_path_with_credential" 2>&1 || failed=true
else else
curl $curl_options -o "$out_path" "$remote_path_with_credential" || failed=true curl $curl_options -o "$out_path" "$remote_path_with_credential" 2>&1 || failed=true
fi fi
if [ "$failed" = true ]; then if [ "$failed" = true ]; then
local disable_feed_credential=false local disable_feed_credential=false
@ -1016,14 +1030,27 @@ downloadwget() {
local out_path="${2:-}" local out_path="${2:-}"
# Append feed_credential as late as possible before calling wget to avoid logging feed_credential # Append feed_credential as late as possible before calling wget to avoid logging feed_credential
local remote_path_with_credential="${remote_path}${feed_credential}" local remote_path_with_credential="${remote_path}${feed_credential}"
local wget_options="--tries 20 --waitretry 2 --connect-timeout 15 " local wget_options="--tries 20 "
local failed=false
if [ -z "$out_path" ]; then local wget_options_extra=''
wget -q $wget_options -O - "$remote_path_with_credential" || failed=true local wget_result=''
# Test for options that aren't supported on all wget implementations.
if [[ $(wget -h 2>&1 | grep -E 'waitretry|connect-timeout') ]]; then
wget_options_extra="--waitretry 2 --connect-timeout 15 "
else else
wget $wget_options -O "$out_path" "$remote_path_with_credential" || failed=true say "wget extra options are unavailable for this environment"
fi fi
if [ "$failed" = true ]; then
if [ -z "$out_path" ]; then
wget -q $wget_options $wget_options_extra -O - "$remote_path_with_credential" 2>&1
wget_result=$?
else
wget $wget_options $wget_options_extra -O "$out_path" "$remote_path_with_credential" 2>&1
wget_result=$?
fi
if [[ $wget_result != 0 ]]; then
local disable_feed_credential=false local disable_feed_credential=false
local response=$(get_http_header_wget $remote_path $disable_feed_credential) local response=$(get_http_header_wget $remote_path $disable_feed_credential)
http_code=$( echo "$response" | awk '/^ HTTP/{print $2}' | tail -1 ) http_code=$( echo "$response" | awk '/^ HTTP/{print $2}' | tail -1 )
@ -1034,6 +1061,7 @@ downloadwget() {
say_verbose "$download_error_msg" say_verbose "$download_error_msg"
return 1 return 1
fi fi
return 0 return 0
} }
@ -1090,11 +1118,197 @@ get_download_link_from_aka_ms() {
fi fi
} }
get_feeds_to_use()
{
feeds=(
"https://dotnetcli.azureedge.net/dotnet"
"https://dotnetbuilds.azureedge.net/public"
)
if [[ -n "$azure_feed" ]]; then
feeds=("$azure_feed")
fi
if [[ "$no_cdn" == "true" ]]; then
feeds=(
"https://dotnetcli.blob.core.windows.net/dotnet"
"https://dotnetbuilds.blob.core.windows.net/public"
)
if [[ -n "$uncached_feed" ]]; then
feeds=("$uncached_feed")
fi
fi
}
# THIS FUNCTION MAY EXIT (if the determined version is already installed).
generate_download_links() {
download_links=()
specific_versions=()
effective_versions=()
link_types=()
# If generate_akams_links returns false, no fallback to old links. Just terminate.
# This function may also 'exit' (if the determined version is already installed).
generate_akams_links || return
# Check other feeds only if we haven't been able to find an aka.ms link.
if [[ "${#download_links[@]}" -lt 1 ]]; then
for feed in ${feeds[@]}
do
# generate_regular_links may also 'exit' (if the determined version is already installed).
generate_regular_links $feed || return
done
fi
if [[ "${#download_links[@]}" -eq 0 ]]; then
say_err "Failed to resolve the exact version number."
return 1
fi
say_verbose "Generated ${#download_links[@]} links."
for link_index in ${!download_links[@]}
do
say_verbose "Link $link_index: ${link_types[$link_index]}, ${effective_versions[$link_index]}, ${download_links[$link_index]}"
done
}
# THIS FUNCTION MAY EXIT (if the determined version is already installed).
generate_akams_links() {
local valid_aka_ms_link=true;
normalized_version="$(to_lowercase "$version")"
if [[ -n "$json_file" || "$normalized_version" != "latest" ]]; then
# aka.ms links are not needed when exact version is specified via command or json file
return
fi
get_download_link_from_aka_ms || valid_aka_ms_link=false
if [[ "$valid_aka_ms_link" == true ]]; then
say_verbose "Retrieved primary payload URL from aka.ms link: '$aka_ms_download_link'."
say_verbose "Downloading using legacy url will not be attempted."
download_link=$aka_ms_download_link
#get version from the path
IFS='/'
read -ra pathElems <<< "$download_link"
count=${#pathElems[@]}
specific_version="${pathElems[count-2]}"
unset IFS;
say_verbose "Version: '$specific_version'."
#Retrieve effective version
effective_version="$(get_specific_product_version "$azure_feed" "$specific_version" "$download_link")"
# Add link info to arrays
download_links+=($download_link)
specific_versions+=($specific_version)
effective_versions+=($effective_version)
link_types+=("aka.ms")
# Check if the SDK version is already installed.
if [[ "$dry_run" != true ]] && is_dotnet_package_installed "$install_root" "$asset_relative_path" "$effective_version"; then
say "$asset_name with version '$effective_version' is already installed."
exit 0
fi
return 0
fi
# if quality is specified - exit with error - there is no fallback approach
if [ ! -z "$normalized_quality" ]; then
say_err "Failed to locate the latest version in the channel '$normalized_channel' with '$normalized_quality' quality for '$normalized_product', os: '$normalized_os', architecture: '$normalized_architecture'."
say_err "Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support."
return 1
fi
say_verbose "Falling back to latest.version file approach."
}
# THIS FUNCTION MAY EXIT (if the determined version is already installed)
# args:
# feed - $1
generate_regular_links() {
local feed="$1"
local valid_legacy_download_link=true
specific_version=$(get_specific_version_from_version "$feed" "$channel" "$normalized_architecture" "$version" "$json_file") || specific_version='0'
if [[ "$specific_version" == '0' ]]; then
say_verbose "Failed to resolve the specific version number using feed '$feed'"
return
fi
effective_version="$(get_specific_product_version "$feed" "$specific_version")"
say_verbose "specific_version=$specific_version"
download_link="$(construct_download_link "$feed" "$channel" "$normalized_architecture" "$specific_version" "$normalized_os")"
say_verbose "Constructed primary named payload URL: $download_link"
# Add link info to arrays
download_links+=($download_link)
specific_versions+=($specific_version)
effective_versions+=($effective_version)
link_types+=("primary")
legacy_download_link="$(construct_legacy_download_link "$feed" "$channel" "$normalized_architecture" "$specific_version")" || valid_legacy_download_link=false
if [ "$valid_legacy_download_link" = true ]; then
say_verbose "Constructed legacy named payload URL: $legacy_download_link"
download_links+=($legacy_download_link)
specific_versions+=($specific_version)
effective_versions+=($effective_version)
link_types+=("legacy")
else
legacy_download_link=""
say_verbose "Cound not construct a legacy_download_link; omitting..."
fi
# Check if the SDK version is already installed.
if [[ "$dry_run" != true ]] && is_dotnet_package_installed "$install_root" "$asset_relative_path" "$effective_version"; then
say "$asset_name with version '$effective_version' is already installed."
exit 0
fi
}
print_dry_run() {
say "Payload URLs:"
for link_index in "${!download_links[@]}"
do
say "URL #$link_index - ${link_types[$link_index]}: ${download_links[$link_index]}"
done
resolved_version=${specific_versions[0]}
repeatable_command="./$script_name --version "\""$resolved_version"\"" --install-dir "\""$install_root"\"" --architecture "\""$normalized_architecture"\"" --os "\""$normalized_os"\"""
if [ ! -z "$normalized_quality" ]; then
repeatable_command+=" --quality "\""$normalized_quality"\"""
fi
if [[ "$runtime" == "dotnet" ]]; then
repeatable_command+=" --runtime "\""dotnet"\"""
elif [[ "$runtime" == "aspnetcore" ]]; then
repeatable_command+=" --runtime "\""aspnetcore"\"""
fi
repeatable_command+="$non_dynamic_parameters"
if [ -n "$feed_credential" ]; then
repeatable_command+=" --feed-credential "\""<feed_credential>"\"""
fi
say "Repeatable invocation: $repeatable_command"
}
calculate_vars() { calculate_vars() {
eval $invocation eval $invocation
valid_legacy_download_link=true
#normalize input variables script_name=$(basename "$0")
normalized_architecture="$(get_normalized_architecture_from_architecture "$architecture")" normalized_architecture="$(get_normalized_architecture_from_architecture "$architecture")"
say_verbose "Normalized architecture: '$normalized_architecture'." say_verbose "Normalized architecture: '$normalized_architecture'."
normalized_os="$(get_normalized_os "$user_defined_os")" normalized_os="$(get_normalized_os "$user_defined_os")"
@ -1105,76 +1319,8 @@ calculate_vars() {
say_verbose "Normalized channel: '$normalized_channel'." say_verbose "Normalized channel: '$normalized_channel'."
normalized_product="$(get_normalized_product "$runtime")" normalized_product="$(get_normalized_product "$runtime")"
say_verbose "Normalized product: '$normalized_product'." say_verbose "Normalized product: '$normalized_product'."
#try to get download location from aka.ms link
#not applicable when exact version is specified via command or json file
normalized_version="$(to_lowercase "$version")"
if [[ -z "$json_file" && "$normalized_version" == "latest" ]]; then
valid_aka_ms_link=true;
get_download_link_from_aka_ms || valid_aka_ms_link=false
if [ "$valid_aka_ms_link" == false ]; then
# if quality is specified - exit with error - there is no fallback approach
if [ ! -z "$normalized_quality" ]; then
say_err "Failed to locate the latest version in the channel '$normalized_channel' with '$normalized_quality' quality for '$normalized_product', os: '$normalized_os', architecture: '$normalized_architecture'."
say_err "Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support."
return 1
fi
say_verbose "Falling back to latest.version file approach."
else
say_verbose "Retrieved primary payload URL from aka.ms link: '$aka_ms_download_link'."
download_link=$aka_ms_download_link
say_verbose "Downloading using legacy url will not be attempted."
valid_legacy_download_link=false
#get version from the path
IFS='/'
read -ra pathElems <<< "$download_link"
count=${#pathElems[@]}
specific_version="${pathElems[count-2]}"
unset IFS;
say_verbose "Version: '$specific_version'."
#Retrieve product specific version
specific_product_version="$(get_specific_product_version "$azure_feed" "$specific_version" "$download_link")"
say_verbose "Product specific version: '$specific_product_version'."
install_root="$(resolve_installation_path "$install_dir")" install_root="$(resolve_installation_path "$install_dir")"
say_verbose "InstallRoot: '$install_root'." say_verbose "InstallRoot: '$install_root'."
return
fi
fi
specific_version="$(get_specific_version_from_version "$azure_feed" "$channel" "$normalized_architecture" "$version" "$json_file")"
specific_product_version="$(get_specific_product_version "$azure_feed" "$specific_version")"
say_verbose "specific_version=$specific_version"
if [ -z "$specific_version" ]; then
say_err "Could not resolve version information."
return 1
fi
download_link="$(construct_download_link "$azure_feed" "$channel" "$normalized_architecture" "$specific_version" "$normalized_os")"
say_verbose "Constructed primary named payload URL: $download_link"
legacy_download_link="$(construct_legacy_download_link "$azure_feed" "$channel" "$normalized_architecture" "$specific_version")" || valid_legacy_download_link=false
if [ "$valid_legacy_download_link" = true ]; then
say_verbose "Constructed legacy named payload URL: $legacy_download_link"
else
say_verbose "Cound not construct a legacy_download_link; omitting..."
fi
install_root="$(resolve_installation_path "$install_dir")"
say_verbose "InstallRoot: $install_root"
}
install_dotnet() {
eval $invocation
local download_failed=false
local asset_name=''
local asset_relative_path=''
if [[ "$runtime" == "dotnet" ]]; then if [[ "$runtime" == "dotnet" ]]; then
asset_relative_path="shared/Microsoft.NETCore.App" asset_relative_path="shared/Microsoft.NETCore.App"
@ -1185,84 +1331,52 @@ install_dotnet() {
elif [ -z "$runtime" ]; then elif [ -z "$runtime" ]; then
asset_relative_path="sdk" asset_relative_path="sdk"
asset_name=".NET Core SDK" asset_name=".NET Core SDK"
else
say_err "Invalid value for \$runtime"
return 1
fi fi
# Check if the SDK version is already installed. get_feeds_to_use
if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$specific_version"; then }
say "$asset_name version $specific_version is already installed."
return 0 install_dotnet() {
fi eval $invocation
local download_failed=false
local download_completed=false
mkdir -p "$install_root" mkdir -p "$install_root"
zip_path="$(mktemp "$temporary_file_template")" zip_path="$(mktemp "$temporary_file_template")"
say_verbose "Zip path: $zip_path" say_verbose "Zip path: $zip_path"
for link_index in "${!download_links[@]}"
do
download_link="${download_links[$link_index]}"
specific_version="${specific_versions[$link_index]}"
effective_version="${effective_versions[$link_index]}"
link_type="${link_types[$link_index]}"
# Failures are normal in the non-legacy case for ultimately legacy downloads. say "Attempting to download using $link_type link $download_link"
# Do not output to stderr, since output to stderr is considered an error.
say "Downloading primary link $download_link"
# The download function will set variables $http_code and $download_error_msg in case of failure. # The download function will set variables $http_code and $download_error_msg in case of failure.
download "$download_link" "$zip_path" 2>&1 || download_failed=true
# if the download fails, download the legacy_download_link
if [ "$download_failed" = true ]; then
primary_path_http_code="$http_code"; primary_path_download_error_msg="$download_error_msg"
case $primary_path_http_code in
404)
say "The resource at $download_link is not available."
;;
*)
say "$primary_path_download_error_msg"
;;
esac
rm -f "$zip_path" 2>&1 && say_verbose "Temporary zip file $zip_path was removed"
if [ "$valid_legacy_download_link" = true ]; then
download_failed=false download_failed=false
download_link="$legacy_download_link"
zip_path="$(mktemp "$temporary_file_template")"
say_verbose "Legacy zip path: $zip_path"
say "Downloading legacy link $download_link"
# The download function will set variables $http_code and $download_error_msg in case of failure.
download "$download_link" "$zip_path" 2>&1 || download_failed=true download "$download_link" "$zip_path" 2>&1 || download_failed=true
if [ "$download_failed" = true ]; then if [ "$download_failed" = true ]; then
legacy_path_http_code="$http_code"; legacy_path_download_error_msg="$download_error_msg" case $http_code in
case $legacy_path_http_code in
404) 404)
say "The resource at $download_link is not available." say "The resource at $link_type link '$download_link' is not available."
;; ;;
*) *)
say "$legacy_path_download_error_msg" say "Failed to download $link_type link '$download_link': $download_error_msg"
;; ;;
esac esac
rm -f "$zip_path" 2>&1 && say_verbose "Temporary zip file $zip_path was removed" rm -f "$zip_path" 2>&1 && say_verbose "Temporary zip file $zip_path was removed"
else
download_completed=true
break
fi fi
fi done
fi
if [ "$download_failed" = true ]; then if [[ "$download_completed" == false ]]; then
if [[ "$primary_path_http_code" = "404" && ( "$valid_legacy_download_link" = false || "$legacy_path_http_code" = "404") ]]; then
say_err "Could not find \`$asset_name\` with version = $specific_version" say_err "Could not find \`$asset_name\` with version = $specific_version"
say_err "Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support" say_err "Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support"
else
say_err "Could not download: \`$asset_name\` with version = $specific_version"
# 404-NotFound is an expected response if it goes from only one of the links, do not show that error.
# If primary path is available (not 404-NotFound) then show the primary error else show the legacy error.
if [ "$primary_path_http_code" != "404" ]; then
say_err "$primary_path_download_error_msg"
return 1
fi
if [[ "$valid_legacy_download_link" = true && "$legacy_path_http_code" != "404" ]]; then
say_err "$legacy_path_download_error_msg"
return 1
fi
fi
return 1 return 1
fi fi
@ -1283,14 +1397,14 @@ install_dotnet() {
fi fi
# Check if the standard SDK version is installed. # Check if the standard SDK version is installed.
say_verbose "Checking installation: version = $specific_product_version" say_verbose "Checking installation: version = $effective_version"
if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$specific_product_version"; then if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$effective_version"; then
return 0 return 0
fi fi
# Version verification failed. More likely something is wrong either with the downloaded content or with the verification algorithm. # Version verification failed. More likely something is wrong either with the downloaded content or with the verification algorithm.
say_err "Failed to verify the version of installed \`$asset_name\`.\nInstallation source: $download_link.\nInstallation location: $install_root.\nReport the bug at https://github.com/dotnet/install-scripts/issues." say_err "Failed to verify the version of installed \`$asset_name\`.\nInstallation source: $download_link.\nInstallation location: $install_root.\nReport the bug at https://github.com/dotnet/install-scripts/issues."
say_err "\`$asset_name\` with version = $specific_product_version failed to install with an unknown error." say_err "\`$asset_name\` with version = $effective_version failed to install with an error."
return 1 return 1
} }
@ -1308,8 +1422,8 @@ architecture="<auto>"
dry_run=false dry_run=false
no_path=false no_path=false
no_cdn=false no_cdn=false
azure_feed="https://dotnetcli.azureedge.net/dotnet" azure_feed=""
uncached_feed="https://dotnetcli.blob.core.windows.net/dotnet" uncached_feed=""
feed_credential="" feed_credential=""
verbose=false verbose=false
runtime="" runtime=""
@ -1434,7 +1548,7 @@ do
echo " - 3-part version in a format A.B.Cxx - represents a specific SDK release" echo " - 3-part version in a format A.B.Cxx - represents a specific SDK release"
echo " examples: 5.0.1xx, 5.0.2xx." echo " examples: 5.0.1xx, 5.0.2xx."
echo " Supported since 5.0 release" echo " Supported since 5.0 release"
echo " Note: The version parameter overrides the channel parameter when any version other than `latest` is used." echo " Note: The version parameter overrides the channel parameter when any version other than 'latest' is used."
echo " -v,--version <VERSION> Use specific VERSION, Defaults to \`$version\`." echo " -v,--version <VERSION> Use specific VERSION, Defaults to \`$version\`."
echo " -Version" echo " -Version"
echo " Possible values:" echo " Possible values:"
@ -1447,7 +1561,7 @@ do
echo " Works only in combination with channel. Not applicable for current and LTS channels and will be ignored if those channels are used." echo " Works only in combination with channel. Not applicable for current and LTS channels and will be ignored if those channels are used."
echo " For SDK use channel in A.B.Cxx format. Using quality for SDK together with channel in A.B format is not supported." echo " For SDK use channel in A.B.Cxx format. Using quality for SDK together with channel in A.B format is not supported."
echo " Supported since 5.0 release." echo " Supported since 5.0 release."
echo " Note: The version parameter overrides the channel parameter when any version other than `latest` is used, and therefore overrides the quality." echo " Note: The version parameter overrides the channel parameter when any version other than 'latest' is used, and therefore overrides the quality."
echo " --internal,-Internal Download internal builds. Requires providing credentials via --feed-credential parameter." echo " --internal,-Internal Download internal builds. Requires providing credentials via --feed-credential parameter."
echo " --feed-credential <FEEDCREDENTIAL> Token to access Azure feed. Used as a query string to append to the Azure feed." echo " --feed-credential <FEEDCREDENTIAL> Token to access Azure feed. Used as a query string to append to the Azure feed."
echo " -FeedCredential This parameter typically is not specified." echo " -FeedCredential This parameter typically is not specified."
@ -1469,8 +1583,12 @@ do
echo " --dry-run,-DryRun Do not perform installation. Display download link." echo " --dry-run,-DryRun Do not perform installation. Display download link."
echo " --no-path, -NoPath Do not set PATH for the current process." echo " --no-path, -NoPath Do not set PATH for the current process."
echo " --verbose,-Verbose Display diagnostics information." echo " --verbose,-Verbose Display diagnostics information."
echo " --azure-feed,-AzureFeed Azure feed location. Defaults to $azure_feed, This parameter typically is not changed by the user." echo " --azure-feed,-AzureFeed For internal use only."
echo " --uncached-feed,-UncachedFeed Uncached feed location. This parameter typically is not changed by the user." echo " Allows using a different storage to download SDK archives from."
echo " This parameter is only used if --no-cdn is false."
echo " --uncached-feed,-UncachedFeed For internal use only."
echo " Allows using a different storage to download SDK archives from."
echo " This parameter is only used if --no-cdn is true."
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable." echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
echo " -SkipNonVersionedFiles" echo " -SkipNonVersionedFiles"
echo " --no-cdn,-NoCdn Disable downloading from the Azure CDN, and use the uncached feed directly." echo " --no-cdn,-NoCdn Disable downloading from the Azure CDN, and use the uncached feed directly."
@ -1478,14 +1596,6 @@ do
echo " Note: global.json must have a value for 'SDK:Version'" echo " Note: global.json must have a value for 'SDK:Version'"
echo " -?,--?,-h,--help,-Help Shows this help message" echo " -?,--?,-h,--help,-Help Shows this help message"
echo "" echo ""
echo "Obsolete parameters:"
echo " --shared-runtime The recommended alternative is '--runtime dotnet'."
echo " This parameter is obsolete and may be removed in a future version of this script."
echo " Installs just the shared runtime bits, not the entire SDK."
echo " --runtime-id Installs the .NET Tools for the given platform (use linux-x64 for portable linux)."
echo " -RuntimeId" The parameter is obsolete and may be removed in a future version of this script. Should be used only for versions below 2.1.
echo " For primary links to override OS or/and architecture, use --os and --architecture option instead."
echo ""
echo "Install Location:" echo "Install Location:"
echo " Location is chosen in following order:" echo " Location is chosen in following order:"
echo " - --install-dir option" echo " - --install-dir option"
@ -1502,10 +1612,6 @@ do
shift shift
done done
if [ "$no_cdn" = true ]; then
azure_feed="$uncached_feed"
fi
say "Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:" say "Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:"
say "- The SDK needs to be installed without user interaction and without admin rights." say "- The SDK needs to be installed without user interaction and without admin rights."
say "- The SDK installation doesn't need to persist across multiple CI runs." say "- The SDK installation doesn't need to persist across multiple CI runs."
@ -1523,33 +1629,11 @@ fi
check_min_reqs check_min_reqs
calculate_vars calculate_vars
script_name=$(basename "$0") # generate_regular_links call below will 'exit' if the determined version is already installed.
generate_download_links
if [ "$dry_run" = true ]; then if [[ "$dry_run" = true ]]; then
say "Payload URLs:" print_dry_run
say "Primary named payload URL: ${download_link}"
if [ "$valid_legacy_download_link" = true ]; then
say "Legacy named payload URL: ${legacy_download_link}"
fi
repeatable_command="./$script_name --version "\""$specific_version"\"" --install-dir "\""$install_root"\"" --architecture "\""$normalized_architecture"\"" --os "\""$normalized_os"\"""
if [ ! -z "$normalized_quality" ]; then
repeatable_command+=" --quality "\""$normalized_quality"\"""
fi
if [[ "$runtime" == "dotnet" ]]; then
repeatable_command+=" --runtime "\""dotnet"\"""
elif [[ "$runtime" == "aspnetcore" ]]; then
repeatable_command+=" --runtime "\""aspnetcore"\"""
fi
repeatable_command+="$non_dynamic_parameters"
if [ -n "$feed_credential" ]; then
repeatable_command+=" --feed-credential "\""<feed_credential>"\"""
fi
say "Repeatable invocation: $repeatable_command"
exit 0 exit 0
fi fi

8831
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.6.0",
"@actions/exec": "^1.0.4", "@actions/exec": "^1.0.4",
"@actions/github": "^1.1.0", "@actions/github": "^1.1.0",
"@actions/http-client": "^1.0.8", "@actions/http-client": "^1.0.8",
@ -40,15 +40,15 @@
"xmlbuilder": "^13.0.2" "xmlbuilder": "^13.0.2"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^25.2.3", "@types/jest": "^27.0.2",
"@types/node": "^12.12.62", "@types/node": "^16.11.25",
"@types/semver": "^6.2.2", "@types/semver": "^6.2.2",
"@zeit/ncc": "^0.21.1", "@vercel/ncc": "^0.33.4",
"husky": "^4.3.0", "husky": "^7.0.2",
"jest": "^26.4.2", "jest": "^27.2.5",
"jest-circus": "^26.4.2", "jest-circus": "^27.2.5",
"prettier": "^1.19.1", "prettier": "^1.19.1",
"ts-jest": "^26.4.0", "ts-jest": "^27.0.5",
"typescript": "^3.9.7", "typescript": "^3.9.7",
"wget-improved": "^3.2.1" "wget-improved": "^3.2.1"
}, },

View File

@ -165,6 +165,12 @@ export class DotnetCoreInstaller {
}); });
} }
if (resultCode != 0) {
throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
}
}
static addToPath() {
if (process.env['DOTNET_INSTALL_DIR']) { if (process.env['DOTNET_INSTALL_DIR']) {
core.addPath(process.env['DOTNET_INSTALL_DIR']); core.addPath(process.env['DOTNET_INSTALL_DIR']);
core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']); core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']);
@ -189,10 +195,6 @@ export class DotnetCoreInstaller {
} }
console.log(process.env['PATH']); console.log(process.env['PATH']);
if (resultCode != 0) {
throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
}
} }
// versionInfo - versionInfo of the SDK/Runtime // versionInfo - versionInfo of the SDK/Runtime
@ -283,7 +285,14 @@ export class DotnetCoreInstaller {
); );
} }
return releasesInfo[0]['releases.json']; const releaseInfo = releasesInfo[0];
if (releaseInfo['support-phase'] === 'eol') {
core.warning(
`${releaseInfo['product']} ${releaseInfo['channel-version']} is no longer supported and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the .NET support policy.`
);
}
return releaseInfo['releases.json'];
} }
private version: string; private version: string;

View File

@ -9,37 +9,48 @@ 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 version = core.getInput('dotnet-version'); let versions = core.getMultilineInput('dotnet-version');
if (!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) {
// 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');
const globalJsonPath = path.join(process.cwd(), 'global.json'); const globalJsonPath = path.join(process.cwd(), 'global.json');
if (fs.existsSync(globalJsonPath)) { if (fs.existsSync(globalJsonPath)) {
const globalJson = JSON.parse( versions.push(getVersionFromGlobalJson(globalJsonPath));
// .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649
fs.readFileSync(globalJsonPath, {encoding: 'utf8'}).trim()
);
if (globalJson.sdk && globalJson.sdk.version) {
version = globalJson.sdk.version;
}
} }
} }
if (version) { if (versions.length) {
const includePrerelease: boolean = const includePrerelease: boolean =
(core.getInput('include-prerelease') || 'false').toLowerCase() === (core.getInput('include-prerelease') || 'false').toLowerCase() ===
'true'; 'true';
let dotnetInstaller!: installer.DotnetCoreInstaller;
const dotnetInstaller = new installer.DotnetCoreInstaller( for (const version of new Set<string>(versions)) {
dotnetInstaller = new installer.DotnetCoreInstaller(
version, version,
includePrerelease includePrerelease
); );
await dotnetInstaller.installDotnet(); await dotnetInstaller.installDotnet();
} }
installer.DotnetCoreInstaller.addToPath();
}
const sourceUrl: string = core.getInput('source-url'); const sourceUrl: string = core.getInput('source-url');
const configFile: string = core.getInput('config-file'); const configFile: string = core.getInput('config-file');
@ -54,4 +65,21 @@ export async function run() {
} }
} }
function getVersionFromGlobalJson(globalJsonPath: string): string {
let version: string = '';
const globalJson = JSON.parse(
// .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649
fs.readFileSync(globalJsonPath, {encoding: 'utf8'}).trim()
);
if (globalJson.sdk && globalJson.sdk.version) {
version = globalJson.sdk.version;
const rollForward = globalJson.sdk.rollForward;
if (rollForward && rollForward === 'latestFeature') {
const [major, minor] = version.split('.');
version = `${major}.${minor}`;
}
}
return version;
}
run(); run();