mirror of
https://github.com/actions/setup-dotnet.git
synced 2026-03-24 07:32:18 +08:00
Compare commits
221 Commits
v1.0.1
...
v-malob/up
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f71fcfa81 | ||
|
|
6803d4b94d | ||
|
|
3c80e97cbd | ||
|
|
8d30c127da | ||
|
|
2d101adc9f | ||
|
|
c8b60fb6bf | ||
|
|
bea420f2fd | ||
|
|
3a3dbe976e | ||
|
|
ce38f90a9a | ||
|
|
c32ed2108b | ||
|
|
d99c06115d | ||
|
|
f311b6d978 | ||
|
|
9427b17c42 | ||
|
|
f39691d155 | ||
|
|
19e6ad3fe0 | ||
|
|
efeb86e5ce | ||
|
|
8e5c71c8f8 | ||
|
|
c0d7255256 | ||
|
|
c1ca14bb7b | ||
|
|
e1655545c1 | ||
|
|
2a58294d0c | ||
|
|
92ffa484b1 | ||
|
|
3698118d95 | ||
|
|
cfb7e25be1 | ||
|
|
5865234247 | ||
|
|
0cb99b2a12 | ||
|
|
4a01d86a5b | ||
|
|
1c7be1087d | ||
|
|
ac1baccba4 | ||
|
|
92451e3d46 | ||
|
|
a841c568fd | ||
|
|
5d1a72cb19 | ||
|
|
8889c6748f | ||
|
|
f4159a6d20 | ||
|
|
7164f75e01 | ||
|
|
44b8627225 | ||
|
|
054db1cac2 | ||
|
|
1317beb53a | ||
|
|
fabe7d52fe | ||
|
|
993f819e3d | ||
|
|
831e0d4070 | ||
|
|
bb2233aaa5 | ||
|
|
24ed2d0102 | ||
|
|
059f1aa99b | ||
|
|
5c5ac76dc6 | ||
|
|
a0f70ab98c | ||
|
|
5dcd27b0bc | ||
|
|
79735df611 | ||
|
|
a1105722ad | ||
|
|
131ac602dc | ||
|
|
c8cb48ba8b | ||
|
|
7bbfec324f | ||
|
|
6b7d951977 | ||
|
|
c7eaa2ec00 | ||
|
|
8807004b20 | ||
|
|
2d640ec739 | ||
|
|
53b5bae1f6 | ||
|
|
45c0959fcd | ||
|
|
d33a835564 | ||
|
|
347456b934 | ||
|
|
76a91b1af8 | ||
|
|
9d49fb8e98 | ||
|
|
10ad86dc12 | ||
|
|
71f0d4bd07 | ||
|
|
7669e56997 | ||
|
|
c8cf369c29 | ||
|
|
6ade6c061b | ||
|
|
843b5197ce | ||
|
|
a3d47e556c | ||
|
|
7261940ea5 | ||
|
|
8ada5b5558 | ||
|
|
62230c5409 | ||
|
|
51b6fb2610 | ||
|
|
c47b497cff | ||
|
|
975b958e4c | ||
|
|
13bccd131e | ||
|
|
daad66578a | ||
|
|
29c0c6cee8 | ||
|
|
5551aab1c3 | ||
|
|
9a46dbb681 | ||
|
|
8336fd394b | ||
|
|
51f68377c1 | ||
|
|
7a98346f51 | ||
|
|
8aad93f856 | ||
|
|
9d7c66c348 | ||
|
|
a1c7110c2a | ||
|
|
352338157c | ||
|
|
3569a93d9f | ||
|
|
985d576ba0 | ||
|
|
52dbd90938 | ||
|
|
d50c2980a5 | ||
|
|
b409ac80d1 | ||
|
|
4f53c95c39 | ||
|
|
bc0200672b | ||
|
|
3fdf140cf1 | ||
|
|
221e7bcc3b | ||
|
|
37b9e8b54a | ||
|
|
bedd981d16 | ||
|
|
422ae8cdee | ||
|
|
e3d81d9453 | ||
|
|
c7a4f4e270 | ||
|
|
55885b7a99 | ||
|
|
7a84008633 | ||
|
|
b8681684f4 | ||
|
|
908a1a8267 | ||
|
|
9e01770f11 | ||
|
|
9bdaa47c80 | ||
|
|
7621179156 | ||
|
|
81ca5f786c | ||
|
|
257d9b2a19 | ||
|
|
61ee7d7a72 | ||
|
|
3af4b91f2c | ||
|
|
fe319a6b7f | ||
|
|
20a4db787c | ||
|
|
80a21d447c | ||
|
|
4114018c87 | ||
|
|
7df9f59802 | ||
|
|
a4ec20650e | ||
|
|
b7a80c5d92 | ||
|
|
3648b37cf8 | ||
|
|
73683e5d2f | ||
|
|
232f64b253 | ||
|
|
5091cc16d9 | ||
|
|
a40afdb08e | ||
|
|
3c9d15de90 | ||
|
|
400e687804 | ||
|
|
8388fb6ff7 | ||
|
|
6efb2bd78f | ||
|
|
e169331466 | ||
|
|
40390722c2 | ||
|
|
fe5534da38 | ||
|
|
983c8ef1bd | ||
|
|
a8eaac54ab | ||
|
|
82b9a8ff02 | ||
|
|
392189ddd3 | ||
|
|
db2ebd0903 | ||
|
|
7895df17cc | ||
|
|
308b9ff32c | ||
|
|
a0982bfd3a | ||
|
|
994f136361 | ||
|
|
7b228edf43 | ||
|
|
3894eede2d | ||
|
|
3de417d35c | ||
|
|
c5ee7a1134 | ||
|
|
4051f74532 | ||
|
|
3eb0d2f3dd | ||
|
|
08fb271bd7 | ||
|
|
3426e11858 | ||
|
|
ebefd7bccb | ||
|
|
5411b6342a | ||
|
|
a5cce9bf9f | ||
|
|
561f9e2075 | ||
|
|
fd402244d0 | ||
|
|
00f2601192 | ||
|
|
cf5f899a30 | ||
|
|
b7821147f5 | ||
|
|
0f6f11a751 | ||
|
|
5454f3aaca | ||
|
|
d41fb1f9ff | ||
|
|
dccf26c63e | ||
|
|
8886b529ee | ||
|
|
a874136a06 | ||
|
|
73b32e9eb3 | ||
|
|
e322cead28 | ||
|
|
6f7ce4eb35 | ||
|
|
d9fc1a3671 | ||
|
|
334021833c | ||
|
|
6b27526581 | ||
|
|
6f2692a991 | ||
|
|
862351c093 | ||
|
|
2b9a6b7c15 | ||
|
|
be484e6cb4 | ||
|
|
932d77f347 | ||
|
|
434fa5bb66 | ||
|
|
45d3fa9f89 | ||
|
|
702f623645 | ||
|
|
44b1ef7444 | ||
|
|
2e3dd8fe60 | ||
|
|
dc257a3a4f | ||
|
|
9e7ce49a73 | ||
|
|
c4b619a553 | ||
|
|
dd19a56732 | ||
|
|
09cc69fecb | ||
|
|
167e5cb271 | ||
|
|
ff633a565f | ||
|
|
154c08aac4 | ||
|
|
bad4a23450 | ||
|
|
80b3560659 | ||
|
|
a3e2a47c75 | ||
|
|
474fe34688 | ||
|
|
719c622d48 | ||
|
|
72d0d3c8b3 | ||
|
|
8f1bb3f9c3 | ||
|
|
e1b1954735 | ||
|
|
79b009fc57 | ||
|
|
c0e4e5bdd4 | ||
|
|
76585d940e | ||
|
|
bb17c31beb | ||
|
|
bb95ce727f | ||
|
|
cc372bb13c | ||
|
|
86c0b21a03 | ||
|
|
d6b77de15f | ||
|
|
d9c317d9d5 | ||
|
|
c61e78b585 | ||
|
|
2f00ce2a3e | ||
|
|
70528ac007 | ||
|
|
6bd4969ec6 | ||
|
|
6c0e2a2a6b | ||
|
|
a668ade667 | ||
|
|
e28ad717b8 | ||
|
|
f7896b6c4c | ||
|
|
a2db70294c | ||
|
|
1c11308e52 | ||
|
|
56ad7c6927 | ||
|
|
83427067c7 | ||
|
|
c0fa767caa | ||
|
|
e6a15e9035 | ||
|
|
553ff3fdfc | ||
|
|
8b1e9ddf26 | ||
|
|
db362d751e | ||
|
|
3280df5864 |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.licenses/** -diff linguist-generated=true
|
||||||
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
* @actions/virtual-environments-owners
|
||||||
32
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
32
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a bug report
|
||||||
|
title: ''
|
||||||
|
labels: bug, needs triage
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Description:**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**Task version:**
|
||||||
|
Specify the task version
|
||||||
|
|
||||||
|
**Platform:**
|
||||||
|
- [ ] Ubuntu
|
||||||
|
- [ ] macOS
|
||||||
|
- [ ] Windows
|
||||||
|
|
||||||
|
**Runner type:**
|
||||||
|
- [ ] Hosted
|
||||||
|
- [ ] Self-hosted
|
||||||
|
|
||||||
|
**Repro steps:**
|
||||||
|
A description with steps to reproduce the issue. If your have a public example or repo to share, please provide the link.
|
||||||
|
|
||||||
|
**Expected behavior:**
|
||||||
|
A description of what you expected to happen.
|
||||||
|
|
||||||
|
**Actual behavior:**
|
||||||
|
A description of what is actually happening.
|
||||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: .NET issues
|
||||||
|
url: https://github.com/dotnet/runtime#filing-issues
|
||||||
|
about: Issues with the runtime, class libraries, frameworks, and SDK should be addressed directly with the .NET team. Documentation on filing issues can be found here.
|
||||||
16
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
16
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: feature request, needs triage
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
**Description:**
|
||||||
|
Describe your proposal.
|
||||||
|
|
||||||
|
**Justification:**
|
||||||
|
Justification or a use case for your proposal.
|
||||||
|
|
||||||
|
**Are you willing to submit a PR?**
|
||||||
|
<!--- We accept contributions! -->
|
||||||
9
.github/csc.json
vendored
9
.github/csc.json
vendored
@@ -4,14 +4,15 @@
|
|||||||
"owner": "csc",
|
"owner": "csc",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
{
|
{
|
||||||
"regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(CS\\d+)\\s*:\\s*(.*)$",
|
"regexp": "^([^\\s].*)\\((\\d+)(?:,\\d+|,\\d+,\\d+)?\\):\\s+(error|warning)\\s+([a-zA-Z]+(?<!MSB)\\d+):\\s*(.*?)\\s+\\[(.*?)\\]$",
|
||||||
"file": 1,
|
"file": 1,
|
||||||
"location": 2,
|
"line": 2,
|
||||||
"severity": 3,
|
"severity": 3,
|
||||||
"code": 4,
|
"code": 4,
|
||||||
"message": 5
|
"message": 5,
|
||||||
|
"fromPath": 6
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
9
.github/pull_request_template.md
vendored
Normal file
9
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
**Description:**
|
||||||
|
Describe your changes.
|
||||||
|
|
||||||
|
**Related issue:**
|
||||||
|
Add link to the related issue.
|
||||||
|
|
||||||
|
**Check list:**
|
||||||
|
- [ ] Mark if documentation changes are required.
|
||||||
|
- [ ] Mark if tests were added or updated to cover the changes.
|
||||||
20
.github/workflows/licensed.yml
vendored
Normal file
20
.github/workflows/licensed.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: Licensed
|
||||||
|
|
||||||
|
on:
|
||||||
|
push: {branches: main}
|
||||||
|
pull_request: {branches: main}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Check licenses
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- run: npm ci
|
||||||
|
- name: Install licensed
|
||||||
|
run: |
|
||||||
|
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
|
||||||
|
sudo tar -xzf licensed.tar.gz
|
||||||
|
sudo mv licensed /usr/local/bin/licensed
|
||||||
|
- run: licensed status
|
||||||
37
.github/workflows/test-dotnet.yml
vendored
Normal file
37
.github/workflows/test-dotnet.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
name: Validate dotnet
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- releases/*
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
setup-version:
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
dotnet-version: ['2.1', '2.2', '3.0', '3.1', '5.0']
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Clear toolcache
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
|
- name: Setup dotnet ${{ matrix.dotnet-version }}
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
dotnet-version: ${{ matrix.dotnet-version }}
|
||||||
|
- name: Check installed version
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
$version = & dotnet --version
|
||||||
|
Write-Host "Installed version: $version"
|
||||||
|
if (-not $version.StartsWith("${{ matrix.dotnet-version }}")) { throw "Unexpected version" }
|
||||||
196
.github/workflows/workflow.yml
vendored
196
.github/workflows/workflow.yml
vendored
@@ -1,26 +1,192 @@
|
|||||||
name: Main workflow
|
name: Main workflow
|
||||||
on: [push]
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- releases/*
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run:
|
build:
|
||||||
name: Run
|
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest]
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v2
|
||||||
|
- name: Set Node.js 12
|
||||||
- name: Set Node.js 10.x
|
uses: actions/setup-node@v1
|
||||||
uses: actions/setup-node@master
|
|
||||||
with:
|
with:
|
||||||
version: 10.x
|
node-version: 12.x
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run build
|
||||||
|
- run: npm run format-check
|
||||||
|
- run: npm test
|
||||||
|
- name: Verify no unstaged changes
|
||||||
|
if: runner.os != 'windows'
|
||||||
|
run: __tests__/verify-no-unstaged-changes.sh
|
||||||
|
|
||||||
- name: npm install
|
test-setup-full-version:
|
||||||
run: npm install
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Clear toolcache
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
|
# Side-by-side install of 2.2 and 3.1 used for the test project
|
||||||
|
- name: Setup dotnet 2.2.402
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
dotnet-version: 2.2.402
|
||||||
|
- name: Setup dotnet 3.1.201
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
dotnet-version: 3.1.201
|
||||||
|
# We are including this veriable to force the generation of the nuget config file to verify that it is created in the correct place
|
||||||
|
source-url: https://api.nuget.org/v3/index.json
|
||||||
|
env:
|
||||||
|
NUGET_AUTH_TOKEN: NOTATOKEN
|
||||||
|
- name: Verify nuget config file
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
if (-Not (Test-Path "../nuget.config")) { throw "nuget file not generated correctly" }
|
||||||
|
- name: Verify dotnet
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/verify-dotnet.ps1 3.1.201 2.2.402
|
||||||
|
|
||||||
- name: Lint
|
test-setup-without-patch-version:
|
||||||
run: npm run format-check
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Clear toolcache
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
|
# 2.0, 3.0, 5.0 needs to be in single quotes to interpret as a string instead of as an integer
|
||||||
|
- name: Setup dotnet '3.1'
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
dotnet-version: '3.1'
|
||||||
|
- name: Setup dotnet '2.2'
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
dotnet-version: '2.2'
|
||||||
|
- name: Verify dotnet
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/verify-dotnet.ps1 3.1 2.2
|
||||||
|
|
||||||
|
test-setup-latest-patch-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@v2
|
||||||
|
- name: Clear toolcache
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
|
- name: Setup dotnet 3.1.x
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
dotnet-version: 3.1.x
|
||||||
|
- name: Setup dotnet 2.2.x
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
dotnet-version: 2.2.x
|
||||||
|
- name: Verify dotnet
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/verify-dotnet.ps1 3.1 2.2
|
||||||
|
|
||||||
- name: npm test
|
test-setup-with-wildcard:
|
||||||
run: npm test
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Clear toolcache
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
|
- name: Setup dotnet 3.1.*
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
dotnet-version: 3.1.*
|
||||||
|
- name: Setup dotnet 2.2.*
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
dotnet-version: 2.2.*
|
||||||
|
- name: Verify dotnet
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/verify-dotnet.ps1 3.1 2.2
|
||||||
|
|
||||||
|
test-proxy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: mcr.microsoft.com/dotnet/core/runtime-deps:3.0-bionic
|
||||||
|
options: --dns 127.0.0.1
|
||||||
|
services:
|
||||||
|
squid-proxy:
|
||||||
|
image: datadog/squid:latest
|
||||||
|
ports:
|
||||||
|
- 3128:3128
|
||||||
|
env:
|
||||||
|
https_proxy: http://squid-proxy:3128
|
||||||
|
http_proxy: http://squid-proxy:3128
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Clear tool cache
|
||||||
|
run: rm -rf "/usr/share/dotnet"
|
||||||
|
- name: Install curl
|
||||||
|
run: |
|
||||||
|
apt update
|
||||||
|
apt -y install curl
|
||||||
|
- name: Setup dotnet 3.1.201
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
dotnet-version: 3.1.201
|
||||||
|
source-url: https://api.nuget.org/v3/index.json
|
||||||
|
env:
|
||||||
|
NUGET_AUTH_TOKEN: NOTATOKEN
|
||||||
|
- name: Verify dotnet
|
||||||
|
run: __tests__/verify-dotnet.sh 3.1.201
|
||||||
|
|
||||||
|
test-bypass-proxy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
https_proxy: http://no-such-proxy:3128
|
||||||
|
no_proxy: github.com,dotnetcli.blob.core.windows.net,download.visualstudio.microsoft.com,api.nuget.org,dotnetcli.azureedge.net
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Clear tool cache
|
||||||
|
run: rm -rf "/usr/share/dotnet"
|
||||||
|
- name: Setup dotnet 3.1.201
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
dotnet-version: 3.1.201
|
||||||
|
source-url: https://api.nuget.org/v3/index.json
|
||||||
|
env:
|
||||||
|
NUGET_AUTH_TOKEN: NOTATOKEN
|
||||||
|
- name: Verify dotnet
|
||||||
|
run: __tests__/verify-dotnet.sh 3.1.201
|
||||||
|
|||||||
104
.gitignore
vendored
104
.gitignore
vendored
@@ -1,7 +1,99 @@
|
|||||||
# runtime dependencies are checked in
|
|
||||||
# dev dependencies are *not* checked in
|
# dev dependencies are *not* checked in
|
||||||
node_modules/.bin
|
global.json
|
||||||
node_modules/typescript
|
lib/
|
||||||
node_modules/@types
|
node_modules/
|
||||||
node_modules/prettier
|
__tests__/runner/*
|
||||||
__tests__/runner/*
|
__tests__/sample-csproj/bin/
|
||||||
|
__tests__/sample-csproj/obj/
|
||||||
|
|
||||||
|
# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# TypeScript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# nuxt.js build output
|
||||||
|
.nuxt
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# Ignore .vscode files
|
||||||
|
.vscode/
|
||||||
14
.licensed.yml
Normal file
14
.licensed.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
sources:
|
||||||
|
npm: true
|
||||||
|
|
||||||
|
allowed:
|
||||||
|
- apache-2.0
|
||||||
|
- bsd-2-clause
|
||||||
|
- bsd-3-clause
|
||||||
|
- isc
|
||||||
|
- mit
|
||||||
|
- cc0-1.0
|
||||||
|
- unlicense
|
||||||
|
|
||||||
|
reviewed:
|
||||||
|
npm:
|
||||||
BIN
.licenses/npm/@actions/core.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/core.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@actions/exec.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/exec.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@actions/github.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/github.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@actions/http-client.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/http-client.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@actions/io.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/io.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@octokit/endpoint.dep.yml
generated
Normal file
BIN
.licenses/npm/@octokit/endpoint.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@octokit/graphql.dep.yml
generated
Normal file
BIN
.licenses/npm/@octokit/graphql.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@octokit/request-error.dep.yml
generated
Normal file
BIN
.licenses/npm/@octokit/request-error.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@octokit/request.dep.yml
generated
Normal file
BIN
.licenses/npm/@octokit/request.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@octokit/rest.dep.yml
generated
Normal file
BIN
.licenses/npm/@octokit/rest.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/atob-lite.dep.yml
generated
Normal file
BIN
.licenses/npm/atob-lite.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/before-after-hook.dep.yml
generated
Normal file
BIN
.licenses/npm/before-after-hook.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/btoa-lite.dep.yml
generated
Normal file
BIN
.licenses/npm/btoa-lite.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/cross-spawn.dep.yml
generated
Normal file
BIN
.licenses/npm/cross-spawn.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/deprecation.dep.yml
generated
Normal file
BIN
.licenses/npm/deprecation.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/end-of-stream.dep.yml
generated
Normal file
BIN
.licenses/npm/end-of-stream.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/execa.dep.yml
generated
Normal file
BIN
.licenses/npm/execa.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/fast-xml-parser.dep.yml
generated
Normal file
BIN
.licenses/npm/fast-xml-parser.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/get-stream.dep.yml
generated
Normal file
BIN
.licenses/npm/get-stream.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/is-plain-object.dep.yml
generated
Normal file
BIN
.licenses/npm/is-plain-object.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/is-stream.dep.yml
generated
Normal file
BIN
.licenses/npm/is-stream.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/isexe.dep.yml
generated
Normal file
BIN
.licenses/npm/isexe.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/isobject.dep.yml
generated
Normal file
BIN
.licenses/npm/isobject.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/lodash.get.dep.yml
generated
Normal file
BIN
.licenses/npm/lodash.get.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/lodash.set.dep.yml
generated
Normal file
BIN
.licenses/npm/lodash.set.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/lodash.uniq.dep.yml
generated
Normal file
BIN
.licenses/npm/lodash.uniq.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/macos-release.dep.yml
generated
Normal file
BIN
.licenses/npm/macos-release.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/nice-try.dep.yml
generated
Normal file
BIN
.licenses/npm/nice-try.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/node-fetch.dep.yml
generated
Normal file
BIN
.licenses/npm/node-fetch.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/npm-run-path.dep.yml
generated
Normal file
BIN
.licenses/npm/npm-run-path.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/octokit-pagination-methods.dep.yml
generated
Normal file
BIN
.licenses/npm/octokit-pagination-methods.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/once.dep.yml
generated
Normal file
BIN
.licenses/npm/once.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/os-name.dep.yml
generated
Normal file
BIN
.licenses/npm/os-name.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/p-finally.dep.yml
generated
Normal file
BIN
.licenses/npm/p-finally.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/path-key.dep.yml
generated
Normal file
BIN
.licenses/npm/path-key.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/pump.dep.yml
generated
Normal file
BIN
.licenses/npm/pump.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/semver-5.7.0.dep.yml
generated
Normal file
BIN
.licenses/npm/semver-5.7.0.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/semver-6.3.0.dep.yml
generated
Normal file
BIN
.licenses/npm/semver-6.3.0.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/shebang-command.dep.yml
generated
Normal file
BIN
.licenses/npm/shebang-command.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/shebang-regex.dep.yml
generated
Normal file
BIN
.licenses/npm/shebang-regex.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/signal-exit.dep.yml
generated
Normal file
BIN
.licenses/npm/signal-exit.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/strip-eof.dep.yml
generated
Normal file
BIN
.licenses/npm/strip-eof.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/tunnel.dep.yml
generated
Normal file
BIN
.licenses/npm/tunnel.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/universal-user-agent-2.1.0.dep.yml
generated
Normal file
BIN
.licenses/npm/universal-user-agent-2.1.0.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/universal-user-agent-4.0.0.dep.yml
generated
Normal file
BIN
.licenses/npm/universal-user-agent-4.0.0.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/which.dep.yml
generated
Normal file
BIN
.licenses/npm/which.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/windows-release.dep.yml
generated
Normal file
BIN
.licenses/npm/windows-release.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/wrappy.dep.yml
generated
Normal file
BIN
.licenses/npm/wrappy.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/xmlbuilder.dep.yml
generated
Normal file
BIN
.licenses/npm/xmlbuilder.dep.yml
generated
Normal file
Binary file not shown.
87
README.md
87
README.md
@@ -4,10 +4,17 @@
|
|||||||
<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>
|
<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>
|
</p>
|
||||||
|
|
||||||
This action sets up a dotnet environment for use in actions by:
|
This action sets up a [dotnet core cli](https://github.com/dotnet/cli) 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 of dotnet by SDK version 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
|
||||||
|
|
||||||
|
Please Note: GitHub hosted runners have some versions of the .NET SDK
|
||||||
|
preinstalled. Installed versions are subject to change. Please refer to the
|
||||||
|
documentation
|
||||||
|
[software installed on github hosted runners](https://help.github.com/en/actions/reference/software-installed-on-github-hosted-runners)
|
||||||
|
for .NET SDK versions that are currently available.
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
@@ -16,10 +23,10 @@ See [action.yml](action.yml)
|
|||||||
Basic:
|
Basic:
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@main
|
||||||
- uses: actions/setup-dotnet@v1
|
- uses: actions/setup-dotnet@v1
|
||||||
with:
|
with:
|
||||||
dotnet-version: '2.2.103' // SDK Version to use.
|
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>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -27,13 +34,13 @@ Matrix Testing:
|
|||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-16.04
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
dotnet: [ '2.2.103', '3.5.2', '4.5.1' ]
|
dotnet: [ '2.2.103', '3.0', '3.1.x' ]
|
||||||
name: Dotnet ${{ matrix.dotnet }} sample
|
name: Dotnet ${{ matrix.dotnet }} sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@v2
|
||||||
- name: Setup dotnet
|
- name: Setup dotnet
|
||||||
uses: actions/setup-dotnet@v1
|
uses: actions/setup-dotnet@v1
|
||||||
with:
|
with:
|
||||||
@@ -41,6 +48,74 @@ jobs:
|
|||||||
- run: dotnet build <my project>
|
- run: dotnet build <my project>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Side by Side Testing:
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Dotnet Side by Side testing sample
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup dotnet
|
||||||
|
uses: actions/setup-dotnet@v1
|
||||||
|
with:
|
||||||
|
dotnet-version: '2.2.103'
|
||||||
|
- name: Setup dotnet
|
||||||
|
uses: actions/setup-dotnet@v1
|
||||||
|
with:
|
||||||
|
dotnet-version: '3.1.x'
|
||||||
|
- run: dotnet build <my project>
|
||||||
|
- run: dotnet test <my project>
|
||||||
|
```
|
||||||
|
|
||||||
|
Authentication for nuget feeds:
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
# Authenticates packages to push to GPR
|
||||||
|
- uses: actions/setup-dotnet@v1
|
||||||
|
with:
|
||||||
|
dotnet-version: '3.1.x' # SDK Version to use.
|
||||||
|
source-url: https://nuget.pkg.github.com/<owner>/index.json
|
||||||
|
env:
|
||||||
|
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
- run: dotnet build <my project>
|
||||||
|
- name: Create the package
|
||||||
|
run: dotnet pack --configuration Release <my project>
|
||||||
|
- name: Publish the package to GPR
|
||||||
|
run: dotnet nuget push <my project>/bin/Release/*.nupkg
|
||||||
|
|
||||||
|
# Authticates packages to push to Azure Artifacts
|
||||||
|
- uses: actions/setup-dotnet@v1
|
||||||
|
with:
|
||||||
|
source-url: https://pkgs.dev.azure.com/<your-organization>/_packaging/<your-feed-name>/nuget/v3/index.json
|
||||||
|
env:
|
||||||
|
NUGET_AUTH_TOKEN: ${{secrets.AZURE_DEVOPS_PAT}} # Note, create a secret with this name in Settings
|
||||||
|
- name: Publish the package to Azure Artifacts
|
||||||
|
run: dotnet nuget push <my project>/bin/Release/*.nupkg
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
- 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_MULTILEVEL_LOOKUP - configures whether the global install location is used as a fall-back (default: true)
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
```yaml
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
DOTNET_NOLOGO: true
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@main
|
||||||
|
- uses: actions/setup-dotnet@v1
|
||||||
|
with:
|
||||||
|
dotnet-version: '3.1.100' # SDK Version to use.
|
||||||
|
```
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||||
|
|||||||
185
__tests__/__snapshots__/authutil.test.ts.snap
Normal file
185
__tests__/__snapshots__/authutil.test.ts.snap
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`authutil tests Existing config not in repo root, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
||||||
|
"<?xml version=\\"1.0\\"?>
|
||||||
|
<configuration>
|
||||||
|
<config>
|
||||||
|
<add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
|
||||||
|
</config>
|
||||||
|
<packageSourceCredentials>
|
||||||
|
<GPR>
|
||||||
|
<add key=\\"Username\\" value=\\"OwnerName\\"/>
|
||||||
|
<add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
|
||||||
|
</GPR>
|
||||||
|
</packageSourceCredentials>
|
||||||
|
</configuration>"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`authutil tests Existing config w/ Azure Artifacts source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
||||||
|
"<?xml version=\\"1.0\\"?>
|
||||||
|
<configuration>
|
||||||
|
<config>
|
||||||
|
<add key=\\"defaultPushSource\\" value=\\"https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json\\"/>
|
||||||
|
</config>
|
||||||
|
<packageSourceCredentials>
|
||||||
|
<AzureArtifacts>
|
||||||
|
<add key=\\"Username\\" value=\\"OwnerName\\"/>
|
||||||
|
<add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
|
||||||
|
</AzureArtifacts>
|
||||||
|
</packageSourceCredentials>
|
||||||
|
</configuration>"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`authutil tests Existing config w/ GPR source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
||||||
|
"<?xml version=\\"1.0\\"?>
|
||||||
|
<configuration>
|
||||||
|
<config>
|
||||||
|
<add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
|
||||||
|
</config>
|
||||||
|
<packageSourceCredentials>
|
||||||
|
<GPR>
|
||||||
|
<add key=\\"Username\\" value=\\"OwnerName\\"/>
|
||||||
|
<add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
|
||||||
|
</GPR>
|
||||||
|
</packageSourceCredentials>
|
||||||
|
</configuration>"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`authutil tests Existing config w/ no GPR sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = `
|
||||||
|
"<?xml version=\\"1.0\\"?>
|
||||||
|
<configuration>
|
||||||
|
<config>
|
||||||
|
<add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
|
||||||
|
</config>
|
||||||
|
<packageSources>
|
||||||
|
<add key=\\"Source\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
|
||||||
|
</packageSources>
|
||||||
|
<packageSourceCredentials>
|
||||||
|
<Source>
|
||||||
|
<add key=\\"Username\\" value=\\"OwnerName\\"/>
|
||||||
|
<add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
|
||||||
|
</Source>
|
||||||
|
</packageSourceCredentials>
|
||||||
|
</configuration>"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`authutil tests Existing config w/ no sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = `
|
||||||
|
"<?xml version=\\"1.0\\"?>
|
||||||
|
<configuration>
|
||||||
|
<config>
|
||||||
|
<add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
|
||||||
|
</config>
|
||||||
|
<packageSources>
|
||||||
|
<add key=\\"Source\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
|
||||||
|
</packageSources>
|
||||||
|
<packageSourceCredentials>
|
||||||
|
<Source>
|
||||||
|
<add key=\\"Username\\" value=\\"OwnerName\\"/>
|
||||||
|
<add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
|
||||||
|
</Source>
|
||||||
|
</packageSourceCredentials>
|
||||||
|
</configuration>"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`authutil tests Existing config w/ only Azure Artifacts source, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
||||||
|
"<?xml version=\\"1.0\\"?>
|
||||||
|
<configuration>
|
||||||
|
<config>
|
||||||
|
<add key=\\"defaultPushSource\\" value=\\"https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json\\"/>
|
||||||
|
</config>
|
||||||
|
<packageSourceCredentials>
|
||||||
|
<AzureArtifacts>
|
||||||
|
<add key=\\"Username\\" value=\\"OwnerName\\"/>
|
||||||
|
<add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
|
||||||
|
</AzureArtifacts>
|
||||||
|
</packageSourceCredentials>
|
||||||
|
</configuration>"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`authutil tests Existing config w/ only GPR source, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
||||||
|
"<?xml version=\\"1.0\\"?>
|
||||||
|
<configuration>
|
||||||
|
<config>
|
||||||
|
<add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
|
||||||
|
</config>
|
||||||
|
<packageSourceCredentials>
|
||||||
|
<GPR>
|
||||||
|
<add key=\\"Username\\" value=\\"OwnerName\\"/>
|
||||||
|
<add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
|
||||||
|
</GPR>
|
||||||
|
</packageSourceCredentials>
|
||||||
|
</configuration>"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`authutil tests Existing config w/ two GPR sources, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
||||||
|
"<?xml version=\\"1.0\\"?>
|
||||||
|
<configuration>
|
||||||
|
<config>
|
||||||
|
<add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com\\"/>
|
||||||
|
</config>
|
||||||
|
<packageSourceCredentials>
|
||||||
|
<GPR-GitHub>
|
||||||
|
<add key=\\"Username\\" value=\\"OwnerName\\"/>
|
||||||
|
<add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
|
||||||
|
</GPR-GitHub>
|
||||||
|
<GPR-Actions>
|
||||||
|
<add key=\\"Username\\" value=\\"OwnerName\\"/>
|
||||||
|
<add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
|
||||||
|
</GPR-Actions>
|
||||||
|
</packageSourceCredentials>
|
||||||
|
</configuration>"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`authutil tests No existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR 1`] = `
|
||||||
|
"<?xml version=\\"1.0\\"?>
|
||||||
|
<configuration>
|
||||||
|
<config>
|
||||||
|
<add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/otherorg/index.json\\"/>
|
||||||
|
</config>
|
||||||
|
<packageSources>
|
||||||
|
<add key=\\"Source\\" value=\\"https://nuget.pkg.github.com/otherorg/index.json\\"/>
|
||||||
|
</packageSources>
|
||||||
|
<packageSourceCredentials>
|
||||||
|
<Source>
|
||||||
|
<add key=\\"Username\\" value=\\"otherorg\\"/>
|
||||||
|
<add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
|
||||||
|
</Source>
|
||||||
|
</packageSourceCredentials>
|
||||||
|
</configuration>"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`authutil tests No existing config, sets up a full NuGet.config with URL and token for other source 1`] = `
|
||||||
|
"<?xml version=\\"1.0\\"?>
|
||||||
|
<configuration>
|
||||||
|
<config>
|
||||||
|
<add key=\\"defaultPushSource\\" value=\\"https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json\\"/>
|
||||||
|
</config>
|
||||||
|
<packageSources>
|
||||||
|
<add key=\\"Source\\" value=\\"https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json\\"/>
|
||||||
|
</packageSources>
|
||||||
|
<packageSourceCredentials>
|
||||||
|
<Source>
|
||||||
|
<add key=\\"Username\\" value=\\"OwnerName\\"/>
|
||||||
|
<add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
|
||||||
|
</Source>
|
||||||
|
</packageSourceCredentials>
|
||||||
|
</configuration>"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`authutil tests No existing config, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = `
|
||||||
|
"<?xml version=\\"1.0\\"?>
|
||||||
|
<configuration>
|
||||||
|
<config>
|
||||||
|
<add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
|
||||||
|
</config>
|
||||||
|
<packageSources>
|
||||||
|
<add key=\\"Source\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/>
|
||||||
|
</packageSources>
|
||||||
|
<packageSourceCredentials>
|
||||||
|
<Source>
|
||||||
|
<add key=\\"Username\\" value=\\"OwnerName\\"/>
|
||||||
|
<add key=\\"ClearTextPassword\\" value=\\"TEST_FAKE_AUTH_TOKEN\\"/>
|
||||||
|
</Source>
|
||||||
|
</packageSourceCredentials>
|
||||||
|
</configuration>"
|
||||||
|
`;
|
||||||
340
__tests__/authutil.test.ts
Normal file
340
__tests__/authutil.test.ts
Normal file
@@ -0,0 +1,340 @@
|
|||||||
|
import io = require('@actions/io');
|
||||||
|
import fs = require('fs');
|
||||||
|
import path = require('path');
|
||||||
|
|
||||||
|
const fakeSourcesDirForTesting = path.join(
|
||||||
|
__dirname,
|
||||||
|
'runner',
|
||||||
|
path.join(
|
||||||
|
Math.random()
|
||||||
|
.toString(36)
|
||||||
|
.substring(7)
|
||||||
|
),
|
||||||
|
's'
|
||||||
|
);
|
||||||
|
|
||||||
|
const invalidNuGetConfig: string = `<?xml version="1.0" encoding="utf-8"?>`;
|
||||||
|
|
||||||
|
const emptyNuGetConfig: string = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
</configuration>`;
|
||||||
|
|
||||||
|
const nugetorgNuGetConfig: string = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>`;
|
||||||
|
|
||||||
|
const gprnugetorgNuGetConfig: string = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="GPR" value="https://nuget.pkg.github.com/OwnerName/index.json" protocolVersion="3" />
|
||||||
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>`;
|
||||||
|
|
||||||
|
const gprNuGetConfig: string = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="GPR" value="https://nuget.pkg.github.com/OwnerName/index.json" protocolVersion="3" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>`;
|
||||||
|
|
||||||
|
const twogprNuGetConfig: string = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="GPR-GitHub" value="https://nuget.pkg.github.com/OwnerName/index.json" protocolVersion="3" />
|
||||||
|
<add key="GPR-Actions" value="https://nuget.pkg.github.com/actions/index.json" protocolVersion="3" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>`;
|
||||||
|
|
||||||
|
const spaceNuGetConfig: string = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="GPR GitHub" value="https://nuget.pkg.github.com/OwnerName/index.json" protocolVersion="3" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>`;
|
||||||
|
|
||||||
|
const azureartifactsNuGetConfig: string = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="AzureArtifacts" value="https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json" protocolVersion="3" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>`;
|
||||||
|
|
||||||
|
const azureartifactsnugetorgNuGetConfig: string = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="AzureArtifacts" value="https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json" protocolVersion="3" />
|
||||||
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>`;
|
||||||
|
|
||||||
|
// We want a NuGet.config one level above the sources directory, so it doesn't trample a user's NuGet.config but is still picked up by NuGet/dotnet.
|
||||||
|
const nugetConfigFile = path.join(fakeSourcesDirForTesting, '../nuget.config');
|
||||||
|
|
||||||
|
process.env['GITHUB_REPOSITORY'] = 'OwnerName/repo';
|
||||||
|
import * as auth from '../src/authutil';
|
||||||
|
|
||||||
|
describe('authutil tests', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await io.rmRF(fakeSourcesDirForTesting);
|
||||||
|
await io.mkdirP(fakeSourcesDirForTesting);
|
||||||
|
}, 30000);
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await io.rmRF(fakeSourcesDirForTesting);
|
||||||
|
}, 30000);
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
if (fs.existsSync(nugetConfigFile)) {
|
||||||
|
fs.unlinkSync(nugetConfigFile);
|
||||||
|
}
|
||||||
|
process.env['INPUT_OWNER'] = '';
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
it('No existing config, sets up a full NuGet.config with URL and user/PAT for GPR', async () => {
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
|
'',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
expect(fs.existsSync(nugetConfigFile)).toBe(true);
|
||||||
|
expect(
|
||||||
|
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('No existing config, auth token environment variable not provided, throws', async () => {
|
||||||
|
let thrown = false;
|
||||||
|
try {
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
|
'',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
thrown = true;
|
||||||
|
}
|
||||||
|
expect(thrown).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('No existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR', async () => {
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
|
process.env['INPUT_OWNER'] = 'otherorg';
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://nuget.pkg.github.com/otherorg/index.json',
|
||||||
|
'',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
expect(fs.existsSync(nugetConfigFile)).toBe(true);
|
||||||
|
expect(
|
||||||
|
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Existing config (invalid), tries to parse an invalid NuGet.config and throws', async () => {
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
|
const inputNuGetConfigPath: string = path.join(
|
||||||
|
fakeSourcesDirForTesting,
|
||||||
|
'nuget.config'
|
||||||
|
);
|
||||||
|
fs.writeFileSync(inputNuGetConfigPath, invalidNuGetConfig);
|
||||||
|
let thrown = false;
|
||||||
|
try {
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
|
'',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
thrown = true;
|
||||||
|
}
|
||||||
|
expect(thrown).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Existing config w/ no sources, sets up a full NuGet.config with URL and user/PAT for GPR', async () => {
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
|
const inputNuGetConfigPath: string = path.join(
|
||||||
|
fakeSourcesDirForTesting,
|
||||||
|
'nuget.config'
|
||||||
|
);
|
||||||
|
fs.writeFileSync(inputNuGetConfigPath, emptyNuGetConfig);
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
|
'',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
expect(fs.existsSync(nugetConfigFile)).toBe(true);
|
||||||
|
expect(
|
||||||
|
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Existing config w/ no GPR sources, sets up a full NuGet.config with URL and user/PAT for GPR', async () => {
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
|
const inputNuGetConfigPath: string = path.join(
|
||||||
|
fakeSourcesDirForTesting,
|
||||||
|
'nuget.config'
|
||||||
|
);
|
||||||
|
fs.writeFileSync(inputNuGetConfigPath, nugetorgNuGetConfig);
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
|
'',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
expect(fs.existsSync(nugetConfigFile)).toBe(true);
|
||||||
|
expect(
|
||||||
|
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Existing config w/ only GPR source, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
|
const inputNuGetConfigPath: string = path.join(
|
||||||
|
fakeSourcesDirForTesting,
|
||||||
|
'nuget.config'
|
||||||
|
);
|
||||||
|
fs.writeFileSync(inputNuGetConfigPath, gprNuGetConfig);
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
|
'',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
expect(fs.existsSync(nugetConfigFile)).toBe(true);
|
||||||
|
expect(
|
||||||
|
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Existing config w/ GPR source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
|
const inputNuGetConfigPath: string = path.join(
|
||||||
|
fakeSourcesDirForTesting,
|
||||||
|
'nuget.config'
|
||||||
|
);
|
||||||
|
fs.writeFileSync(inputNuGetConfigPath, gprnugetorgNuGetConfig);
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
|
'',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
expect(fs.existsSync(nugetConfigFile)).toBe(true);
|
||||||
|
expect(
|
||||||
|
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Existing config w/ two GPR sources, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
|
const inputNuGetConfigPath: string = path.join(
|
||||||
|
fakeSourcesDirForTesting,
|
||||||
|
'nuget.config'
|
||||||
|
);
|
||||||
|
fs.writeFileSync(inputNuGetConfigPath, twogprNuGetConfig);
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://nuget.pkg.github.com',
|
||||||
|
'',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
expect(fs.existsSync(nugetConfigFile)).toBe(true);
|
||||||
|
expect(
|
||||||
|
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Existing config w/ spaces in key, throws for now', async () => {
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
|
const inputNuGetConfigPath: string = path.join(
|
||||||
|
fakeSourcesDirForTesting,
|
||||||
|
'nuget.config'
|
||||||
|
);
|
||||||
|
fs.writeFileSync(inputNuGetConfigPath, spaceNuGetConfig);
|
||||||
|
let thrown = false;
|
||||||
|
try {
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
|
'',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
thrown = true;
|
||||||
|
}
|
||||||
|
expect(thrown).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Existing config not in repo root, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
|
const inputNuGetConfigDirectory: string = path.join(
|
||||||
|
fakeSourcesDirForTesting,
|
||||||
|
'subfolder'
|
||||||
|
);
|
||||||
|
const inputNuGetConfigPath: string = path.join(
|
||||||
|
inputNuGetConfigDirectory,
|
||||||
|
'nuget.config'
|
||||||
|
);
|
||||||
|
fs.mkdirSync(inputNuGetConfigDirectory, {recursive: true});
|
||||||
|
fs.writeFileSync(inputNuGetConfigPath, gprNuGetConfig);
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
|
'subfolder/nuget.config',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
expect(fs.existsSync(nugetConfigFile)).toBe(true);
|
||||||
|
expect(
|
||||||
|
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Existing config w/ only Azure Artifacts source, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
|
const inputNuGetConfigPath: string = path.join(
|
||||||
|
fakeSourcesDirForTesting,
|
||||||
|
'nuget.config'
|
||||||
|
);
|
||||||
|
fs.writeFileSync(inputNuGetConfigPath, azureartifactsNuGetConfig);
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json',
|
||||||
|
'',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
expect(fs.existsSync(nugetConfigFile)).toBe(true);
|
||||||
|
expect(
|
||||||
|
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Existing config w/ Azure Artifacts source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
|
const inputNuGetConfigPath: string = path.join(
|
||||||
|
fakeSourcesDirForTesting,
|
||||||
|
'nuget.config'
|
||||||
|
);
|
||||||
|
fs.writeFileSync(inputNuGetConfigPath, azureartifactsnugetorgNuGetConfig);
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json',
|
||||||
|
'',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
expect(fs.existsSync(nugetConfigFile)).toBe(true);
|
||||||
|
expect(
|
||||||
|
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('No existing config, sets up a full NuGet.config with URL and token for other source', async () => {
|
||||||
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
|
await auth.configAuthentication(
|
||||||
|
'https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json',
|
||||||
|
'',
|
||||||
|
fakeSourcesDirForTesting
|
||||||
|
);
|
||||||
|
expect(fs.existsSync(nugetConfigFile)).toBe(true);
|
||||||
|
expect(
|
||||||
|
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
||||||
13
__tests__/clear-toolcache.ps1
Normal file
13
__tests__/clear-toolcache.ps1
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
$dotnetPaths = @{
|
||||||
|
Linux = @("/usr/share/dotnet")
|
||||||
|
macOS = @("$env:HOME/.dotnet")
|
||||||
|
Windows = @("$env:ProgramFiles\dotnet/*",
|
||||||
|
"$env:LocalAppData\Microsoft\dotnet/*")
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($path in $dotnetPaths[$args[0]]) {
|
||||||
|
if (Test-Path $path) {
|
||||||
|
Write-Host "Clear $path path"
|
||||||
|
Remove-Item $path -Recurse -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
23
__tests__/csc.test.ts
Normal file
23
__tests__/csc.test.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import fs = require('fs');
|
||||||
|
|
||||||
|
describe('csc tests', () => {
|
||||||
|
it('Valid regular expression', async () => {
|
||||||
|
var cscFile = require('../.github/csc.json');
|
||||||
|
var regex = cscFile['problemMatcher'][0]['pattern'][0]['regexp'];
|
||||||
|
|
||||||
|
console.log(regex);
|
||||||
|
var re = new RegExp(regex);
|
||||||
|
|
||||||
|
// Ideally we would verify that this
|
||||||
|
var stringsToMatch = [
|
||||||
|
'Program.cs(10,79): error CS1002: ; expected [/Users/zacharyeisinger/Documents/repo/setup-dotnet/__tests__/sample-broken-csproj/sample.csproj]',
|
||||||
|
"S:\\Msbuild\\src\\Build\\Evaluation\\ExpressionShredder.cs(33,7): error CS1003: Syntax error, ',' expected [S:\\msbuild\\src\\Build\\Microsoft.Build.csproj > Properties:prop]"
|
||||||
|
];
|
||||||
|
|
||||||
|
stringsToMatch.forEach(string => {
|
||||||
|
var matchStr = string.match(re);
|
||||||
|
console.log(matchStr);
|
||||||
|
expect(matchStr).toEqual(expect.anything());
|
||||||
|
});
|
||||||
|
}, 10000);
|
||||||
|
});
|
||||||
@@ -2,7 +2,7 @@ import io = require('@actions/io');
|
|||||||
import fs = require('fs');
|
import fs = require('fs');
|
||||||
import os = require('os');
|
import os = require('os');
|
||||||
import path = require('path');
|
import path = require('path');
|
||||||
import httpClient = require('typed-rest-client/HttpClient');
|
import hc = require('@actions/http-client');
|
||||||
|
|
||||||
const toolDir = path.join(__dirname, 'runner', 'tools');
|
const toolDir = path.join(__dirname, 'runner', 'tools');
|
||||||
const tempDir = path.join(__dirname, 'runner', 'temp');
|
const tempDir = path.join(__dirname, 'runner', 'temp');
|
||||||
@@ -15,6 +15,10 @@ const IS_WINDOWS = process.platform === 'win32';
|
|||||||
|
|
||||||
describe('installer tests', () => {
|
describe('installer tests', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
process.env.RUNNER_TOOL_CACHE = toolDir;
|
||||||
|
process.env.DOTNET_INSTALL_DIR = toolDir;
|
||||||
|
process.env.RUNNER_TEMP = tempDir;
|
||||||
|
process.env.DOTNET_ROOT = '';
|
||||||
await io.rmRF(toolDir);
|
await io.rmRF(toolDir);
|
||||||
await io.rmRF(tempDir);
|
await io.rmRF(tempDir);
|
||||||
});
|
});
|
||||||
@@ -26,19 +30,40 @@ describe('installer tests', () => {
|
|||||||
} catch {
|
} catch {
|
||||||
console.log('Failed to remove test directories');
|
console.log('Failed to remove test directories');
|
||||||
}
|
}
|
||||||
}, 100000);
|
}, 30000);
|
||||||
|
|
||||||
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('2.2.104');
|
await getDotnet('3.1.201');
|
||||||
const dotnetDir = path.join(toolDir, 'dncs', '2.2.104', os.arch());
|
expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).toBe(true);
|
||||||
|
|
||||||
expect(fs.existsSync(`${dotnetDir}.complete`)).toBe(true);
|
|
||||||
if (IS_WINDOWS) {
|
if (IS_WINDOWS) {
|
||||||
expect(fs.existsSync(path.join(dotnetDir, 'dotnet.exe'))).toBe(true);
|
expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
|
||||||
} else {
|
} else {
|
||||||
expect(fs.existsSync(path.join(dotnetDir, 'dotnet'))).toBe(true);
|
expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
|
||||||
}
|
}
|
||||||
}, 100000);
|
|
||||||
|
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('Acquires generic version of dotnet if no matching version is installed', async () => {
|
||||||
|
await getDotnet('3.1');
|
||||||
|
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('Throws if no location contains correct dotnet version', async () => {
|
it('Throws if no location contains correct dotnet version', async () => {
|
||||||
let thrown = false;
|
let thrown = false;
|
||||||
@@ -48,40 +73,17 @@ describe('installer tests', () => {
|
|||||||
thrown = true;
|
thrown = true;
|
||||||
}
|
}
|
||||||
expect(thrown).toBe(true);
|
expect(thrown).toBe(true);
|
||||||
}, 100000);
|
}, 30000);
|
||||||
|
|
||||||
it('Uses version of dotnet installed in cache', async () => {
|
|
||||||
const dotnetDir: string = path.join(toolDir, 'dncs', '250.0.0', os.arch());
|
|
||||||
await io.mkdirP(dotnetDir);
|
|
||||||
fs.writeFileSync(`${dotnetDir}.complete`, 'hello');
|
|
||||||
// This will throw if it doesn't find it in the cache (because no such version exists)
|
|
||||||
await getDotnet('250.0.0');
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Doesnt use version of dotnet that was only partially installed in cache', async () => {
|
|
||||||
const dotnetDir: string = path.join(toolDir, 'dncs', '251.0.0', os.arch());
|
|
||||||
await io.mkdirP(dotnetDir);
|
|
||||||
let thrown = false;
|
|
||||||
try {
|
|
||||||
// This will throw if it doesn't find it in the cache (because no such version exists)
|
|
||||||
await getDotnet('251.0.0');
|
|
||||||
} catch {
|
|
||||||
thrown = true;
|
|
||||||
}
|
|
||||||
expect(thrown).toBe(true);
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Uses an up to date bash download script', async () => {
|
it('Uses an up to date bash download script', async () => {
|
||||||
var httpCallbackClient = new httpClient.HttpClient(
|
const httpCallbackClient = new hc.HttpClient('setup-dotnet-test', [], {
|
||||||
'setup-dotnet-test',
|
allowRetries: true,
|
||||||
[],
|
maxRetries: 3
|
||||||
{}
|
});
|
||||||
);
|
const response: hc.HttpClientResponse = await httpCallbackClient.get(
|
||||||
const response: httpClient.HttpClientResponse = await httpCallbackClient.get(
|
|
||||||
'https://dot.net/v1/dotnet-install.sh'
|
'https://dot.net/v1/dotnet-install.sh'
|
||||||
);
|
);
|
||||||
|
expect(response.message.statusCode).toBe(200);
|
||||||
const upToDateContents: string = await response.readBody();
|
const upToDateContents: string = await response.readBody();
|
||||||
const currentContents: string = fs
|
const currentContents: string = fs
|
||||||
.readFileSync(
|
.readFileSync(
|
||||||
@@ -91,17 +93,17 @@ describe('installer tests', () => {
|
|||||||
expect(normalizeFileContents(currentContents)).toBe(
|
expect(normalizeFileContents(currentContents)).toBe(
|
||||||
normalizeFileContents(upToDateContents)
|
normalizeFileContents(upToDateContents)
|
||||||
);
|
);
|
||||||
});
|
}, 30000);
|
||||||
|
|
||||||
it('Uses an up to date powershell download script', async () => {
|
it('Uses an up to date powershell download script', async () => {
|
||||||
var httpCallbackClient = new httpClient.HttpClient(
|
var httpCallbackClient = new hc.HttpClient('setup-dotnet-test', [], {
|
||||||
'setup-dotnet-test',
|
allowRetries: true,
|
||||||
[],
|
maxRetries: 3
|
||||||
{}
|
});
|
||||||
);
|
const response: hc.HttpClientResponse = await httpCallbackClient.get(
|
||||||
const response: httpClient.HttpClientResponse = await httpCallbackClient.get(
|
|
||||||
'https://dot.net/v1/dotnet-install.ps1'
|
'https://dot.net/v1/dotnet-install.ps1'
|
||||||
);
|
);
|
||||||
|
expect(response.message.statusCode).toBe(200);
|
||||||
const upToDateContents: string = await response.readBody();
|
const upToDateContents: string = await response.readBody();
|
||||||
const currentContents: string = fs
|
const currentContents: string = fs
|
||||||
.readFileSync(
|
.readFileSync(
|
||||||
@@ -111,7 +113,7 @@ describe('installer tests', () => {
|
|||||||
expect(normalizeFileContents(currentContents)).toBe(
|
expect(normalizeFileContents(currentContents)).toBe(
|
||||||
normalizeFileContents(upToDateContents)
|
normalizeFileContents(upToDateContents)
|
||||||
);
|
);
|
||||||
});
|
}, 30000);
|
||||||
});
|
});
|
||||||
|
|
||||||
function normalizeFileContents(contents: string): string {
|
function normalizeFileContents(contents: string): string {
|
||||||
|
|||||||
15
__tests__/sample-csproj/Program.cs
Normal file
15
__tests__/sample-csproj/Program.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace sample_csproj
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void TestMethod1()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello, World!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
__tests__/sample-csproj/sample.csproj
Normal file
18
__tests__/sample-csproj/sample.csproj
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>netcoreapp3.1;netcoreapp2.2</TargetFrameworks>
|
||||||
|
<RootNamespace>sample_csproj</RootNamespace>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<!-- These packages will be downloaded over the network for testing proxy settings -->
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||||
|
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
|
||||||
|
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
|
||||||
|
<PackageReference Include="coverlet.collector" Version="1.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
47
__tests__/setup-dotnet.test.ts
Normal file
47
__tests__/setup-dotnet.test.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import io = require('@actions/io');
|
||||||
|
import fs = require('fs');
|
||||||
|
import os = require('os');
|
||||||
|
import path = require('path');
|
||||||
|
|
||||||
|
const toolDir = path.join(__dirname, 'runner', 'tools2');
|
||||||
|
const tempDir = path.join(__dirname, 'runner', 'temp2');
|
||||||
|
|
||||||
|
import * as setup from '../src/setup-dotnet';
|
||||||
|
|
||||||
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
|
|
||||||
|
describe('setup-dotnet tests', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
process.env.RUNNER_TOOL_CACHE = toolDir;
|
||||||
|
process.env.DOTNET_INSTALL_DIR = toolDir;
|
||||||
|
process.env.RUNNER_TEMP = tempDir;
|
||||||
|
await io.rmRF(toolDir);
|
||||||
|
await io.rmRF(tempDir);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
try {
|
||||||
|
await io.rmRF(path.join(process.cwd(), 'global.json'));
|
||||||
|
await io.rmRF(toolDir);
|
||||||
|
await io.rmRF(tempDir);
|
||||||
|
} catch {
|
||||||
|
console.log('Failed to remove test directories');
|
||||||
|
}
|
||||||
|
}, 30000);
|
||||||
|
|
||||||
|
it('Acquires version of dotnet from global.json if no matching version is installed', async () => {
|
||||||
|
const globalJsonPath = path.join(process.cwd(), 'global.json');
|
||||||
|
const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version": "3.1.201"${os.EOL}}${os.EOL}}`;
|
||||||
|
if (!fs.existsSync(globalJsonPath)) {
|
||||||
|
fs.writeFileSync(globalJsonPath, jsonContents);
|
||||||
|
}
|
||||||
|
await setup.run();
|
||||||
|
|
||||||
|
expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).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);
|
||||||
|
});
|
||||||
62
__tests__/verify-dotnet.ps1
Executable file
62
__tests__/verify-dotnet.ps1
Executable file
@@ -0,0 +1,62 @@
|
|||||||
|
if (!$args[0])
|
||||||
|
{
|
||||||
|
throw "Must supply dotnet version argument"
|
||||||
|
}
|
||||||
|
|
||||||
|
$dotnet = Get-Command dotnet | Select-Object -First 1 | ForEach-Object { $_.Path }
|
||||||
|
Write-Host "Found '$dotnet'"
|
||||||
|
|
||||||
|
$version = & $dotnet --version | Out-String | ForEach-Object { $_.Trim() }
|
||||||
|
Write-Host "Version $version"
|
||||||
|
if (-not ($version.StartsWith($args[0].ToString())))
|
||||||
|
{
|
||||||
|
Write-Host "PATH='$env:PATH'"
|
||||||
|
throw "Unexpected version"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($args[1])
|
||||||
|
{
|
||||||
|
# SDKs are listed on multiple lines with the path afterwards in square brackets
|
||||||
|
$versions = & $dotnet --list-sdks | ForEach-Object { $_.SubString(0, $_.IndexOf('[')).Trim() }
|
||||||
|
Write-Host "Installed versions: $versions"
|
||||||
|
$isInstalledVersion = $false
|
||||||
|
foreach ($version in $versions)
|
||||||
|
{
|
||||||
|
if ($version.StartsWith($args[1].ToString()))
|
||||||
|
{
|
||||||
|
$isInstalledVersion = $true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (-not $isInstalledVersion)
|
||||||
|
{
|
||||||
|
Write-Host "PATH='$env:PATH'"
|
||||||
|
throw "Unexpected version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Building sample csproj"
|
||||||
|
& $dotnet build __tests__/sample-csproj/ --no-cache
|
||||||
|
if ($LASTEXITCODE -ne 0)
|
||||||
|
{
|
||||||
|
throw "Unexpected exit code $LASTEXITCODE"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Testing compiled app"
|
||||||
|
$sample_output = "$(dotnet test __tests__/sample-csproj/ --no-build)"
|
||||||
|
Write-Host "Sample output: $sample_output"
|
||||||
|
# For Side-by-Side installs we want to run the tests twice, for a single install the tests will run once
|
||||||
|
if ($args[1])
|
||||||
|
{
|
||||||
|
if ($sample_output -notlike "*Test Run Successful.*Test Run Successful.*")
|
||||||
|
{
|
||||||
|
throw "Unexpected output"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($sample_output -notlike "*Test Run Successful.*")
|
||||||
|
{
|
||||||
|
throw "Unexpected output"
|
||||||
|
}
|
||||||
|
}
|
||||||
44
__tests__/verify-dotnet.sh
Executable file
44
__tests__/verify-dotnet.sh
Executable file
@@ -0,0 +1,44 @@
|
|||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Must supply dotnet version argument"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "../nuget.config" ]; then
|
||||||
|
echo "nuget file not generated correctly"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
dotnet_version="$(dotnet --version)"
|
||||||
|
echo "Found dotnet version '$dotnet_version'"
|
||||||
|
if [ -z "$(echo $dotnet_version | grep $1)" ]; then
|
||||||
|
echo "Unexpected version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
dotnet_version="$(dotnet --list-sdks)"
|
||||||
|
echo "Found dotnet version '$dotnet_version'"
|
||||||
|
if [ -z "$(echo $dotnet_version | grep $2)" ]; then
|
||||||
|
echo "Unexpected version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Building sample csproj"
|
||||||
|
dotnet build __tests__/sample-csproj/ --no-cache || exit 1
|
||||||
|
|
||||||
|
echo "Testing compiled app"
|
||||||
|
sample_output=$(dotnet test __tests__/sample-csproj/ --no-build)
|
||||||
|
echo "Sample output: $sample_output"
|
||||||
|
# For Side-by-Side installs we want to run the tests twice, for a single install the tests will run once
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
if [ -z "$(echo $sample_output | grep "Test Run Successful.*Test Run Successful.")" ]; then
|
||||||
|
echo "Unexpected output"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ -z "$(echo $sample_output | grep "Test Run Successful.")" ]; then
|
||||||
|
echo "Unexpected output"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
17
__tests__/verify-no-unstaged-changes.sh
Executable file
17
__tests__/verify-no-unstaged-changes.sh
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ "$(git status --porcelain)" != "" ]]; then
|
||||||
|
echo ----------------------------------------
|
||||||
|
echo git status
|
||||||
|
echo ----------------------------------------
|
||||||
|
git status
|
||||||
|
echo ----------------------------------------
|
||||||
|
echo git diff
|
||||||
|
echo ----------------------------------------
|
||||||
|
git diff
|
||||||
|
echo ----------------------------------------
|
||||||
|
echo Troubleshooting
|
||||||
|
echo ----------------------------------------
|
||||||
|
echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && npm ci && npm run pre-checkin"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
90
__tests__/versionutil.test.ts
Normal file
90
__tests__/versionutil.test.ts
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
import each from 'jest-each';
|
||||||
|
import * as installer from '../src/installer';
|
||||||
|
|
||||||
|
describe('version tests', () => {
|
||||||
|
each(['3.1.999', '3.1.101-preview.3']).test(
|
||||||
|
"Exact version '%s' should be the same",
|
||||||
|
vers => {
|
||||||
|
let versInfo = new installer.DotNetVersionInfo(vers);
|
||||||
|
|
||||||
|
expect(versInfo.isExactVersion()).toBe(true);
|
||||||
|
expect(versInfo.version()).toBe(vers);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
each([
|
||||||
|
['3.1.x', '3.1'],
|
||||||
|
['1.1.*', '1.1'],
|
||||||
|
['2.0', '2.0']
|
||||||
|
]).test("Generic version '%s' should be '%s'", (vers, resVers) => {
|
||||||
|
let versInfo = new installer.DotNetVersionInfo(vers);
|
||||||
|
|
||||||
|
expect(versInfo.isExactVersion()).toBe(false);
|
||||||
|
expect(versInfo.version()).toBe(resVers);
|
||||||
|
});
|
||||||
|
|
||||||
|
each([
|
||||||
|
'',
|
||||||
|
'.',
|
||||||
|
'..',
|
||||||
|
' . ',
|
||||||
|
'. ',
|
||||||
|
' .',
|
||||||
|
' . . ',
|
||||||
|
' .. ',
|
||||||
|
' . ',
|
||||||
|
'-1.-1',
|
||||||
|
'-1',
|
||||||
|
'-1.-1.-1',
|
||||||
|
'..3',
|
||||||
|
'1..3',
|
||||||
|
'1..',
|
||||||
|
'.2.3',
|
||||||
|
'.2.x',
|
||||||
|
'1',
|
||||||
|
'2.x',
|
||||||
|
'*.*.1',
|
||||||
|
'*.1',
|
||||||
|
'*.',
|
||||||
|
'1.2.',
|
||||||
|
'1.2.-abc',
|
||||||
|
'a.b',
|
||||||
|
'a.b.c',
|
||||||
|
'a.b.c-preview',
|
||||||
|
' 0 . 1 . 2 '
|
||||||
|
]).test("Malformed version '%s' should throw", vers => {
|
||||||
|
expect(() => new installer.DotNetVersionInfo(vers)).toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
each([
|
||||||
|
['3.1.x', '3.1.'],
|
||||||
|
['3.1.*', '3.1.'],
|
||||||
|
['3.1', '3.1.'],
|
||||||
|
['5.0.0-preview.6', '5.0.0-preview.6'],
|
||||||
|
['3.1.201', '3.1.201']
|
||||||
|
]).test(
|
||||||
|
"Resolving version '%s' as '%s'",
|
||||||
|
async (input, expectedVersion) => {
|
||||||
|
const dotnetInstaller = new installer.DotnetCoreInstaller(input);
|
||||||
|
let versInfo = await dotnetInstaller.resolveVersion(
|
||||||
|
new installer.DotNetVersionInfo(input)
|
||||||
|
);
|
||||||
|
console.log(versInfo);
|
||||||
|
|
||||||
|
expect(versInfo.startsWith(expectedVersion));
|
||||||
|
},
|
||||||
|
100000
|
||||||
|
);
|
||||||
|
|
||||||
|
it('Resolving a nonexistent generic version fails', async () => {
|
||||||
|
const dotnetInstaller = new installer.DotnetCoreInstaller('999.1.x');
|
||||||
|
try {
|
||||||
|
await dotnetInstaller.resolveVersion(
|
||||||
|
new installer.DotNetVersionInfo('999.1.x')
|
||||||
|
);
|
||||||
|
fail();
|
||||||
|
} catch {
|
||||||
|
expect(true);
|
||||||
|
}
|
||||||
|
}, 100000);
|
||||||
|
});
|
||||||
22
action.yml
22
action.yml
@@ -1,12 +1,18 @@
|
|||||||
name: 'Setup Dotnet environment'
|
name: 'Setup .NET Core SDK'
|
||||||
description: 'Setup a Dotnet environment and add it to the PATH, additionally providing proxy support'
|
description: 'Set up a specific version of the .NET Core CLI in the PATH and set up authentication to a private NuGet repository'
|
||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
inputs:
|
branding:
|
||||||
|
icon: play
|
||||||
|
color: green
|
||||||
|
inputs:
|
||||||
dotnet-version:
|
dotnet-version:
|
||||||
description: 'SDK version to use. E.g. 2.2.104'
|
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'
|
||||||
# Deprecated option, do not use. Will not be supported after October 1, 2019
|
source-url:
|
||||||
version:
|
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: 'Deprecated. Use dotnet-version instead. Will not be supported after October 1, 2019'
|
owner:
|
||||||
|
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:
|
||||||
|
description: 'Optional NuGet.config location, if your NuGet.config isn''t located in the root of the repo.'
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'lib/setup-dotnet.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
22055
dist/index.js
vendored
Normal file
22055
dist/index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -1,17 +1,34 @@
|
|||||||
# Contributors
|
# Contributors
|
||||||
|
|
||||||
|
Thank you for contributing! This action is targetted around setting up the dotnet cli and related sdks for GitHub actions. As part of that we use proxy settings (for self-hosted runners) and set-up nuget authentication for private feeds.
|
||||||
|
|
||||||
# Checkin
|
If you would like to contribute there are a few things to consider:
|
||||||
|
|
||||||
- Do checkin source (src)
|
## Commands to use
|
||||||
- Do checkin build output (lib)
|
|
||||||
- Do checkin runtime node_modules
|
|
||||||
- Do not checkin
|
|
||||||
|
|
||||||
# Adding a dev dependency
|
- npm run build - Compiles the action into a single js file at dist/index.js (Please check in the changes made by this command)
|
||||||
|
- npm run test - Runs all tests under __tests__
|
||||||
|
- npm run format - Runs formatting required to pass the lint test (Please check in the changes made by this command)
|
||||||
|
- npm run update-installers - Updates the install-dotnet scripts in externals (Please check in the changes made by this command)
|
||||||
|
|
||||||
Remember to update .gitignore.
|
## To check in or not to check in
|
||||||
|
|
||||||
# Updating toolkit dependency
|
- Do check in source (src)
|
||||||
|
- Do check in index file (dist)
|
||||||
|
- Do check in updates to install-dotnet scripts (externals)
|
||||||
|
- Do not check in build output (lib)
|
||||||
|
- Do not check in runtime (node_modules)
|
||||||
|
|
||||||
Until released publically, update tgz packages in toolkit
|
## Writing tests
|
||||||
|
|
||||||
|
With any contribution please take time to consider how this can be tested to maintain high quality. Current tests can be found in the folder __tests__ for examples.
|
||||||
|
|
||||||
|
## Creating new version
|
||||||
|
|
||||||
|
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.
|
||||||
|
Once the new release is created, the v1 tag needs to be updated as well.
|
||||||
|
```
|
||||||
|
git tag -fa v1 -m "Update v1 tag"
|
||||||
|
git push origin v1 --force
|
||||||
|
```
|
||||||
|
|||||||
192
externals/get-os-distro.sh
vendored
192
externals/get-os-distro.sh
vendored
@@ -1,192 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
||||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
||||||
#
|
|
||||||
|
|
||||||
# Stop script on NZEC
|
|
||||||
set -e
|
|
||||||
# Stop script if unbound variable found (use ${var:-} if intentional)
|
|
||||||
set -u
|
|
||||||
# By default cmd1 | cmd2 returns exit code of cmd2 regardless of cmd1 success
|
|
||||||
# This is causing it to fail
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
# Use in the the functions: eval $invocation
|
|
||||||
invocation='say_verbose "Calling: ${yellow:-}${FUNCNAME[0]} ${green:-}$*${normal:-}"'
|
|
||||||
|
|
||||||
# standard output may be used as a return value in the functions
|
|
||||||
# we need a way to write text on the screen in the functions so that
|
|
||||||
# it won't interfere with the return value.
|
|
||||||
# Exposing stream 3 as a pipe to standard output of the script itself
|
|
||||||
exec 3>&1
|
|
||||||
|
|
||||||
say_err() {
|
|
||||||
printf "%b\n" "get-os-distro: Error: $1" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
# This platform list is finite - if the SDK/Runtime has supported Linux distribution-specific assets,
|
|
||||||
# then and only then should the Linux distribution appear in this list.
|
|
||||||
# Adding a Linux distribution to this list does not imply distribution-specific support.
|
|
||||||
get_legacy_os_name_from_platform() {
|
|
||||||
|
|
||||||
platform="$1"
|
|
||||||
case "$platform" in
|
|
||||||
"centos.7")
|
|
||||||
echo "centos"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
"debian.8")
|
|
||||||
echo "debian"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
"fedora.23")
|
|
||||||
echo "fedora.23"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
"fedora.27")
|
|
||||||
echo "fedora.27"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
"fedora.24")
|
|
||||||
echo "fedora.24"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
"opensuse.13.2")
|
|
||||||
echo "opensuse.13.2"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
"opensuse.42.1")
|
|
||||||
echo "opensuse.42.1"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
"opensuse.42.3")
|
|
||||||
echo "opensuse.42.3"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
"rhel.7"*)
|
|
||||||
echo "rhel"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
"ubuntu.14.04")
|
|
||||||
echo "ubuntu"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
"ubuntu.16.04")
|
|
||||||
echo "ubuntu.16.04"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
"ubuntu.16.10")
|
|
||||||
echo "ubuntu.16.10"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
"ubuntu.18.04")
|
|
||||||
echo "ubuntu.18.04"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
"alpine.3.4.3")
|
|
||||||
echo "alpine"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
get_linux_platform_name() {
|
|
||||||
|
|
||||||
if [ -e /etc/os-release ]; then
|
|
||||||
. /etc/os-release
|
|
||||||
echo "$ID.$VERSION_ID"
|
|
||||||
return 0
|
|
||||||
elif [ -e /etc/redhat-release ]; then
|
|
||||||
local redhatRelease=$(</etc/redhat-release)
|
|
||||||
if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
|
|
||||||
echo "rhel.6"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
say_err "Linux specific platform name and version could not be detected: UName = $uname"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
get_current_os_name() {
|
|
||||||
|
|
||||||
local uname=$(uname)
|
|
||||||
if [ "$uname" = "Darwin" ]; then
|
|
||||||
echo "mac"
|
|
||||||
return 0
|
|
||||||
elif [ "$uname" = "Linux" ]; then
|
|
||||||
local linux_platform_name
|
|
||||||
linux_platform_name="$(get_linux_platform_name)" || { echo "linux" && return 0 ; }
|
|
||||||
|
|
||||||
if [[ $linux_platform_name == "rhel.6" ]]; then
|
|
||||||
echo "$linux_platform_name"
|
|
||||||
return 0
|
|
||||||
elif [[ $linux_platform_name == alpine* ]]; then
|
|
||||||
echo "linux-musl"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "linux"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
say_err "OS name could not be detected: UName = $uname"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
get_legacy_os_name() {
|
|
||||||
|
|
||||||
local uname=$(uname)
|
|
||||||
if [ "$uname" = "Darwin" ]; then
|
|
||||||
echo "mac"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
if [ -e /etc/os-release ]; then
|
|
||||||
. /etc/os-release
|
|
||||||
os=$(get_legacy_os_name_from_platform "$ID.$VERSION_ID" || echo "")
|
|
||||||
if [ -n "$os" ]; then
|
|
||||||
echo "$os"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
say_err "Distribution specific OS name and version could not be detected: UName = $uname"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
get_machine_architecture() {
|
|
||||||
|
|
||||||
if command -v uname > /dev/null; then
|
|
||||||
CPUName=$(uname -m)
|
|
||||||
case $CPUName in
|
|
||||||
armv7l)
|
|
||||||
echo "arm"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
aarch64)
|
|
||||||
echo "arm64"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Always default to 'x64'
|
|
||||||
echo "x64"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
osName=$(get_current_os_name || echo "")
|
|
||||||
legacyOsName=$(get_legacy_os_name || echo "")
|
|
||||||
arch=$(get_machine_architecture || echo "")
|
|
||||||
|
|
||||||
primaryName="$osName-$arch"
|
|
||||||
legacyName="$legacyOsName"
|
|
||||||
|
|
||||||
echo "Primary:$primaryName"
|
|
||||||
echo "Legacy:$legacyName"
|
|
||||||
|
|
||||||
if [ -z "$osName" ] && [ -z "$legacyOsName" ];then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
18
externals/get-os-platform.ps1
vendored
18
externals/get-os-platform.ps1
vendored
@@ -1,18 +0,0 @@
|
|||||||
function Get-Machine-Architecture()
|
|
||||||
{
|
|
||||||
# possible values: AMD64, IA64, x86
|
|
||||||
return $ENV:PROCESSOR_ARCHITECTURE
|
|
||||||
}
|
|
||||||
|
|
||||||
function Get-CLIArchitecture-From-Architecture([string]$Architecture)
|
|
||||||
{
|
|
||||||
switch ($Architecture.ToLower())
|
|
||||||
{
|
|
||||||
{ ($_ -eq "amd64") -or ($_ -eq "x64") } { return "x64" }
|
|
||||||
{ $_ -eq "x86" } { return "x86" }
|
|
||||||
default { throw "Architecture not supported. If you think this is a bug, please report it at https://github.com/dotnet/cli/issues" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$CLIArchitecture = Get-CLIArchitecture-From-Architecture $(Get-Machine-Architecture)
|
|
||||||
Write-Output "Primary:win-$CLIArchitecture"
|
|
||||||
1733
externals/install-dotnet.ps1
vendored
1733
externals/install-dotnet.ps1
vendored
File diff suppressed because it is too large
Load Diff
455
externals/install-dotnet.sh
vendored
Normal file → Executable file
455
externals/install-dotnet.sh
vendored
Normal file → Executable file
@@ -40,7 +40,7 @@ if [ -t 1 ] && command -v tput > /dev/null; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
say_warning() {
|
say_warning() {
|
||||||
printf "%b\n" "${yellow:-}dotnet_install: Warning: $1${normal:-}"
|
printf "%b\n" "${yellow:-}dotnet_install: Warning: $1${normal:-}" >&3
|
||||||
}
|
}
|
||||||
|
|
||||||
say_err() {
|
say_err() {
|
||||||
@@ -144,11 +144,11 @@ get_linux_platform_name() {
|
|||||||
else
|
else
|
||||||
if [ -e /etc/os-release ]; then
|
if [ -e /etc/os-release ]; then
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
echo "$ID.$VERSION_ID"
|
echo "$ID${VERSION_ID:+.${VERSION_ID}}"
|
||||||
return 0
|
return 0
|
||||||
elif [ -e /etc/redhat-release ]; then
|
elif [ -e /etc/redhat-release ]; then
|
||||||
local redhatRelease=$(</etc/redhat-release)
|
local redhatRelease=$(</etc/redhat-release)
|
||||||
if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
|
if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux "*" release 6."* ]]; then
|
||||||
echo "rhel.6"
|
echo "rhel.6"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -159,6 +159,10 @@ get_linux_platform_name() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_musl_based_distro() {
|
||||||
|
(ldd --version 2>&1 || true) | grep -q musl
|
||||||
|
}
|
||||||
|
|
||||||
get_current_os_name() {
|
get_current_os_name() {
|
||||||
eval $invocation
|
eval $invocation
|
||||||
|
|
||||||
@@ -168,15 +172,18 @@ get_current_os_name() {
|
|||||||
return 0
|
return 0
|
||||||
elif [ "$uname" = "FreeBSD" ]; then
|
elif [ "$uname" = "FreeBSD" ]; then
|
||||||
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)" || { echo "linux" && return 0 ; }
|
||||||
|
|
||||||
if [[ $linux_platform_name == "rhel.6" ]]; then
|
if [ "$linux_platform_name" = "rhel.6" ]; then
|
||||||
echo $linux_platform_name
|
echo $linux_platform_name
|
||||||
return 0
|
return 0
|
||||||
elif [[ $linux_platform_name == alpine* ]]; then
|
elif is_musl_based_distro; then
|
||||||
|
echo "linux-musl"
|
||||||
|
return 0
|
||||||
|
elif [ "$linux_platform_name" = "linux-musl" ]; then
|
||||||
echo "linux-musl"
|
echo "linux-musl"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
@@ -202,7 +209,7 @@ get_legacy_os_name() {
|
|||||||
else
|
else
|
||||||
if [ -e /etc/os-release ]; then
|
if [ -e /etc/os-release ]; then
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
os=$(get_legacy_os_name_from_platform "$ID.$VERSION_ID" || echo "")
|
os=$(get_legacy_os_name_from_platform "$ID${VERSION_ID:+.${VERSION_ID}}" || echo "")
|
||||||
if [ -n "$os" ]; then
|
if [ -n "$os" ]; then
|
||||||
echo "$os"
|
echo "$os"
|
||||||
return 0
|
return 0
|
||||||
@@ -237,33 +244,6 @@ check_min_reqs() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
check_pre_reqs() {
|
|
||||||
eval $invocation
|
|
||||||
|
|
||||||
if [ "${DOTNET_INSTALL_SKIP_PREREQS:-}" = "1" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$(uname)" = "Linux" ]; then
|
|
||||||
if [ ! -x "$(command -v ldconfig)" ]; then
|
|
||||||
echo "ldconfig is not in PATH, trying /sbin/ldconfig."
|
|
||||||
LDCONFIG_COMMAND="/sbin/ldconfig"
|
|
||||||
else
|
|
||||||
LDCONFIG_COMMAND="ldconfig"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local librarypath=${LD_LIBRARY_PATH:-}
|
|
||||||
LDCONFIG_COMMAND="$LDCONFIG_COMMAND -NXv ${librarypath//:/ }"
|
|
||||||
|
|
||||||
[ -z "$($LDCONFIG_COMMAND 2>/dev/null | grep libunwind)" ] && say_warning "Unable to locate libunwind. Probable prerequisite missing; install libunwind."
|
|
||||||
[ -z "$($LDCONFIG_COMMAND 2>/dev/null | grep libssl)" ] && say_warning "Unable to locate libssl. Probable prerequisite missing; install libssl."
|
|
||||||
[ -z "$($LDCONFIG_COMMAND 2>/dev/null | grep libicu)" ] && say_warning "Unable to locate libicu. Probable prerequisite missing; install libicu."
|
|
||||||
[ -z "$($LDCONFIG_COMMAND 2>/dev/null | grep -F libcurl.so)" ] && say_warning "Unable to locate libcurl. Probable prerequisite missing; install libcurl."
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# args:
|
# args:
|
||||||
# input - $1
|
# input - $1
|
||||||
to_lowercase() {
|
to_lowercase() {
|
||||||
@@ -319,11 +299,11 @@ get_machine_architecture() {
|
|||||||
if command -v uname > /dev/null; then
|
if command -v uname > /dev/null; then
|
||||||
CPUName=$(uname -m)
|
CPUName=$(uname -m)
|
||||||
case $CPUName in
|
case $CPUName in
|
||||||
armv7l)
|
armv*l)
|
||||||
echo "arm"
|
echo "arm"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
aarch64)
|
aarch64|arm64)
|
||||||
echo "arm64"
|
echo "arm64"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
@@ -360,10 +340,34 @@ get_normalized_architecture_from_architecture() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
say_err "Architecture \`$architecture\` not supported. If you think this is a bug, report it at https://github.com/dotnet/cli/issues"
|
say_err "Architecture \`$architecture\` not supported. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# args:
|
||||||
|
# user_defined_os - $1
|
||||||
|
get_normalized_os() {
|
||||||
|
eval $invocation
|
||||||
|
|
||||||
|
local osname="$(to_lowercase "$1")"
|
||||||
|
if [ ! -z "$osname" ]; then
|
||||||
|
case "$osname" in
|
||||||
|
osx | freebsd | rhel.6 | linux-musl | linux)
|
||||||
|
echo "$osname"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
say_err "'$user_defined_os' is not a supported value for --os option, supported values are: osx, linux, linux-musl, freebsd, rhel.6. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues."
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
osname="$(get_current_os_name)" || return 1
|
||||||
|
fi
|
||||||
|
echo "$osname"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
# The version text returned from the feeds is a 1-line or 2-line string:
|
# The version text returned from the feeds is a 1-line or 2-line string:
|
||||||
# For the SDK and the dotnet runtime (2 lines):
|
# For the SDK and the dotnet runtime (2 lines):
|
||||||
# Line 1: # commit_hash
|
# Line 1: # commit_hash
|
||||||
@@ -405,14 +409,12 @@ is_dotnet_package_installed() {
|
|||||||
# azure_feed - $1
|
# azure_feed - $1
|
||||||
# channel - $2
|
# channel - $2
|
||||||
# normalized_architecture - $3
|
# normalized_architecture - $3
|
||||||
# coherent - $4
|
|
||||||
get_latest_version_info() {
|
get_latest_version_info() {
|
||||||
eval $invocation
|
eval $invocation
|
||||||
|
|
||||||
local azure_feed="$1"
|
local azure_feed="$1"
|
||||||
local channel="$2"
|
local channel="$2"
|
||||||
local normalized_architecture="$3"
|
local normalized_architecture="$3"
|
||||||
local coherent="$4"
|
|
||||||
|
|
||||||
local version_file_url=null
|
local version_file_url=null
|
||||||
if [[ "$runtime" == "dotnet" ]]; then
|
if [[ "$runtime" == "dotnet" ]]; then
|
||||||
@@ -420,11 +422,7 @@ get_latest_version_info() {
|
|||||||
elif [[ "$runtime" == "aspnetcore" ]]; then
|
elif [[ "$runtime" == "aspnetcore" ]]; then
|
||||||
version_file_url="$uncached_feed/aspnetcore/Runtime/$channel/latest.version"
|
version_file_url="$uncached_feed/aspnetcore/Runtime/$channel/latest.version"
|
||||||
elif [ -z "$runtime" ]; then
|
elif [ -z "$runtime" ]; then
|
||||||
if [ "$coherent" = true ]; then
|
version_file_url="$uncached_feed/Sdk/$channel/latest.version"
|
||||||
version_file_url="$uncached_feed/Sdk/$channel/latest.coherent.version"
|
|
||||||
else
|
|
||||||
version_file_url="$uncached_feed/Sdk/$channel/latest.version"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
say_err "Invalid value for \$runtime"
|
say_err "Invalid value for \$runtime"
|
||||||
return 1
|
return 1
|
||||||
@@ -435,11 +433,52 @@ get_latest_version_info() {
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# args:
|
||||||
|
# json_file - $1
|
||||||
|
parse_jsonfile_for_version() {
|
||||||
|
eval $invocation
|
||||||
|
|
||||||
|
local json_file="$1"
|
||||||
|
if [ ! -f "$json_file" ]; then
|
||||||
|
say_err "Unable to find \`$json_file\`"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
sdk_section=$(cat $json_file | awk '/"sdk"/,/}/')
|
||||||
|
if [ -z "$sdk_section" ]; then
|
||||||
|
say_err "Unable to parse the SDK node in \`$json_file\`"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
sdk_list=$(echo $sdk_section | awk -F"[{}]" '{print $2}')
|
||||||
|
sdk_list=${sdk_list//[\" ]/}
|
||||||
|
sdk_list=${sdk_list//,/$'\n'}
|
||||||
|
|
||||||
|
local version_info=""
|
||||||
|
while read -r line; do
|
||||||
|
IFS=:
|
||||||
|
while read -r key value; do
|
||||||
|
if [[ "$key" == "version" ]]; then
|
||||||
|
version_info=$value
|
||||||
|
fi
|
||||||
|
done <<< "$line"
|
||||||
|
done <<< "$sdk_list"
|
||||||
|
if [ -z "$version_info" ]; then
|
||||||
|
say_err "Unable to find the SDK:version node in \`$json_file\`"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset IFS;
|
||||||
|
echo "$version_info"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
# args:
|
# args:
|
||||||
# azure_feed - $1
|
# azure_feed - $1
|
||||||
# channel - $2
|
# channel - $2
|
||||||
# normalized_architecture - $3
|
# normalized_architecture - $3
|
||||||
# version - $4
|
# version - $4
|
||||||
|
# json_file - $5
|
||||||
get_specific_version_from_version() {
|
get_specific_version_from_version() {
|
||||||
eval $invocation
|
eval $invocation
|
||||||
|
|
||||||
@@ -447,27 +486,25 @@ get_specific_version_from_version() {
|
|||||||
local channel="$2"
|
local channel="$2"
|
||||||
local normalized_architecture="$3"
|
local normalized_architecture="$3"
|
||||||
local version="$(to_lowercase "$4")"
|
local version="$(to_lowercase "$4")"
|
||||||
|
local json_file="$5"
|
||||||
|
|
||||||
case "$version" in
|
if [ -z "$json_file" ]; then
|
||||||
latest)
|
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_latest_version_info "$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_version_info
|
||||||
return 0
|
return 0
|
||||||
;;
|
else
|
||||||
coherent)
|
|
||||||
local version_info
|
|
||||||
version_info="$(get_latest_version_info "$azure_feed" "$channel" "$normalized_architecture" true)" || return 1
|
|
||||||
say_verbose "get_specific_version_from_version: version_info=$version_info"
|
|
||||||
echo "$version_info" | get_version_from_version_info
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "$version"
|
echo "$version"
|
||||||
return 0
|
return 0
|
||||||
;;
|
fi
|
||||||
esac
|
else
|
||||||
|
local version_info
|
||||||
|
version_info="$(parse_jsonfile_for_version "$json_file")" || return 1
|
||||||
|
echo "$version_info"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# args:
|
# args:
|
||||||
@@ -475,6 +512,7 @@ get_specific_version_from_version() {
|
|||||||
# channel - $2
|
# channel - $2
|
||||||
# normalized_architecture - $3
|
# normalized_architecture - $3
|
||||||
# specific_version - $4
|
# specific_version - $4
|
||||||
|
# normalized_os - $5
|
||||||
construct_download_link() {
|
construct_download_link() {
|
||||||
eval $invocation
|
eval $invocation
|
||||||
|
|
||||||
@@ -482,17 +520,16 @@ construct_download_link() {
|
|||||||
local channel="$2"
|
local channel="$2"
|
||||||
local normalized_architecture="$3"
|
local normalized_architecture="$3"
|
||||||
local specific_version="${4//[$'\t\r\n']}"
|
local specific_version="${4//[$'\t\r\n']}"
|
||||||
|
local specific_product_version="$(get_specific_product_version "$1" "$4")"
|
||||||
local osname
|
local osname="$5"
|
||||||
osname="$(get_current_os_name)" || return 1
|
|
||||||
|
|
||||||
local download_link=null
|
local download_link=null
|
||||||
if [[ "$runtime" == "dotnet" ]]; then
|
if [[ "$runtime" == "dotnet" ]]; then
|
||||||
download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_version-$osname-$normalized_architecture.tar.gz"
|
download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_product_version-$osname-$normalized_architecture.tar.gz"
|
||||||
elif [[ "$runtime" == "aspnetcore" ]]; then
|
elif [[ "$runtime" == "aspnetcore" ]]; then
|
||||||
download_link="$azure_feed/aspnetcore/Runtime/$specific_version/aspnetcore-runtime-$specific_version-$osname-$normalized_architecture.tar.gz"
|
download_link="$azure_feed/aspnetcore/Runtime/$specific_version/aspnetcore-runtime-$specific_product_version-$osname-$normalized_architecture.tar.gz"
|
||||||
elif [ -z "$runtime" ]; then
|
elif [ -z "$runtime" ]; then
|
||||||
download_link="$azure_feed/Sdk/$specific_version/dotnet-sdk-$specific_version-$osname-$normalized_architecture.tar.gz"
|
download_link="$azure_feed/Sdk/$specific_version/dotnet-sdk-$specific_product_version-$osname-$normalized_architecture.tar.gz"
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -501,6 +538,50 @@ construct_download_link() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# args:
|
||||||
|
# azure_feed - $1
|
||||||
|
# specific_version - $2
|
||||||
|
get_specific_product_version() {
|
||||||
|
# If we find a 'productVersion.txt' at the root of any folder, we'll use its contents
|
||||||
|
# to resolve the version of what's in the folder, superseding the specified version.
|
||||||
|
eval $invocation
|
||||||
|
|
||||||
|
local azure_feed="$1"
|
||||||
|
local specific_version="${2//[$'\t\r\n']}"
|
||||||
|
local specific_product_version=$specific_version
|
||||||
|
|
||||||
|
local download_link=null
|
||||||
|
if [[ "$runtime" == "dotnet" ]]; then
|
||||||
|
download_link="$azure_feed/Runtime/$specific_version/productVersion.txt${feed_credential}"
|
||||||
|
elif [[ "$runtime" == "aspnetcore" ]]; then
|
||||||
|
download_link="$azure_feed/aspnetcore/Runtime/$specific_version/productVersion.txt${feed_credential}"
|
||||||
|
elif [ -z "$runtime" ]; then
|
||||||
|
download_link="$azure_feed/Sdk/$specific_version/productVersion.txt${feed_credential}"
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if machine_has "curl"
|
||||||
|
then
|
||||||
|
specific_product_version=$(curl -s --fail "$download_link")
|
||||||
|
if [ $? -ne 0 ]
|
||||||
|
then
|
||||||
|
specific_product_version=$specific_version
|
||||||
|
fi
|
||||||
|
elif machine_has "wget"
|
||||||
|
then
|
||||||
|
specific_product_version=$(wget -qO- "$download_link")
|
||||||
|
if [ $? -ne 0 ]
|
||||||
|
then
|
||||||
|
specific_product_version=$specific_version
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
specific_product_version="${specific_product_version//[$'\t\r\n']}"
|
||||||
|
|
||||||
|
echo "$specific_product_version"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
# args:
|
# args:
|
||||||
# azure_feed - $1
|
# azure_feed - $1
|
||||||
# channel - $2
|
# channel - $2
|
||||||
@@ -558,24 +639,6 @@ resolve_installation_path() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# args:
|
|
||||||
# install_root - $1
|
|
||||||
get_installed_version_info() {
|
|
||||||
eval $invocation
|
|
||||||
|
|
||||||
local install_root="$1"
|
|
||||||
local version_file="$(combine_paths "$install_root" "$local_version_file_relative_path")"
|
|
||||||
say_verbose "Local version file: $version_file"
|
|
||||||
if [ ! -z "$version_file" ] | [ -r "$version_file" ]; then
|
|
||||||
local version_info="$(cat "$version_file")"
|
|
||||||
echo "$version_info"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
say_verbose "Local version file not found."
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# args:
|
# args:
|
||||||
# relative_or_absolute_path - $1
|
# relative_or_absolute_path - $1
|
||||||
get_absolute_path() {
|
get_absolute_path() {
|
||||||
@@ -600,7 +663,7 @@ copy_files_or_dirs_from_list() {
|
|||||||
local osname="$(get_current_os_name)"
|
local osname="$(get_current_os_name)"
|
||||||
local override_switch=$(
|
local override_switch=$(
|
||||||
if [ "$override" = false ]; then
|
if [ "$override" = false ]; then
|
||||||
if [[ "$osname" == "linux-musl" ]]; then
|
if [ "$osname" = "linux-musl" ]; then
|
||||||
printf -- "-u";
|
printf -- "-u";
|
||||||
else
|
else
|
||||||
printf -- "-n";
|
printf -- "-n";
|
||||||
@@ -612,6 +675,9 @@ copy_files_or_dirs_from_list() {
|
|||||||
local target="$out_path/$path"
|
local target="$out_path/$path"
|
||||||
if [ "$override" = true ] || (! ([ -d "$target" ] || [ -e "$target" ])); then
|
if [ "$override" = true ] || (! ([ -d "$target" ] || [ -e "$target" ])); then
|
||||||
mkdir -p "$out_path/$(dirname "$path")"
|
mkdir -p "$out_path/$(dirname "$path")"
|
||||||
|
if [ -d "$target" ]; then
|
||||||
|
rm -rf "$target"
|
||||||
|
fi
|
||||||
cp -R $override_switch "$root_path/$path" "$target"
|
cp -R $override_switch "$root_path/$path" "$target"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -636,11 +702,31 @@ extract_dotnet_package() {
|
|||||||
find "$temp_out_path" -type f | grep -Ev "$folders_with_version_regex" | copy_files_or_dirs_from_list "$temp_out_path" "$out_path" "$override_non_versioned_files"
|
find "$temp_out_path" -type f | grep -Ev "$folders_with_version_regex" | copy_files_or_dirs_from_list "$temp_out_path" "$out_path" "$override_non_versioned_files"
|
||||||
|
|
||||||
rm -rf "$temp_out_path"
|
rm -rf "$temp_out_path"
|
||||||
|
rm -f "$zip_path" && say_verbose "Temporary zip file $zip_path was removed"
|
||||||
|
|
||||||
if [ "$failed" = true ]; then
|
if [ "$failed" = true ]; then
|
||||||
say_err "Extraction failed"
|
say_err "Extraction failed"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
get_http_header_curl() {
|
||||||
|
eval $invocation
|
||||||
|
local remote_path="$1"
|
||||||
|
remote_path_with_credential="${remote_path}${feed_credential}"
|
||||||
|
curl_options="-I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 "
|
||||||
|
curl $curl_options "$remote_path_with_credential" || return 1
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
get_http_header_wget() {
|
||||||
|
eval $invocation
|
||||||
|
local remote_path="$1"
|
||||||
|
remote_path_with_credential="${remote_path}${feed_credential}"
|
||||||
|
wget_options="-q -S --spider --tries 5 --waitretry 2 --connect-timeout 15 "
|
||||||
|
wget $wget_options "$remote_path_with_credential" 2>&1 || return 1
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# args:
|
# args:
|
||||||
@@ -658,13 +744,30 @@ download() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local failed=false
|
local failed=false
|
||||||
if machine_has "curl"; then
|
local attempts=0
|
||||||
downloadcurl "$remote_path" "$out_path" || failed=true
|
while [ $attempts -lt 3 ]; do
|
||||||
elif machine_has "wget"; then
|
attempts=$((attempts+1))
|
||||||
downloadwget "$remote_path" "$out_path" || failed=true
|
failed=false
|
||||||
else
|
if machine_has "curl"; then
|
||||||
failed=true
|
downloadcurl "$remote_path" "$out_path" || failed=true
|
||||||
fi
|
elif machine_has "wget"; then
|
||||||
|
downloadwget "$remote_path" "$out_path" || failed=true
|
||||||
|
else
|
||||||
|
say_err "Missing dependency: neither curl nor wget was found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$failed" = false ] || [ $attempts -ge 3 ] || { [ ! -z $http_code ] && [ $http_code = "404" ]; }; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
say "Download attempt #$attempts has failed: $http_code $download_error_msg"
|
||||||
|
say "Attempt #$((attempts+1)) will start in $((attempts*10)) seconds."
|
||||||
|
sleep $((attempts*20))
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$failed" = true ]; then
|
if [ "$failed" = true ]; then
|
||||||
say_verbose "Download failed: $remote_path"
|
say_verbose "Download failed: $remote_path"
|
||||||
return 1
|
return 1
|
||||||
@@ -672,43 +775,60 @@ download() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Updates global variables $http_code and $download_error_msg
|
||||||
downloadcurl() {
|
downloadcurl() {
|
||||||
eval $invocation
|
eval $invocation
|
||||||
|
unset http_code
|
||||||
|
unset download_error_msg
|
||||||
local remote_path="$1"
|
local remote_path="$1"
|
||||||
local out_path="${2:-}"
|
local out_path="${2:-}"
|
||||||
|
|
||||||
# Append feed_credential as late as possible before calling curl to avoid logging feed_credential
|
# Append feed_credential as late as possible before calling curl to avoid logging feed_credential
|
||||||
remote_path="${remote_path}${feed_credential}"
|
local remote_path_with_credential="${remote_path}${feed_credential}"
|
||||||
|
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 --retry 10 -sSL -f --create-dirs "$remote_path" || failed=true
|
curl $curl_options "$remote_path_with_credential" || failed=true
|
||||||
else
|
else
|
||||||
curl --retry 10 -sSL -f --create-dirs -o "$out_path" "$remote_path" || failed=true
|
curl $curl_options -o "$out_path" "$remote_path_with_credential" || failed=true
|
||||||
fi
|
fi
|
||||||
if [ "$failed" = true ]; then
|
if [ "$failed" = true ]; then
|
||||||
say_verbose "Curl download failed"
|
local response=$(get_http_header_curl $remote_path_with_credential)
|
||||||
|
http_code=$( echo "$response" | awk '/^HTTP/{print $2}' | tail -1 )
|
||||||
|
download_error_msg="Unable to download $remote_path."
|
||||||
|
if [[ $http_code != 2* ]]; then
|
||||||
|
download_error_msg+=" Returned HTTP status code: $http_code."
|
||||||
|
fi
|
||||||
|
say_verbose "$download_error_msg"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Updates global variables $http_code and $download_error_msg
|
||||||
downloadwget() {
|
downloadwget() {
|
||||||
eval $invocation
|
eval $invocation
|
||||||
|
unset http_code
|
||||||
|
unset download_error_msg
|
||||||
local remote_path="$1"
|
local remote_path="$1"
|
||||||
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
|
||||||
remote_path="${remote_path}${feed_credential}"
|
local remote_path_with_credential="${remote_path}${feed_credential}"
|
||||||
|
local wget_options="--tries 20 --waitretry 2 --connect-timeout 15 "
|
||||||
local failed=false
|
local failed=false
|
||||||
if [ -z "$out_path" ]; then
|
if [ -z "$out_path" ]; then
|
||||||
wget -q --tries 10 -O - "$remote_path" || failed=true
|
wget -q $wget_options -O - "$remote_path_with_credential" || failed=true
|
||||||
else
|
else
|
||||||
wget --tries 10 -O "$out_path" "$remote_path" || failed=true
|
wget $wget_options -O "$out_path" "$remote_path_with_credential" || failed=true
|
||||||
fi
|
fi
|
||||||
if [ "$failed" = true ]; then
|
if [ "$failed" = true ]; then
|
||||||
say_verbose "Wget download failed"
|
local response=$(get_http_header_wget $remote_path_with_credential)
|
||||||
|
http_code=$( echo "$response" | awk '/^ HTTP/{print $2}' | tail -1 )
|
||||||
|
download_error_msg="Unable to download $remote_path."
|
||||||
|
if [[ $http_code != 2* ]]; then
|
||||||
|
download_error_msg+=" Returned HTTP status code: $http_code."
|
||||||
|
fi
|
||||||
|
say_verbose "$download_error_msg"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
@@ -721,14 +841,18 @@ calculate_vars() {
|
|||||||
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"
|
||||||
|
|
||||||
specific_version="$(get_specific_version_from_version "$azure_feed" "$channel" "$normalized_architecture" "$version")"
|
normalized_os="$(get_normalized_os "$user_defined_os")"
|
||||||
|
say_verbose "normalized_os=$normalized_os"
|
||||||
|
|
||||||
|
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"
|
say_verbose "specific_version=$specific_version"
|
||||||
if [ -z "$specific_version" ]; then
|
if [ -z "$specific_version" ]; then
|
||||||
say_err "Could not resolve version information."
|
say_err "Could not resolve version information."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
download_link="$(construct_download_link "$azure_feed" "$channel" "$normalized_architecture" "$specific_version")"
|
download_link="$(construct_download_link "$azure_feed" "$channel" "$normalized_architecture" "$specific_version" "$normalized_os")"
|
||||||
say_verbose "Constructed primary named payload URL: $download_link"
|
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
|
legacy_download_link="$(construct_legacy_download_link "$azure_feed" "$channel" "$normalized_architecture" "$specific_version")" || valid_legacy_download_link=false
|
||||||
@@ -773,46 +897,98 @@ install_dotnet() {
|
|||||||
zip_path="$(mktemp "$temporary_file_template")"
|
zip_path="$(mktemp "$temporary_file_template")"
|
||||||
say_verbose "Zip path: $zip_path"
|
say_verbose "Zip path: $zip_path"
|
||||||
|
|
||||||
say "Downloading link: $download_link"
|
|
||||||
|
|
||||||
# Failures are normal in the non-legacy case for ultimately legacy downloads.
|
# Failures are normal in the non-legacy case for ultimately legacy downloads.
|
||||||
# Do not output to stderr, since output to stderr is considered an error.
|
# 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.
|
||||||
download "$download_link" "$zip_path" 2>&1 || download_failed=true
|
download "$download_link" "$zip_path" 2>&1 || download_failed=true
|
||||||
|
|
||||||
# if the download fails, download the legacy_download_link
|
# if the download fails, download the legacy_download_link
|
||||||
if [ "$download_failed" = true ]; then
|
if [ "$download_failed" = true ]; then
|
||||||
say "Cannot download: $download_link"
|
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
|
if [ "$valid_legacy_download_link" = true ]; then
|
||||||
download_failed=false
|
download_failed=false
|
||||||
download_link="$legacy_download_link"
|
download_link="$legacy_download_link"
|
||||||
zip_path="$(mktemp "$temporary_file_template")"
|
zip_path="$(mktemp "$temporary_file_template")"
|
||||||
say_verbose "Legacy zip path: $zip_path"
|
say_verbose "Legacy zip path: $zip_path"
|
||||||
say "Downloading legacy link: $download_link"
|
|
||||||
|
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
|
||||||
say "Cannot download: $download_link"
|
legacy_path_http_code="$http_code"; legacy_path_download_error_msg="$download_error_msg"
|
||||||
|
case $legacy_path_http_code in
|
||||||
|
404)
|
||||||
|
say "The resource at $download_link is not available."
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
say "$legacy_path_download_error_msg"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
rm -f "$zip_path" 2>&1 && say_verbose "Temporary zip file $zip_path was removed"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$download_failed" = true ]; then
|
if [ "$download_failed" = true ]; then
|
||||||
say_err "Could not find/download: \`$asset_name\` with version = $specific_version"
|
if [[ "$primary_path_http_code" = "404" && ( "$valid_legacy_download_link" = false || "$legacy_path_http_code" = "404") ]]; then
|
||||||
say_err "Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support"
|
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"
|
||||||
|
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
|
||||||
|
|
||||||
say "Extracting zip from $download_link"
|
say "Extracting zip from $download_link"
|
||||||
extract_dotnet_package "$zip_path" "$install_root"
|
extract_dotnet_package "$zip_path" "$install_root" || return 1
|
||||||
|
|
||||||
# Check if the SDK version is now installed; if not, fail the installation.
|
# Check if the SDK version is installed; if not, fail the installation.
|
||||||
if ! is_dotnet_package_installed "$install_root" "$asset_relative_path" "$specific_version"; then
|
# if the version contains "RTM" or "servicing"; check if a 'release-type' SDK version is installed.
|
||||||
say_err "\`$asset_name\` with version = $specific_version failed to install with an unknown error."
|
if [[ $specific_version == *"rtm"* || $specific_version == *"servicing"* ]]; then
|
||||||
return 1
|
IFS='-'
|
||||||
|
read -ra verArr <<< "$specific_version"
|
||||||
|
release_version="${verArr[0]}"
|
||||||
|
unset IFS;
|
||||||
|
say_verbose "Checking installation: version = $release_version"
|
||||||
|
if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$release_version"; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
# Check if the standard SDK version is installed.
|
||||||
|
say_verbose "Checking installation: version = $specific_product_version"
|
||||||
|
if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$specific_product_version"; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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 "\`$asset_name\` with version = $specific_product_version failed to install with an unknown error."
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
args=("$@")
|
args=("$@")
|
||||||
@@ -823,6 +999,7 @@ temporary_file_template="${TMPDIR:-/tmp}/dotnet.XXXXXXXXX"
|
|||||||
|
|
||||||
channel="LTS"
|
channel="LTS"
|
||||||
version="Latest"
|
version="Latest"
|
||||||
|
json_file=""
|
||||||
install_dir="<auto>"
|
install_dir="<auto>"
|
||||||
architecture="<auto>"
|
architecture="<auto>"
|
||||||
dry_run=false
|
dry_run=false
|
||||||
@@ -836,6 +1013,7 @@ runtime=""
|
|||||||
runtime_id=""
|
runtime_id=""
|
||||||
override_non_versioned_files=true
|
override_non_versioned_files=true
|
||||||
non_dynamic_parameters=""
|
non_dynamic_parameters=""
|
||||||
|
user_defined_os=""
|
||||||
|
|
||||||
while [ $# -ne 0 ]
|
while [ $# -ne 0 ]
|
||||||
do
|
do
|
||||||
@@ -857,6 +1035,10 @@ do
|
|||||||
shift
|
shift
|
||||||
architecture="$1"
|
architecture="$1"
|
||||||
;;
|
;;
|
||||||
|
--os|-[Oo][SS])
|
||||||
|
shift
|
||||||
|
user_defined_os="$1"
|
||||||
|
;;
|
||||||
--shared-runtime|-[Ss]hared[Rr]untime)
|
--shared-runtime|-[Ss]hared[Rr]untime)
|
||||||
say_warning "The --shared-runtime flag is obsolete and may be removed in a future version of this script. The recommended usage is to specify '--runtime dotnet'."
|
say_warning "The --shared-runtime flag is obsolete and may be removed in a future version of this script. The recommended usage is to specify '--runtime dotnet'."
|
||||||
if [ -z "$runtime" ]; then
|
if [ -z "$runtime" ]; then
|
||||||
@@ -868,6 +1050,9 @@ do
|
|||||||
runtime="$1"
|
runtime="$1"
|
||||||
if [[ "$runtime" != "dotnet" ]] && [[ "$runtime" != "aspnetcore" ]]; then
|
if [[ "$runtime" != "dotnet" ]] && [[ "$runtime" != "aspnetcore" ]]; then
|
||||||
say_err "Unsupported value for --runtime: '$1'. Valid values are 'dotnet' and 'aspnetcore'."
|
say_err "Unsupported value for --runtime: '$1'. Valid values are 'dotnet' and 'aspnetcore'."
|
||||||
|
if [[ "$runtime" == "windowsdesktop" ]]; then
|
||||||
|
say_err "WindowsDesktop archives are manufactured for Windows platforms only."
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@@ -905,6 +1090,11 @@ do
|
|||||||
shift
|
shift
|
||||||
runtime_id="$1"
|
runtime_id="$1"
|
||||||
non_dynamic_parameters+=" $name "\""$1"\"""
|
non_dynamic_parameters+=" $name "\""$1"\"""
|
||||||
|
say_warning "Use of --runtime-id is obsolete and should be limited to the versions below 2.1. To override architecture, use --architecture option instead. To override OS, use --os option instead."
|
||||||
|
;;
|
||||||
|
--jsonfile|-[Jj][Ss]on[Ff]ile)
|
||||||
|
shift
|
||||||
|
json_file="$1"
|
||||||
;;
|
;;
|
||||||
--skip-non-versioned-files|-[Ss]kip[Nn]on[Vv]ersioned[Ff]iles)
|
--skip-non-versioned-files|-[Ss]kip[Nn]on[Vv]ersioned[Ff]iles)
|
||||||
override_non_versioned_files=false
|
override_non_versioned_files=false
|
||||||
@@ -933,8 +1123,6 @@ do
|
|||||||
echo " -Version"
|
echo " -Version"
|
||||||
echo " Possible values:"
|
echo " Possible values:"
|
||||||
echo " - latest - most latest build on specific channel"
|
echo " - latest - most latest build on specific channel"
|
||||||
echo " - coherent - most latest coherent build on specific channel"
|
|
||||||
echo " coherent applies only to SDK downloads"
|
|
||||||
echo " - 3-part version in a format A.B.C - represents specific version of build"
|
echo " - 3-part version in a format A.B.C - represents specific version of build"
|
||||||
echo " examples: 2.0.0-preview2-006120; 1.1.0"
|
echo " examples: 2.0.0-preview2-006120; 1.1.0"
|
||||||
echo " -i,--install-dir <DIR> Install under specified location (see Install Location below)"
|
echo " -i,--install-dir <DIR> Install under specified location (see Install Location below)"
|
||||||
@@ -942,27 +1130,36 @@ do
|
|||||||
echo " --architecture <ARCHITECTURE> Architecture of dotnet binaries to be installed, Defaults to \`$architecture\`."
|
echo " --architecture <ARCHITECTURE> Architecture of dotnet binaries to be installed, Defaults to \`$architecture\`."
|
||||||
echo " --arch,-Architecture,-Arch"
|
echo " --arch,-Architecture,-Arch"
|
||||||
echo " Possible values: x64, arm, and arm64"
|
echo " Possible values: x64, arm, and arm64"
|
||||||
|
echo " --os <system> Specifies operating system to be used when selecting the installer."
|
||||||
|
echo " Overrides the OS determination approach used by the script. Supported values: osx, linux, linux-musl, freebsd, rhel.6."
|
||||||
|
echo " In case any other value is provided, the platform will be determined by the script based on machine configuration."
|
||||||
|
echo " Not supported for legacy links. Use --runtime-id to specify platform for legacy links."
|
||||||
|
echo " Refer to: https://aka.ms/dotnet-os-lifecycle for more information."
|
||||||
echo " --runtime <RUNTIME> Installs a shared runtime only, without the SDK."
|
echo " --runtime <RUNTIME> Installs a shared runtime only, without the SDK."
|
||||||
echo " -Runtime"
|
echo " -Runtime"
|
||||||
echo " Possible values:"
|
echo " Possible values:"
|
||||||
echo " - dotnet - the Microsoft.NETCore.App shared runtime"
|
echo " - dotnet - the Microsoft.NETCore.App shared runtime"
|
||||||
echo " - aspnetcore - the Microsoft.AspNetCore.App shared runtime"
|
echo " - aspnetcore - the Microsoft.AspNetCore.App shared runtime"
|
||||||
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
|
|
||||||
echo " -SkipNonVersionedFiles"
|
|
||||||
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 Azure feed location. Defaults to $azure_feed, This parameter typically is not changed by the user."
|
||||||
echo " --uncached-feed,-UncachedFeed Uncached feed location. This parameter typically is not changed by the user."
|
echo " --uncached-feed,-UncachedFeed Uncached feed location. This parameter typically is not changed by the user."
|
||||||
echo " --no-cdn,-NoCdn Disable downloading from the Azure CDN, and use the uncached feed directly."
|
|
||||||
echo " --feed-credential,-FeedCredential Azure feed shared access token. This parameter typically is not specified."
|
echo " --feed-credential,-FeedCredential Azure feed shared access token. This parameter typically is not specified."
|
||||||
echo " --runtime-id Installs the .NET Tools for the given platform (use linux-x64 for portable linux)."
|
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
|
||||||
echo " -RuntimeId"
|
echo " -SkipNonVersionedFiles"
|
||||||
|
echo " --no-cdn,-NoCdn Disable downloading from the Azure CDN, and use the uncached feed directly."
|
||||||
|
echo " --jsonfile <JSONFILE> Determines the SDK version from a user specified global.json file."
|
||||||
|
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 "Obsolete parameters:"
|
||||||
echo " --shared-runtime The recommended alternative is '--runtime dotnet'."
|
echo " --shared-runtime The recommended alternative is '--runtime dotnet'."
|
||||||
echo " -SharedRuntime Installs just the shared runtime bits, not the entire SDK."
|
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 ""
|
||||||
echo "Install Location:"
|
echo "Install Location:"
|
||||||
echo " Location is chosen in following order:"
|
echo " Location is chosen in following order:"
|
||||||
@@ -984,6 +1181,11 @@ if [ "$no_cdn" = true ]; then
|
|||||||
azure_feed="$uncached_feed"
|
azure_feed="$uncached_feed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
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 installation doesn't need to persist across multiple CI runs."
|
||||||
|
say "To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer.\n"
|
||||||
|
|
||||||
check_min_reqs
|
check_min_reqs
|
||||||
calculate_vars
|
calculate_vars
|
||||||
script_name=$(basename "$0")
|
script_name=$(basename "$0")
|
||||||
@@ -994,7 +1196,7 @@ if [ "$dry_run" = true ]; then
|
|||||||
if [ "$valid_legacy_download_link" = true ]; then
|
if [ "$valid_legacy_download_link" = true ]; then
|
||||||
say "Legacy named payload URL: $legacy_download_link"
|
say "Legacy named payload URL: $legacy_download_link"
|
||||||
fi
|
fi
|
||||||
repeatable_command="./$script_name --version "\""$specific_version"\"" --install-dir "\""$install_root"\"" --architecture "\""$normalized_architecture"\"""
|
repeatable_command="./$script_name --version "\""$specific_version"\"" --install-dir "\""$install_root"\"" --architecture "\""$normalized_architecture"\"" --os "\""$normalized_os"\"""
|
||||||
if [[ "$runtime" == "dotnet" ]]; then
|
if [[ "$runtime" == "dotnet" ]]; then
|
||||||
repeatable_command+=" --runtime "\""dotnet"\"""
|
repeatable_command+=" --runtime "\""dotnet"\"""
|
||||||
elif [[ "$runtime" == "aspnetcore" ]]; then
|
elif [[ "$runtime" == "aspnetcore" ]]; then
|
||||||
@@ -1005,7 +1207,6 @@ if [ "$dry_run" = true ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
check_pre_reqs
|
|
||||||
install_dotnet
|
install_dotnet
|
||||||
|
|
||||||
bin_path="$(get_absolute_path "$(combine_paths "$install_root" "$bin_folder_relative_path")")"
|
bin_path="$(get_absolute_path "$(combine_paths "$install_root" "$bin_folder_relative_path")")"
|
||||||
@@ -1016,4 +1217,6 @@ else
|
|||||||
say "Binaries of dotnet can be found in $bin_path"
|
say "Binaries of dotnet can be found in $bin_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
say "Note that the script does not resolve dependencies during installation."
|
||||||
|
say "To check the list of dependencies, go to https://docs.microsoft.com/dotnet/core/install, select your operating system and check the \"Dependencies\" section."
|
||||||
say "Installation finished successfully."
|
say "Installation finished successfully."
|
||||||
|
|||||||
307
lib/installer.js
307
lib/installer.js
@@ -1,307 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
// Load tempDirectory before it gets wiped by tool-cache
|
|
||||||
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
|
||||||
const core = __importStar(require("@actions/core"));
|
|
||||||
const exec = __importStar(require("@actions/exec"));
|
|
||||||
const io = __importStar(require("@actions/io"));
|
|
||||||
const tc = __importStar(require("@actions/tool-cache"));
|
|
||||||
const httpClient = require("typed-rest-client/HttpClient");
|
|
||||||
const fs_1 = require("fs");
|
|
||||||
const os = __importStar(require("os"));
|
|
||||||
const path = __importStar(require("path"));
|
|
||||||
const semver = __importStar(require("semver"));
|
|
||||||
const util = __importStar(require("util"));
|
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
|
||||||
if (!tempDirectory) {
|
|
||||||
let baseLocation;
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
// On windows use the USERPROFILE env variable
|
|
||||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (process.platform === 'darwin') {
|
|
||||||
baseLocation = '/Users';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
baseLocation = '/home';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
|
||||||
}
|
|
||||||
class DotnetCoreInstaller {
|
|
||||||
constructor(version) {
|
|
||||||
if (semver.valid(semver.clean(version) || '') == null) {
|
|
||||||
throw 'Implicit version not permitted';
|
|
||||||
}
|
|
||||||
this.version = version;
|
|
||||||
this.cachedToolName = 'dncs';
|
|
||||||
this.arch = 'x64';
|
|
||||||
}
|
|
||||||
installDotnet() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
// Check cache
|
|
||||||
let toolPath;
|
|
||||||
let osSuffixes = yield this.detectMachineOS();
|
|
||||||
let parts = osSuffixes[0].split('-');
|
|
||||||
if (parts.length > 1) {
|
|
||||||
this.arch = parts[1];
|
|
||||||
}
|
|
||||||
toolPath = this.getLocalTool();
|
|
||||||
if (!toolPath) {
|
|
||||||
// download, extract, cache
|
|
||||||
console.log('Getting a download url', this.version);
|
|
||||||
let downloadUrls = yield this.getDownloadUrls(osSuffixes, this.version);
|
|
||||||
toolPath = yield this.downloadAndInstall(downloadUrls);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log('Using cached tool');
|
|
||||||
}
|
|
||||||
// Prepend the tools path. instructs the agent to prepend for future tasks
|
|
||||||
core.addPath(toolPath);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getLocalTool() {
|
|
||||||
console.log('Checking tool cache');
|
|
||||||
return tc.find(this.cachedToolName, this.version, this.arch);
|
|
||||||
}
|
|
||||||
detectMachineOS() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let osSuffix = [];
|
|
||||||
let output = '';
|
|
||||||
let resultCode = 0;
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
let escapedScript = path
|
|
||||||
.join(__dirname, '..', 'externals', 'get-os-platform.ps1')
|
|
||||||
.replace(/'/g, "''");
|
|
||||||
let command = `& '${escapedScript}'`;
|
|
||||||
const powershellPath = yield io.which('powershell', true);
|
|
||||||
resultCode = yield exec.exec(`"${powershellPath}"`, [
|
|
||||||
'-NoLogo',
|
|
||||||
'-Sta',
|
|
||||||
'-NoProfile',
|
|
||||||
'-NonInteractive',
|
|
||||||
'-ExecutionPolicy',
|
|
||||||
'Unrestricted',
|
|
||||||
'-Command',
|
|
||||||
command
|
|
||||||
], {
|
|
||||||
listeners: {
|
|
||||||
stdout: (data) => {
|
|
||||||
output += data.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let scriptPath = path.join(__dirname, '..', 'externals', 'get-os-distro.sh');
|
|
||||||
fs_1.chmodSync(scriptPath, '777');
|
|
||||||
const toolPath = yield io.which(scriptPath, true);
|
|
||||||
resultCode = yield exec.exec(`"${toolPath}"`, [], {
|
|
||||||
listeners: {
|
|
||||||
stdout: (data) => {
|
|
||||||
output += data.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (resultCode != 0) {
|
|
||||||
throw `Failed to detect os with result code ${resultCode}. Output: ${output}`;
|
|
||||||
}
|
|
||||||
let index;
|
|
||||||
if ((index = output.indexOf('Primary:')) >= 0) {
|
|
||||||
let primary = output.substr(index + 'Primary:'.length).split(os.EOL)[0];
|
|
||||||
osSuffix.push(primary);
|
|
||||||
}
|
|
||||||
if ((index = output.indexOf('Legacy:')) >= 0) {
|
|
||||||
let legacy = output.substr(index + 'Legacy:'.length).split(os.EOL)[0];
|
|
||||||
osSuffix.push(legacy);
|
|
||||||
}
|
|
||||||
if (osSuffix.length == 0) {
|
|
||||||
throw 'Could not detect platform';
|
|
||||||
}
|
|
||||||
return osSuffix;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
downloadAndInstall(downloadUrls) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let downloaded = false;
|
|
||||||
let downloadPath = '';
|
|
||||||
for (const url of downloadUrls) {
|
|
||||||
try {
|
|
||||||
downloadPath = yield tc.downloadTool(url);
|
|
||||||
downloaded = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
console.log('Could Not Download', url, JSON.stringify(error));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!downloaded) {
|
|
||||||
throw 'Failed to download package';
|
|
||||||
}
|
|
||||||
// extract
|
|
||||||
console.log('Extracting Package', downloadPath);
|
|
||||||
let extPath = IS_WINDOWS
|
|
||||||
? yield tc.extractZip(downloadPath)
|
|
||||||
: yield tc.extractTar(downloadPath);
|
|
||||||
// cache tool
|
|
||||||
console.log('Caching tool');
|
|
||||||
let cachedDir = yield tc.cacheDir(extPath, this.cachedToolName, this.version, this.arch);
|
|
||||||
console.log('Successfully installed', this.version);
|
|
||||||
return cachedDir;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// OsSuffixes - The suffix which is a part of the file name ex- linux-x64, windows-x86
|
|
||||||
// Type - SDK / Runtime
|
|
||||||
// Version - Version of the SDK/Runtime
|
|
||||||
getDownloadUrls(osSuffixes, version) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let downloadUrls = [];
|
|
||||||
let releasesJSON = yield this.getReleasesJson();
|
|
||||||
core.debug('Releases: ' + releasesJSON);
|
|
||||||
let releasesInfo = JSON.parse(yield releasesJSON.readBody());
|
|
||||||
releasesInfo = releasesInfo.filter((releaseInfo) => {
|
|
||||||
return (releaseInfo['version-sdk'] === version ||
|
|
||||||
releaseInfo['version-sdk-display'] === version);
|
|
||||||
});
|
|
||||||
if (releasesInfo.length != 0) {
|
|
||||||
let release = releasesInfo[0];
|
|
||||||
let blobUrl = release['blob-sdk'];
|
|
||||||
let dlcUrl = release['dlc--sdk'];
|
|
||||||
let fileName = release['sdk-' + osSuffixes[0]]
|
|
||||||
? release['sdk-' + osSuffixes[0]]
|
|
||||||
: release['sdk-' + osSuffixes[1]];
|
|
||||||
if (!!fileName) {
|
|
||||||
fileName = fileName.trim();
|
|
||||||
// For some latest version, the filename itself can be full download url.
|
|
||||||
// Do a very basic check for url(instead of regex) as the url is only for downloading and
|
|
||||||
// is coming from .net core releases json and not some ransom user input
|
|
||||||
if (fileName.toLowerCase().startsWith('https://')) {
|
|
||||||
downloadUrls.push(fileName);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!!blobUrl) {
|
|
||||||
downloadUrls.push(util.format('%s%s', blobUrl.trim(), fileName));
|
|
||||||
}
|
|
||||||
if (!!dlcUrl) {
|
|
||||||
downloadUrls.push(util.format('%s%s', dlcUrl.trim(), fileName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw `The specified version's download links are not correctly formed in the supported versions document => ${DotNetCoreReleasesUrl}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(`Could not fetch download information for version ${version}`);
|
|
||||||
downloadUrls = yield this.getFallbackDownloadUrls(version);
|
|
||||||
}
|
|
||||||
if (downloadUrls.length == 0) {
|
|
||||||
throw `Could not construct download URL. Please ensure that specified version ${version} is valid.`;
|
|
||||||
}
|
|
||||||
core.debug(`Got download urls ${downloadUrls}`);
|
|
||||||
return downloadUrls;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getReleasesJson() {
|
|
||||||
var httpCallbackClient = new httpClient.HttpClient('setup-dotnet', [], {});
|
|
||||||
return httpCallbackClient.get(DotNetCoreReleasesUrl);
|
|
||||||
}
|
|
||||||
getFallbackDownloadUrls(version) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let primaryUrlSearchString;
|
|
||||||
let legacyUrlSearchString;
|
|
||||||
let output = '';
|
|
||||||
let resultCode = 0;
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
let escapedScript = path
|
|
||||||
.join(__dirname, '..', 'externals', 'install-dotnet.ps1')
|
|
||||||
.replace(/'/g, "''");
|
|
||||||
let command = `& '${escapedScript}' -Version ${version} -DryRun`;
|
|
||||||
const powershellPath = yield io.which('powershell', true);
|
|
||||||
resultCode = yield exec.exec(`"${powershellPath}"`, [
|
|
||||||
'-NoLogo',
|
|
||||||
'-Sta',
|
|
||||||
'-NoProfile',
|
|
||||||
'-NonInteractive',
|
|
||||||
'-ExecutionPolicy',
|
|
||||||
'Unrestricted',
|
|
||||||
'-Command',
|
|
||||||
command
|
|
||||||
], {
|
|
||||||
listeners: {
|
|
||||||
stdout: (data) => {
|
|
||||||
output += data.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
primaryUrlSearchString = 'dotnet-install: Primary named payload URL: ';
|
|
||||||
legacyUrlSearchString = 'dotnet-install: Legacy named payload URL: ';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let escapedScript = path
|
|
||||||
.join(__dirname, '..', 'externals', 'install-dotnet.sh')
|
|
||||||
.replace(/'/g, "''");
|
|
||||||
fs_1.chmodSync(escapedScript, '777');
|
|
||||||
const scriptPath = yield io.which(escapedScript, true);
|
|
||||||
resultCode = yield exec.exec(`"${scriptPath}"`, ['--version', version, '--dry-run'], {
|
|
||||||
listeners: {
|
|
||||||
stdout: (data) => {
|
|
||||||
output += data.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
primaryUrlSearchString = 'dotnet-install: Primary named payload URL: ';
|
|
||||||
legacyUrlSearchString = 'dotnet-install: Legacy named payload URL: ';
|
|
||||||
}
|
|
||||||
if (resultCode != 0) {
|
|
||||||
throw `Failed to get download urls with result code ${resultCode}. ${output}`;
|
|
||||||
}
|
|
||||||
let primaryUrl = '';
|
|
||||||
let legacyUrl = '';
|
|
||||||
if (!!output && output.length > 0) {
|
|
||||||
let lines = output.split(os.EOL);
|
|
||||||
// Fallback to \n if initial split doesn't work (not consistent across versions)
|
|
||||||
if (lines.length === 1) {
|
|
||||||
lines = output.split('\n');
|
|
||||||
}
|
|
||||||
if (!!lines && lines.length > 0) {
|
|
||||||
lines.forEach((line) => {
|
|
||||||
if (!line) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var primarySearchStringIndex = line.indexOf(primaryUrlSearchString);
|
|
||||||
if (primarySearchStringIndex > -1) {
|
|
||||||
primaryUrl = line.substring(primarySearchStringIndex + primaryUrlSearchString.length);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var legacySearchStringIndex = line.indexOf(legacyUrlSearchString);
|
|
||||||
if (legacySearchStringIndex > -1) {
|
|
||||||
legacyUrl = line.substring(legacySearchStringIndex + legacyUrlSearchString.length);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return [primaryUrl, legacyUrl];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.DotnetCoreInstaller = DotnetCoreInstaller;
|
|
||||||
const DotNetCoreReleasesUrl = 'https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases.json';
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const core = __importStar(require("@actions/core"));
|
|
||||||
const installer = __importStar(require("./installer"));
|
|
||||||
const path = __importStar(require("path"));
|
|
||||||
function run() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
//
|
|
||||||
// Version is optional. If supplied, install / use from the tool cache
|
|
||||||
// If not supplied then task is still used to setup proxy, auth, etc...
|
|
||||||
//
|
|
||||||
let version = core.getInput('version');
|
|
||||||
if (!version) {
|
|
||||||
version = core.getInput('dotnet-version');
|
|
||||||
}
|
|
||||||
if (version) {
|
|
||||||
const dotnetInstaller = new installer.DotnetCoreInstaller(version);
|
|
||||||
yield dotnetInstaller.installDotnet();
|
|
||||||
}
|
|
||||||
// TODO: setup proxy from runner proxy config
|
|
||||||
const matchersPath = path.join(__dirname, '..', '.github');
|
|
||||||
console.log(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`);
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
core.setFailed(error.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
run();
|
|
||||||
7
node_modules/@actions/core/README.md
generated
vendored
7
node_modules/@actions/core/README.md
generated
vendored
@@ -1,7 +0,0 @@
|
|||||||
# `@actions/core`
|
|
||||||
|
|
||||||
> Core functions for setting results, logging, registering secrets and exporting variables across actions
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
See [src/core.ts](src/core.ts).
|
|
||||||
16
node_modules/@actions/core/lib/command.d.ts
generated
vendored
16
node_modules/@actions/core/lib/command.d.ts
generated
vendored
@@ -1,16 +0,0 @@
|
|||||||
interface CommandProperties {
|
|
||||||
[key: string]: string;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Commands
|
|
||||||
*
|
|
||||||
* Command Format:
|
|
||||||
* ##[name key=value;key=value]message
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ##[warning]This is the user warning message
|
|
||||||
* ##[set-secret name=mypassword]definatelyNotAPassword!
|
|
||||||
*/
|
|
||||||
export declare function issueCommand(command: string, properties: CommandProperties, message: string): void;
|
|
||||||
export declare function issue(name: string, message: string): void;
|
|
||||||
export {};
|
|
||||||
66
node_modules/@actions/core/lib/command.js
generated
vendored
66
node_modules/@actions/core/lib/command.js
generated
vendored
@@ -1,66 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const os = require("os");
|
|
||||||
/**
|
|
||||||
* Commands
|
|
||||||
*
|
|
||||||
* Command Format:
|
|
||||||
* ##[name key=value;key=value]message
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ##[warning]This is the user warning message
|
|
||||||
* ##[set-secret name=mypassword]definatelyNotAPassword!
|
|
||||||
*/
|
|
||||||
function issueCommand(command, properties, message) {
|
|
||||||
const cmd = new Command(command, properties, message);
|
|
||||||
process.stdout.write(cmd.toString() + os.EOL);
|
|
||||||
}
|
|
||||||
exports.issueCommand = issueCommand;
|
|
||||||
function issue(name, message) {
|
|
||||||
issueCommand(name, {}, message);
|
|
||||||
}
|
|
||||||
exports.issue = issue;
|
|
||||||
const CMD_PREFIX = '##[';
|
|
||||||
class Command {
|
|
||||||
constructor(command, properties, message) {
|
|
||||||
if (!command) {
|
|
||||||
command = 'missing.command';
|
|
||||||
}
|
|
||||||
this.command = command;
|
|
||||||
this.properties = properties;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
toString() {
|
|
||||||
let cmdStr = CMD_PREFIX + this.command;
|
|
||||||
if (this.properties && Object.keys(this.properties).length > 0) {
|
|
||||||
cmdStr += ' ';
|
|
||||||
for (const key in this.properties) {
|
|
||||||
if (this.properties.hasOwnProperty(key)) {
|
|
||||||
const val = this.properties[key];
|
|
||||||
if (val) {
|
|
||||||
// safely append the val - avoid blowing up when attempting to
|
|
||||||
// call .replace() if message is not a string for some reason
|
|
||||||
cmdStr += `${key}=${escape(`${val || ''}`)};`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cmdStr += ']';
|
|
||||||
// safely append the message - avoid blowing up when attempting to
|
|
||||||
// call .replace() if message is not a string for some reason
|
|
||||||
const message = `${this.message || ''}`;
|
|
||||||
cmdStr += escapeData(message);
|
|
||||||
return cmdStr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function escapeData(s) {
|
|
||||||
return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A');
|
|
||||||
}
|
|
||||||
function escape(s) {
|
|
||||||
return s
|
|
||||||
.replace(/\r/g, '%0D')
|
|
||||||
.replace(/\n/g, '%0A')
|
|
||||||
.replace(/]/g, '%5D')
|
|
||||||
.replace(/;/g, '%3B');
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=command.js.map
|
|
||||||
1
node_modules/@actions/core/lib/command.js.map
generated
vendored
1
node_modules/@actions/core/lib/command.js.map
generated
vendored
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,OAAe;IACjD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,KAAK,CAAA;AAExB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,OAAO,CAAA;QAEtC,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9D,MAAM,IAAI,GAAG,CAAA;YACb,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjC,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;oBACvC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;oBAChC,IAAI,GAAG,EAAE;wBACP,8DAA8D;wBAC9D,6DAA6D;wBAC7D,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAA;qBAC9C;iBACF;aACF;SACF;QAED,MAAM,IAAI,GAAG,CAAA;QAEb,kEAAkE;QAClE,6DAA6D;QAC7D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;QACvC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC;SACL,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}
|
|
||||||
57
node_modules/@actions/core/lib/core.d.ts
generated
vendored
57
node_modules/@actions/core/lib/core.d.ts
generated
vendored
@@ -1,57 +0,0 @@
|
|||||||
/**
|
|
||||||
* Interface for getInput options
|
|
||||||
*/
|
|
||||||
export interface InputOptions {
|
|
||||||
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
|
||||||
required?: boolean;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* sets env variable for this action and future actions in the job
|
|
||||||
* @param name the name of the variable to set
|
|
||||||
* @param val the value of the variable
|
|
||||||
*/
|
|
||||||
export declare function exportVariable(name: string, val: string): void;
|
|
||||||
/**
|
|
||||||
* exports the variable and registers a secret which will get masked from logs
|
|
||||||
* @param name the name of the variable to set
|
|
||||||
* @param val value of the secret
|
|
||||||
*/
|
|
||||||
export declare function exportSecret(name: string, val: string): void;
|
|
||||||
/**
|
|
||||||
* Prepends inputPath to the PATH (for this action and future actions)
|
|
||||||
* @param inputPath
|
|
||||||
*/
|
|
||||||
export declare function addPath(inputPath: string): void;
|
|
||||||
/**
|
|
||||||
* Gets the value of an input. The value is also trimmed.
|
|
||||||
*
|
|
||||||
* @param name name of the input to get
|
|
||||||
* @param options optional. See InputOptions.
|
|
||||||
* @returns string
|
|
||||||
*/
|
|
||||||
export declare function getInput(name: string, options?: InputOptions): string;
|
|
||||||
/**
|
|
||||||
* Sets the action status to neutral
|
|
||||||
*/
|
|
||||||
export declare function setNeutral(): void;
|
|
||||||
/**
|
|
||||||
* Sets the action status to failed.
|
|
||||||
* When the action exits it will be with an exit code of 1
|
|
||||||
* @param message add error issue message
|
|
||||||
*/
|
|
||||||
export declare function setFailed(message: string): void;
|
|
||||||
/**
|
|
||||||
* Writes debug message to user log
|
|
||||||
* @param message debug message
|
|
||||||
*/
|
|
||||||
export declare function debug(message: string): void;
|
|
||||||
/**
|
|
||||||
* Adds an error issue
|
|
||||||
* @param message error issue message
|
|
||||||
*/
|
|
||||||
export declare function error(message: string): void;
|
|
||||||
/**
|
|
||||||
* Adds an warning issue
|
|
||||||
* @param message warning issue message
|
|
||||||
*/
|
|
||||||
export declare function warning(message: string): void;
|
|
||||||
100
node_modules/@actions/core/lib/core.js
generated
vendored
100
node_modules/@actions/core/lib/core.js
generated
vendored
@@ -1,100 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const exit_1 = require("@actions/exit");
|
|
||||||
const command_1 = require("./command");
|
|
||||||
const path = require("path");
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Variables
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* sets env variable for this action and future actions in the job
|
|
||||||
* @param name the name of the variable to set
|
|
||||||
* @param val the value of the variable
|
|
||||||
*/
|
|
||||||
function exportVariable(name, val) {
|
|
||||||
process.env[name] = val;
|
|
||||||
command_1.issueCommand('set-env', { name }, val);
|
|
||||||
}
|
|
||||||
exports.exportVariable = exportVariable;
|
|
||||||
/**
|
|
||||||
* exports the variable and registers a secret which will get masked from logs
|
|
||||||
* @param name the name of the variable to set
|
|
||||||
* @param val value of the secret
|
|
||||||
*/
|
|
||||||
function exportSecret(name, val) {
|
|
||||||
exportVariable(name, val);
|
|
||||||
command_1.issueCommand('set-secret', {}, val);
|
|
||||||
}
|
|
||||||
exports.exportSecret = exportSecret;
|
|
||||||
/**
|
|
||||||
* Prepends inputPath to the PATH (for this action and future actions)
|
|
||||||
* @param inputPath
|
|
||||||
*/
|
|
||||||
function addPath(inputPath) {
|
|
||||||
command_1.issueCommand('add-path', {}, inputPath);
|
|
||||||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
|
||||||
}
|
|
||||||
exports.addPath = addPath;
|
|
||||||
/**
|
|
||||||
* Gets the value of an input. The value is also trimmed.
|
|
||||||
*
|
|
||||||
* @param name name of the input to get
|
|
||||||
* @param options optional. See InputOptions.
|
|
||||||
* @returns string
|
|
||||||
*/
|
|
||||||
function getInput(name, options) {
|
|
||||||
const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || '';
|
|
||||||
if (options && options.required && !val) {
|
|
||||||
throw new Error(`Input required and not supplied: ${name}`);
|
|
||||||
}
|
|
||||||
return val.trim();
|
|
||||||
}
|
|
||||||
exports.getInput = getInput;
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Results
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Sets the action status to neutral
|
|
||||||
*/
|
|
||||||
function setNeutral() {
|
|
||||||
process.exitCode = exit_1.ExitCode.Neutral;
|
|
||||||
}
|
|
||||||
exports.setNeutral = setNeutral;
|
|
||||||
/**
|
|
||||||
* Sets the action status to failed.
|
|
||||||
* When the action exits it will be with an exit code of 1
|
|
||||||
* @param message add error issue message
|
|
||||||
*/
|
|
||||||
function setFailed(message) {
|
|
||||||
process.exitCode = exit_1.ExitCode.Failure;
|
|
||||||
error(message);
|
|
||||||
}
|
|
||||||
exports.setFailed = setFailed;
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Logging Commands
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Writes debug message to user log
|
|
||||||
* @param message debug message
|
|
||||||
*/
|
|
||||||
function debug(message) {
|
|
||||||
command_1.issueCommand('debug', {}, message);
|
|
||||||
}
|
|
||||||
exports.debug = debug;
|
|
||||||
/**
|
|
||||||
* Adds an error issue
|
|
||||||
* @param message error issue message
|
|
||||||
*/
|
|
||||||
function error(message) {
|
|
||||||
command_1.issue('error', message);
|
|
||||||
}
|
|
||||||
exports.error = error;
|
|
||||||
/**
|
|
||||||
* Adds an warning issue
|
|
||||||
* @param message warning issue message
|
|
||||||
*/
|
|
||||||
function warning(message) {
|
|
||||||
command_1.issue('warning', message);
|
|
||||||
}
|
|
||||||
exports.warning = warning;
|
|
||||||
//# sourceMappingURL=core.js.map
|
|
||||||
1
node_modules/@actions/core/lib/core.js.map
generated
vendored
1
node_modules/@actions/core/lib/core.js.map
generated
vendored
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;AAAA,wCAAsC;AACtC,uCAA6C;AAE7C,6BAA4B;AAU5B,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACzB,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;AACrC,CAAC;AAHD,oCAGC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAsB;IAC3D,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IACpE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AARD,4BAQC;AAED,yEAAyE;AACzE,UAAU;AACV,yEAAyE;AAEzE;;GAEG;AACH,SAAgB,UAAU;IACxB,OAAO,CAAC,QAAQ,GAAG,eAAQ,CAAC,OAAO,CAAA;AACrC,CAAC;AAFD,gCAEC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,CAAC,QAAQ,GAAG,eAAQ,CAAC,OAAO,CAAA;IACnC,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC;AAHD,8BAGC;AAED,yEAAyE;AACzE,mBAAmB;AACnB,yEAAyE;AAEzE;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,sBAAY,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC"}
|
|
||||||
66
node_modules/@actions/core/package.json
generated
vendored
66
node_modules/@actions/core/package.json
generated
vendored
@@ -1,66 +0,0 @@
|
|||||||
{
|
|
||||||
"_from": "file:toolkit\\actions-core-0.0.0.tgz",
|
|
||||||
"_id": "@actions/core@0.0.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-58ituSV1rzBMmmsWoFDnrnsT+Wm4kD/u9NgAGbPvZ7rQHWluYtD5bDbIsjDC6rKFuhqytkxDJPsF/TWBdgc/nA==",
|
|
||||||
"_location": "/@actions/core",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "file",
|
|
||||||
"where": "C:\\Users\\damccorm\\Documents\\setup-dotnet",
|
|
||||||
"raw": "@actions/core@file:toolkit/actions-core-0.0.0.tgz",
|
|
||||||
"name": "@actions/core",
|
|
||||||
"escapedName": "@actions%2fcore",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "file:toolkit/actions-core-0.0.0.tgz",
|
|
||||||
"saveSpec": "file:toolkit\\actions-core-0.0.0.tgz",
|
|
||||||
"fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-dotnet\\toolkit\\actions-core-0.0.0.tgz"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/",
|
|
||||||
"/@actions/tool-cache"
|
|
||||||
],
|
|
||||||
"_resolved": "C:\\Users\\damccorm\\Documents\\setup-dotnet\\toolkit\\actions-core-0.0.0.tgz",
|
|
||||||
"_shasum": "346d90a534fa6c5021bc2e1b732574fd2c66fc35",
|
|
||||||
"_spec": "@actions/core@file:toolkit/actions-core-0.0.0.tgz",
|
|
||||||
"_where": "C:\\Users\\damccorm\\Documents\\setup-dotnet",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {
|
|
||||||
"@actions/exit": "^0.0.0"
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Actions core lib",
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "^12.0.2"
|
|
||||||
},
|
|
||||||
"directories": {
|
|
||||||
"lib": "lib",
|
|
||||||
"test": "__tests__"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"lib"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
|
|
||||||
"keywords": [
|
|
||||||
"core",
|
|
||||||
"actions"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/core.js",
|
|
||||||
"name": "@actions/core",
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/actions/toolkit.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
|
||||||
"tsc": "tsc"
|
|
||||||
},
|
|
||||||
"version": "0.0.0"
|
|
||||||
}
|
|
||||||
7
node_modules/@actions/exec/README.md
generated
vendored
7
node_modules/@actions/exec/README.md
generated
vendored
@@ -1,7 +0,0 @@
|
|||||||
# `@actions/exec`
|
|
||||||
|
|
||||||
> Functions necessary for running tools on the command line
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
See [src/exec.ts](src/exec.ts).
|
|
||||||
12
node_modules/@actions/exec/lib/exec.d.ts
generated
vendored
12
node_modules/@actions/exec/lib/exec.d.ts
generated
vendored
@@ -1,12 +0,0 @@
|
|||||||
import * as im from './interfaces';
|
|
||||||
/**
|
|
||||||
* Exec a command.
|
|
||||||
* Output will be streamed to the live console.
|
|
||||||
* Returns promise with return code
|
|
||||||
*
|
|
||||||
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
|
||||||
* @param args optional arguments for tool. Escaping is handled by the lib.
|
|
||||||
* @param options optional exec options. See ExecOptions
|
|
||||||
* @returns Promise<number> exit code
|
|
||||||
*/
|
|
||||||
export declare function exec(commandLine: string, args?: string[], options?: im.ExecOptions): Promise<number>;
|
|
||||||
36
node_modules/@actions/exec/lib/exec.js
generated
vendored
36
node_modules/@actions/exec/lib/exec.js
generated
vendored
@@ -1,36 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const tr = require("./toolrunner");
|
|
||||||
/**
|
|
||||||
* Exec a command.
|
|
||||||
* Output will be streamed to the live console.
|
|
||||||
* Returns promise with return code
|
|
||||||
*
|
|
||||||
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
|
||||||
* @param args optional arguments for tool. Escaping is handled by the lib.
|
|
||||||
* @param options optional exec options. See ExecOptions
|
|
||||||
* @returns Promise<number> exit code
|
|
||||||
*/
|
|
||||||
function exec(commandLine, args, options) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const commandArgs = tr.argStringToArray(commandLine);
|
|
||||||
if (commandArgs.length === 0) {
|
|
||||||
throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
|
|
||||||
}
|
|
||||||
// Path to tool to execute should be first arg
|
|
||||||
const toolPath = commandArgs[0];
|
|
||||||
args = commandArgs.slice(1).concat(args || []);
|
|
||||||
const runner = new tr.ToolRunner(toolPath, args, options);
|
|
||||||
return runner.exec();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.exec = exec;
|
|
||||||
//# sourceMappingURL=exec.js.map
|
|
||||||
1
node_modules/@actions/exec/lib/exec.js.map
generated
vendored
1
node_modules/@actions/exec/lib/exec.js.map
generated
vendored
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":";;;;;;;;;;AACA,mCAAkC;AAElC;;;;;;;;;GASG;AACH,SAAsB,IAAI,CACxB,WAAmB,EACnB,IAAe,EACf,OAAwB;;QAExB,MAAM,WAAW,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAA;QACpD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;SACpE;QACD,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;QAC/B,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;QAC9C,MAAM,MAAM,GAAkB,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QACxE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAA;IACtB,CAAC;CAAA;AAdD,oBAcC"}
|
|
||||||
35
node_modules/@actions/exec/lib/interfaces.d.ts
generated
vendored
35
node_modules/@actions/exec/lib/interfaces.d.ts
generated
vendored
@@ -1,35 +0,0 @@
|
|||||||
/// <reference types="node" />
|
|
||||||
import * as stream from 'stream';
|
|
||||||
/**
|
|
||||||
* Interface for exec options
|
|
||||||
*/
|
|
||||||
export interface ExecOptions {
|
|
||||||
/** optional working directory. defaults to current */
|
|
||||||
cwd?: string;
|
|
||||||
/** optional envvar dictionary. defaults to current process's env */
|
|
||||||
env?: {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
/** optional. defaults to false */
|
|
||||||
silent?: boolean;
|
|
||||||
/** optional out stream to use. Defaults to process.stdout */
|
|
||||||
outStream?: stream.Writable;
|
|
||||||
/** optional err stream to use. Defaults to process.stderr */
|
|
||||||
errStream?: stream.Writable;
|
|
||||||
/** optional. whether to skip quoting/escaping arguments if needed. defaults to false. */
|
|
||||||
windowsVerbatimArguments?: boolean;
|
|
||||||
/** optional. whether to fail if output to stderr. defaults to false */
|
|
||||||
failOnStdErr?: boolean;
|
|
||||||
/** optional. defaults to failing on non zero. ignore will not fail leaving it up to the caller */
|
|
||||||
ignoreReturnCode?: boolean;
|
|
||||||
/** optional. How long in ms to wait for STDIO streams to close after the exit event of the process before terminating. defaults to 10000 */
|
|
||||||
delay?: number;
|
|
||||||
/** optional. Listeners for output. Callback functions that will be called on these events */
|
|
||||||
listeners?: {
|
|
||||||
stdout?: (data: Buffer) => void;
|
|
||||||
stderr?: (data: Buffer) => void;
|
|
||||||
stdline?: (data: string) => void;
|
|
||||||
errline?: (data: string) => void;
|
|
||||||
debug?: (data: string) => void;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
3
node_modules/@actions/exec/lib/interfaces.js
generated
vendored
3
node_modules/@actions/exec/lib/interfaces.js
generated
vendored
@@ -1,3 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
//# sourceMappingURL=interfaces.js.map
|
|
||||||
1
node_modules/@actions/exec/lib/interfaces.js.map
generated
vendored
1
node_modules/@actions/exec/lib/interfaces.js.map
generated
vendored
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
|
|
||||||
37
node_modules/@actions/exec/lib/toolrunner.d.ts
generated
vendored
37
node_modules/@actions/exec/lib/toolrunner.d.ts
generated
vendored
@@ -1,37 +0,0 @@
|
|||||||
/// <reference types="node" />
|
|
||||||
import * as events from 'events';
|
|
||||||
import * as im from './interfaces';
|
|
||||||
export declare class ToolRunner extends events.EventEmitter {
|
|
||||||
constructor(toolPath: string, args?: string[], options?: im.ExecOptions);
|
|
||||||
private toolPath;
|
|
||||||
private args;
|
|
||||||
private options;
|
|
||||||
private _debug;
|
|
||||||
private _getCommandString;
|
|
||||||
private _processLineBuffer;
|
|
||||||
private _getSpawnFileName;
|
|
||||||
private _getSpawnArgs;
|
|
||||||
private _endsWith;
|
|
||||||
private _isCmdFile;
|
|
||||||
private _windowsQuoteCmdArg;
|
|
||||||
private _uvQuoteCmdArg;
|
|
||||||
private _cloneExecOptions;
|
|
||||||
private _getSpawnOptions;
|
|
||||||
/**
|
|
||||||
* Exec a tool.
|
|
||||||
* Output will be streamed to the live console.
|
|
||||||
* Returns promise with return code
|
|
||||||
*
|
|
||||||
* @param tool path to tool to exec
|
|
||||||
* @param options optional exec options. See ExecOptions
|
|
||||||
* @returns number
|
|
||||||
*/
|
|
||||||
exec(): Promise<number>;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Convert an arg string to an array of args. Handles escaping
|
|
||||||
*
|
|
||||||
* @param argString string of arguments
|
|
||||||
* @returns string[] array of arguments
|
|
||||||
*/
|
|
||||||
export declare function argStringToArray(argString: string): string[];
|
|
||||||
573
node_modules/@actions/exec/lib/toolrunner.js
generated
vendored
573
node_modules/@actions/exec/lib/toolrunner.js
generated
vendored
@@ -1,573 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const os = require("os");
|
|
||||||
const events = require("events");
|
|
||||||
const child = require("child_process");
|
|
||||||
/* eslint-disable @typescript-eslint/unbound-method */
|
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
|
||||||
/*
|
|
||||||
* Class for running command line tools. Handles quoting and arg parsing in a platform agnostic way.
|
|
||||||
*/
|
|
||||||
class ToolRunner extends events.EventEmitter {
|
|
||||||
constructor(toolPath, args, options) {
|
|
||||||
super();
|
|
||||||
if (!toolPath) {
|
|
||||||
throw new Error("Parameter 'toolPath' cannot be null or empty.");
|
|
||||||
}
|
|
||||||
this.toolPath = toolPath;
|
|
||||||
this.args = args || [];
|
|
||||||
this.options = options || {};
|
|
||||||
}
|
|
||||||
_debug(message) {
|
|
||||||
if (this.options.listeners && this.options.listeners.debug) {
|
|
||||||
this.options.listeners.debug(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_getCommandString(options, noPrefix) {
|
|
||||||
const toolPath = this._getSpawnFileName();
|
|
||||||
const args = this._getSpawnArgs(options);
|
|
||||||
let cmd = noPrefix ? '' : '[command]'; // omit prefix when piped to a second tool
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
// Windows + cmd file
|
|
||||||
if (this._isCmdFile()) {
|
|
||||||
cmd += toolPath;
|
|
||||||
for (const a of args) {
|
|
||||||
cmd += ` ${a}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Windows + verbatim
|
|
||||||
else if (options.windowsVerbatimArguments) {
|
|
||||||
cmd += `"${toolPath}"`;
|
|
||||||
for (const a of args) {
|
|
||||||
cmd += ` ${a}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Windows (regular)
|
|
||||||
else {
|
|
||||||
cmd += this._windowsQuoteCmdArg(toolPath);
|
|
||||||
for (const a of args) {
|
|
||||||
cmd += ` ${this._windowsQuoteCmdArg(a)}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// OSX/Linux - this can likely be improved with some form of quoting.
|
|
||||||
// creating processes on Unix is fundamentally different than Windows.
|
|
||||||
// on Unix, execvp() takes an arg array.
|
|
||||||
cmd += toolPath;
|
|
||||||
for (const a of args) {
|
|
||||||
cmd += ` ${a}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cmd;
|
|
||||||
}
|
|
||||||
_processLineBuffer(data, strBuffer, onLine) {
|
|
||||||
try {
|
|
||||||
let s = strBuffer + data.toString();
|
|
||||||
let n = s.indexOf(os.EOL);
|
|
||||||
while (n > -1) {
|
|
||||||
const line = s.substring(0, n);
|
|
||||||
onLine(line);
|
|
||||||
// the rest of the string ...
|
|
||||||
s = s.substring(n + os.EOL.length);
|
|
||||||
n = s.indexOf(os.EOL);
|
|
||||||
}
|
|
||||||
strBuffer = s;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// streaming lines to console is best effort. Don't fail a build.
|
|
||||||
this._debug(`error processing line. Failed with error ${err}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_getSpawnFileName() {
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
if (this._isCmdFile()) {
|
|
||||||
return process.env['COMSPEC'] || 'cmd.exe';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.toolPath;
|
|
||||||
}
|
|
||||||
_getSpawnArgs(options) {
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
if (this._isCmdFile()) {
|
|
||||||
let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;
|
|
||||||
for (const a of this.args) {
|
|
||||||
argline += ' ';
|
|
||||||
argline += options.windowsVerbatimArguments
|
|
||||||
? a
|
|
||||||
: this._windowsQuoteCmdArg(a);
|
|
||||||
}
|
|
||||||
argline += '"';
|
|
||||||
return [argline];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.args;
|
|
||||||
}
|
|
||||||
_endsWith(str, end) {
|
|
||||||
return str.endsWith(end);
|
|
||||||
}
|
|
||||||
_isCmdFile() {
|
|
||||||
const upperToolPath = this.toolPath.toUpperCase();
|
|
||||||
return (this._endsWith(upperToolPath, '.CMD') ||
|
|
||||||
this._endsWith(upperToolPath, '.BAT'));
|
|
||||||
}
|
|
||||||
_windowsQuoteCmdArg(arg) {
|
|
||||||
// for .exe, apply the normal quoting rules that libuv applies
|
|
||||||
if (!this._isCmdFile()) {
|
|
||||||
return this._uvQuoteCmdArg(arg);
|
|
||||||
}
|
|
||||||
// otherwise apply quoting rules specific to the cmd.exe command line parser.
|
|
||||||
// the libuv rules are generic and are not designed specifically for cmd.exe
|
|
||||||
// command line parser.
|
|
||||||
//
|
|
||||||
// for a detailed description of the cmd.exe command line parser, refer to
|
|
||||||
// http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/7970912#7970912
|
|
||||||
// need quotes for empty arg
|
|
||||||
if (!arg) {
|
|
||||||
return '""';
|
|
||||||
}
|
|
||||||
// determine whether the arg needs to be quoted
|
|
||||||
const cmdSpecialChars = [
|
|
||||||
' ',
|
|
||||||
'\t',
|
|
||||||
'&',
|
|
||||||
'(',
|
|
||||||
')',
|
|
||||||
'[',
|
|
||||||
']',
|
|
||||||
'{',
|
|
||||||
'}',
|
|
||||||
'^',
|
|
||||||
'=',
|
|
||||||
';',
|
|
||||||
'!',
|
|
||||||
"'",
|
|
||||||
'+',
|
|
||||||
',',
|
|
||||||
'`',
|
|
||||||
'~',
|
|
||||||
'|',
|
|
||||||
'<',
|
|
||||||
'>',
|
|
||||||
'"'
|
|
||||||
];
|
|
||||||
let needsQuotes = false;
|
|
||||||
for (const char of arg) {
|
|
||||||
if (cmdSpecialChars.some(x => x === char)) {
|
|
||||||
needsQuotes = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// short-circuit if quotes not needed
|
|
||||||
if (!needsQuotes) {
|
|
||||||
return arg;
|
|
||||||
}
|
|
||||||
// the following quoting rules are very similar to the rules that by libuv applies.
|
|
||||||
//
|
|
||||||
// 1) wrap the string in quotes
|
|
||||||
//
|
|
||||||
// 2) double-up quotes - i.e. " => ""
|
|
||||||
//
|
|
||||||
// this is different from the libuv quoting rules. libuv replaces " with \", which unfortunately
|
|
||||||
// doesn't work well with a cmd.exe command line.
|
|
||||||
//
|
|
||||||
// note, replacing " with "" also works well if the arg is passed to a downstream .NET console app.
|
|
||||||
// for example, the command line:
|
|
||||||
// foo.exe "myarg:""my val"""
|
|
||||||
// is parsed by a .NET console app into an arg array:
|
|
||||||
// [ "myarg:\"my val\"" ]
|
|
||||||
// which is the same end result when applying libuv quoting rules. although the actual
|
|
||||||
// command line from libuv quoting rules would look like:
|
|
||||||
// foo.exe "myarg:\"my val\""
|
|
||||||
//
|
|
||||||
// 3) double-up slashes that preceed a quote,
|
|
||||||
// e.g. hello \world => "hello \world"
|
|
||||||
// hello\"world => "hello\\""world"
|
|
||||||
// hello\\"world => "hello\\\\""world"
|
|
||||||
// hello world\ => "hello world\\"
|
|
||||||
//
|
|
||||||
// technically this is not required for a cmd.exe command line, or the batch argument parser.
|
|
||||||
// the reasons for including this as a .cmd quoting rule are:
|
|
||||||
//
|
|
||||||
// a) this is optimized for the scenario where the argument is passed from the .cmd file to an
|
|
||||||
// external program. many programs (e.g. .NET console apps) rely on the slash-doubling rule.
|
|
||||||
//
|
|
||||||
// b) it's what we've been doing previously (by deferring to node default behavior) and we
|
|
||||||
// haven't heard any complaints about that aspect.
|
|
||||||
//
|
|
||||||
// note, a weakness of the quoting rules chosen here, is that % is not escaped. in fact, % cannot be
|
|
||||||
// escaped when used on the command line directly - even though within a .cmd file % can be escaped
|
|
||||||
// by using %%.
|
|
||||||
//
|
|
||||||
// the saving grace is, on the command line, %var% is left as-is if var is not defined. this contrasts
|
|
||||||
// the line parsing rules within a .cmd file, where if var is not defined it is replaced with nothing.
|
|
||||||
//
|
|
||||||
// one option that was explored was replacing % with ^% - i.e. %var% => ^%var^%. this hack would
|
|
||||||
// often work, since it is unlikely that var^ would exist, and the ^ character is removed when the
|
|
||||||
// variable is used. the problem, however, is that ^ is not removed when %* is used to pass the args
|
|
||||||
// to an external program.
|
|
||||||
//
|
|
||||||
// an unexplored potential solution for the % escaping problem, is to create a wrapper .cmd file.
|
|
||||||
// % can be escaped within a .cmd file.
|
|
||||||
let reverse = '"';
|
|
||||||
let quoteHit = true;
|
|
||||||
for (let i = arg.length; i > 0; i--) {
|
|
||||||
// walk the string in reverse
|
|
||||||
reverse += arg[i - 1];
|
|
||||||
if (quoteHit && arg[i - 1] === '\\') {
|
|
||||||
reverse += '\\'; // double the slash
|
|
||||||
}
|
|
||||||
else if (arg[i - 1] === '"') {
|
|
||||||
quoteHit = true;
|
|
||||||
reverse += '"'; // double the quote
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
quoteHit = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reverse += '"';
|
|
||||||
return reverse
|
|
||||||
.split('')
|
|
||||||
.reverse()
|
|
||||||
.join('');
|
|
||||||
}
|
|
||||||
_uvQuoteCmdArg(arg) {
|
|
||||||
// Tool runner wraps child_process.spawn() and needs to apply the same quoting as
|
|
||||||
// Node in certain cases where the undocumented spawn option windowsVerbatimArguments
|
|
||||||
// is used.
|
|
||||||
//
|
|
||||||
// Since this function is a port of quote_cmd_arg from Node 4.x (technically, lib UV,
|
|
||||||
// see https://github.com/nodejs/node/blob/v4.x/deps/uv/src/win/process.c for details),
|
|
||||||
// pasting copyright notice from Node within this function:
|
|
||||||
//
|
|
||||||
// Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
if (!arg) {
|
|
||||||
// Need double quotation for empty argument
|
|
||||||
return '""';
|
|
||||||
}
|
|
||||||
if (!arg.includes(' ') && !arg.includes('\t') && !arg.includes('"')) {
|
|
||||||
// No quotation needed
|
|
||||||
return arg;
|
|
||||||
}
|
|
||||||
if (!arg.includes('"') && !arg.includes('\\')) {
|
|
||||||
// No embedded double quotes or backslashes, so I can just wrap
|
|
||||||
// quote marks around the whole thing.
|
|
||||||
return `"${arg}"`;
|
|
||||||
}
|
|
||||||
// Expected input/output:
|
|
||||||
// input : hello"world
|
|
||||||
// output: "hello\"world"
|
|
||||||
// input : hello""world
|
|
||||||
// output: "hello\"\"world"
|
|
||||||
// input : hello\world
|
|
||||||
// output: hello\world
|
|
||||||
// input : hello\\world
|
|
||||||
// output: hello\\world
|
|
||||||
// input : hello\"world
|
|
||||||
// output: "hello\\\"world"
|
|
||||||
// input : hello\\"world
|
|
||||||
// output: "hello\\\\\"world"
|
|
||||||
// input : hello world\
|
|
||||||
// output: "hello world\\" - note the comment in libuv actually reads "hello world\"
|
|
||||||
// but it appears the comment is wrong, it should be "hello world\\"
|
|
||||||
let reverse = '"';
|
|
||||||
let quoteHit = true;
|
|
||||||
for (let i = arg.length; i > 0; i--) {
|
|
||||||
// walk the string in reverse
|
|
||||||
reverse += arg[i - 1];
|
|
||||||
if (quoteHit && arg[i - 1] === '\\') {
|
|
||||||
reverse += '\\';
|
|
||||||
}
|
|
||||||
else if (arg[i - 1] === '"') {
|
|
||||||
quoteHit = true;
|
|
||||||
reverse += '\\';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
quoteHit = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reverse += '"';
|
|
||||||
return reverse
|
|
||||||
.split('')
|
|
||||||
.reverse()
|
|
||||||
.join('');
|
|
||||||
}
|
|
||||||
_cloneExecOptions(options) {
|
|
||||||
options = options || {};
|
|
||||||
const result = {
|
|
||||||
cwd: options.cwd || process.cwd(),
|
|
||||||
env: options.env || process.env,
|
|
||||||
silent: options.silent || false,
|
|
||||||
windowsVerbatimArguments: options.windowsVerbatimArguments || false,
|
|
||||||
failOnStdErr: options.failOnStdErr || false,
|
|
||||||
ignoreReturnCode: options.ignoreReturnCode || false,
|
|
||||||
delay: options.delay || 10000
|
|
||||||
};
|
|
||||||
result.outStream = options.outStream || process.stdout;
|
|
||||||
result.errStream = options.errStream || process.stderr;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
_getSpawnOptions(options, toolPath) {
|
|
||||||
options = options || {};
|
|
||||||
const result = {};
|
|
||||||
result.cwd = options.cwd;
|
|
||||||
result.env = options.env;
|
|
||||||
result['windowsVerbatimArguments'] =
|
|
||||||
options.windowsVerbatimArguments || this._isCmdFile();
|
|
||||||
if (options.windowsVerbatimArguments) {
|
|
||||||
result.argv0 = `"${toolPath}"`;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Exec a tool.
|
|
||||||
* Output will be streamed to the live console.
|
|
||||||
* Returns promise with return code
|
|
||||||
*
|
|
||||||
* @param tool path to tool to exec
|
|
||||||
* @param options optional exec options. See ExecOptions
|
|
||||||
* @returns number
|
|
||||||
*/
|
|
||||||
exec() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this._debug(`exec tool: ${this.toolPath}`);
|
|
||||||
this._debug('arguments:');
|
|
||||||
for (const arg of this.args) {
|
|
||||||
this._debug(` ${arg}`);
|
|
||||||
}
|
|
||||||
const optionsNonNull = this._cloneExecOptions(this.options);
|
|
||||||
if (!optionsNonNull.silent && optionsNonNull.outStream) {
|
|
||||||
optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL);
|
|
||||||
}
|
|
||||||
const state = new ExecState(optionsNonNull, this.toolPath);
|
|
||||||
state.on('debug', (message) => {
|
|
||||||
this._debug(message);
|
|
||||||
});
|
|
||||||
const fileName = this._getSpawnFileName();
|
|
||||||
const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
|
|
||||||
const stdbuffer = '';
|
|
||||||
if (cp.stdout) {
|
|
||||||
cp.stdout.on('data', (data) => {
|
|
||||||
if (this.options.listeners && this.options.listeners.stdout) {
|
|
||||||
this.options.listeners.stdout(data);
|
|
||||||
}
|
|
||||||
if (!optionsNonNull.silent && optionsNonNull.outStream) {
|
|
||||||
optionsNonNull.outStream.write(data);
|
|
||||||
}
|
|
||||||
this._processLineBuffer(data, stdbuffer, (line) => {
|
|
||||||
if (this.options.listeners && this.options.listeners.stdline) {
|
|
||||||
this.options.listeners.stdline(line);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const errbuffer = '';
|
|
||||||
if (cp.stderr) {
|
|
||||||
cp.stderr.on('data', (data) => {
|
|
||||||
state.processStderr = true;
|
|
||||||
if (this.options.listeners && this.options.listeners.stderr) {
|
|
||||||
this.options.listeners.stderr(data);
|
|
||||||
}
|
|
||||||
if (!optionsNonNull.silent &&
|
|
||||||
optionsNonNull.errStream &&
|
|
||||||
optionsNonNull.outStream) {
|
|
||||||
const s = optionsNonNull.failOnStdErr
|
|
||||||
? optionsNonNull.errStream
|
|
||||||
: optionsNonNull.outStream;
|
|
||||||
s.write(data);
|
|
||||||
}
|
|
||||||
this._processLineBuffer(data, errbuffer, (line) => {
|
|
||||||
if (this.options.listeners && this.options.listeners.errline) {
|
|
||||||
this.options.listeners.errline(line);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
cp.on('error', (err) => {
|
|
||||||
state.processError = err.message;
|
|
||||||
state.processExited = true;
|
|
||||||
state.processClosed = true;
|
|
||||||
state.CheckComplete();
|
|
||||||
});
|
|
||||||
cp.on('exit', (code) => {
|
|
||||||
state.processExitCode = code;
|
|
||||||
state.processExited = true;
|
|
||||||
this._debug(`Exit code ${code} received from tool '${this.toolPath}'`);
|
|
||||||
state.CheckComplete();
|
|
||||||
});
|
|
||||||
cp.on('close', (code) => {
|
|
||||||
state.processExitCode = code;
|
|
||||||
state.processExited = true;
|
|
||||||
state.processClosed = true;
|
|
||||||
this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);
|
|
||||||
state.CheckComplete();
|
|
||||||
});
|
|
||||||
state.on('done', (error, exitCode) => {
|
|
||||||
if (stdbuffer.length > 0) {
|
|
||||||
this.emit('stdline', stdbuffer);
|
|
||||||
}
|
|
||||||
if (errbuffer.length > 0) {
|
|
||||||
this.emit('errline', errbuffer);
|
|
||||||
}
|
|
||||||
cp.removeAllListeners();
|
|
||||||
if (error) {
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(exitCode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.ToolRunner = ToolRunner;
|
|
||||||
/**
|
|
||||||
* Convert an arg string to an array of args. Handles escaping
|
|
||||||
*
|
|
||||||
* @param argString string of arguments
|
|
||||||
* @returns string[] array of arguments
|
|
||||||
*/
|
|
||||||
function argStringToArray(argString) {
|
|
||||||
const args = [];
|
|
||||||
let inQuotes = false;
|
|
||||||
let escaped = false;
|
|
||||||
let arg = '';
|
|
||||||
function append(c) {
|
|
||||||
// we only escape double quotes.
|
|
||||||
if (escaped && c !== '"') {
|
|
||||||
arg += '\\';
|
|
||||||
}
|
|
||||||
arg += c;
|
|
||||||
escaped = false;
|
|
||||||
}
|
|
||||||
for (let i = 0; i < argString.length; i++) {
|
|
||||||
const c = argString.charAt(i);
|
|
||||||
if (c === '"') {
|
|
||||||
if (!escaped) {
|
|
||||||
inQuotes = !inQuotes;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
append(c);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c === '\\' && escaped) {
|
|
||||||
append(c);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c === '\\' && inQuotes) {
|
|
||||||
escaped = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c === ' ' && !inQuotes) {
|
|
||||||
if (arg.length > 0) {
|
|
||||||
args.push(arg);
|
|
||||||
arg = '';
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
append(c);
|
|
||||||
}
|
|
||||||
if (arg.length > 0) {
|
|
||||||
args.push(arg.trim());
|
|
||||||
}
|
|
||||||
return args;
|
|
||||||
}
|
|
||||||
exports.argStringToArray = argStringToArray;
|
|
||||||
class ExecState extends events.EventEmitter {
|
|
||||||
constructor(options, toolPath) {
|
|
||||||
super();
|
|
||||||
this.processClosed = false; // tracks whether the process has exited and stdio is closed
|
|
||||||
this.processError = '';
|
|
||||||
this.processExitCode = 0;
|
|
||||||
this.processExited = false; // tracks whether the process has exited
|
|
||||||
this.processStderr = false; // tracks whether stderr was written to
|
|
||||||
this.delay = 10000; // 10 seconds
|
|
||||||
this.done = false;
|
|
||||||
this.timeout = null;
|
|
||||||
if (!toolPath) {
|
|
||||||
throw new Error('toolPath must not be empty');
|
|
||||||
}
|
|
||||||
this.options = options;
|
|
||||||
this.toolPath = toolPath;
|
|
||||||
if (options.delay) {
|
|
||||||
this.delay = options.delay;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CheckComplete() {
|
|
||||||
if (this.done) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.processClosed) {
|
|
||||||
this._setResult();
|
|
||||||
}
|
|
||||||
else if (this.processExited) {
|
|
||||||
this.timeout = setTimeout(ExecState.HandleTimeout, this.delay, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_debug(message) {
|
|
||||||
this.emit('debug', message);
|
|
||||||
}
|
|
||||||
_setResult() {
|
|
||||||
// determine whether there is an error
|
|
||||||
let error;
|
|
||||||
if (this.processExited) {
|
|
||||||
if (this.processError) {
|
|
||||||
error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`);
|
|
||||||
}
|
|
||||||
else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) {
|
|
||||||
error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`);
|
|
||||||
}
|
|
||||||
else if (this.processStderr && this.options.failOnStdErr) {
|
|
||||||
error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// clear the timeout
|
|
||||||
if (this.timeout) {
|
|
||||||
clearTimeout(this.timeout);
|
|
||||||
this.timeout = null;
|
|
||||||
}
|
|
||||||
this.done = true;
|
|
||||||
this.emit('done', error, this.processExitCode);
|
|
||||||
}
|
|
||||||
static HandleTimeout(state) {
|
|
||||||
if (state.done) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!state.processClosed && state.processExited) {
|
|
||||||
const message = `The STDIO streams did not close within ${state.delay /
|
|
||||||
1000} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;
|
|
||||||
state._debug(message);
|
|
||||||
}
|
|
||||||
state._setResult();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=toolrunner.js.map
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user