You've already forked setup-dotnet
							
							
				mirror of
				https://github.com/actions/setup-dotnet.git
				synced 2025-11-04 08:56:35 +07:00 
			
		
		
		
	Compare commits
	
		
			203 Commits
		
	
	
		
			v1.7.0
			...
			add-publis
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 27dbb7f407 | |||
| 9c99f11032 | |||
| 871f041373 | |||
| 67cd79ce76 | |||
| b3da5ab48f | |||
| 65c71668de | |||
| f2d774a272 | |||
| 8f3cbf74e2 | |||
| e31c9045e5 | |||
| 0d16f91084 | |||
| 71a4fd9b27 | |||
| 608ee757cf | |||
| e54e706650 | |||
| c20f59e04a | |||
| 13b852df87 | |||
| f85bcda870 | |||
| 499789684c | |||
| 76ddd67c90 | |||
| 550702114f | |||
| e3ce4164b3 | |||
| 463326422f | |||
| 547d075822 | |||
| fc9265379f | |||
| 32c76e2669 | |||
| 8ca0cf75a1 | |||
| 7f88dbf08f | |||
| af0ed6536b | |||
| 9dd9d27e57 | |||
| 44530e8569 | |||
| 5a3fa01c67 | |||
| f2da928c08 | |||
| fb9fd97b03 | |||
| f0b9e4cf3f | |||
| b66058b059 | |||
| 7323c4e7cb | |||
| 6eab455d72 | |||
| b2cf6c7cd4 | |||
| ff5b78971e | |||
| e26fc623bc | |||
| e974974b42 | |||
| 9969bca445 | |||
| deee0f6246 | |||
| 33fad1d142 | |||
| 2c3efd1f04 | |||
| f3822c3b02 | |||
| 5e45b4b591 | |||
| b7b99f337e | |||
| f92687c910 | |||
| 0067f023d2 | |||
| 9480036ff9 | |||
| 6b8ad2e725 | |||
| 078f7c4a73 | |||
| 13fd5bf191 | |||
| 26be14c4e1 | |||
| 8309d4ee7e | |||
| bab14f40fd | |||
| 4b337272b7 | |||
| d62c876481 | |||
| 5306333434 | |||
| 5070486392 | |||
| 9647326bcf | |||
| f720d14d91 | |||
| 7f3ad75595 | |||
| 634914df32 | |||
| 4fc55d8fdb | |||
| c98cd238db | |||
| b25fa305a3 | |||
| 181f10df92 | |||
| c65a26fe6d | |||
| dd9ada314c | |||
| 12194cb2cd | |||
| b8ab602c41 | |||
| 95f03216f8 | |||
| 5529ce4143 | |||
| 5b0ff19756 | |||
| bf3c3eb1fd | |||
| 450b569534 | |||
| e1cf912aaf | |||
| 03d6eb5402 | |||
| effa3e26d2 | |||
| a71d1eb2c8 | |||
| b50d70502b | |||
| d8cff32ae5 | |||
| 7b2009794e | |||
| 53d6483af8 | |||
| 34c59b7d0b | |||
| bd485b6bd1 | |||
| 0cfae9b3a5 | |||
| 23fa2c1473 | |||
| 291588df6a | |||
| 87189a16c7 | |||
| cde58ab948 | |||
| 20e68089c2 | |||
| 7790315509 | |||
| c47e26f841 | |||
| 3edf2e9363 | |||
| a8c97016ef | |||
| 07b4a80293 | |||
| d08d2193f9 | |||
| 632ccbdfb9 | |||
| b81836a248 | |||
| 3b539379a8 | |||
| 596753d72c | |||
| f9d7f16c00 | |||
| 56d96e897e | |||
| 5a201f5e82 | |||
| 13ccc115f4 | |||
| f2eb44dadd | |||
| 8dcf1ee9bc | |||
| 3707a44789 | |||
| 385512c5e5 | |||
| 083d63a2ff | |||
| 6930747f7f | |||
| 20afff9c90 | |||
| 36fa9877a9 | |||
| 77a48bbb85 | |||
| 4f71fcfa81 | |||
| 768b4eb7db | |||
| ba7e1e2155 | |||
| 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 | |||
| 9fdd50a4bb | |||
| 8336fd394b | |||
| 51f68377c1 | |||
| 7a98346f51 | |||
| 8aad93f856 | 
							
								
								
									
										1
									
								
								.github/CODEOWNERS
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.github/CODEOWNERS
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					* @actions/virtual-environments-owners
 | 
				
			||||||
							
								
								
									
										33
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										33
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
								
							@ -2,22 +2,31 @@
 | 
				
			|||||||
name: Bug report
 | 
					name: Bug report
 | 
				
			||||||
about: Create a bug report
 | 
					about: Create a bug report
 | 
				
			||||||
title: ''
 | 
					title: ''
 | 
				
			||||||
labels: ''
 | 
					labels: bug, needs triage
 | 
				
			||||||
assignees: ''
 | 
					assignees: ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
---
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Description
 | 
					**Description:**
 | 
				
			||||||
 | 
					A clear and concise description of what the bug is.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<!--
 | 
					**Task version:**
 | 
				
			||||||
* Please share short description of the problem
 | 
					Specify the task version
 | 
				
			||||||
  -->
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Details
 | 
					**Platform:**
 | 
				
			||||||
 | 
					- [ ] Ubuntu
 | 
				
			||||||
 | 
					- [ ] macOS
 | 
				
			||||||
 | 
					- [ ] Windows
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<!--
 | 
					**Runner type:**
 | 
				
			||||||
* Include the relevant yaml, platform, and dotnet versions in use
 | 
					- [ ] Hosted
 | 
				
			||||||
* If an error occurred on a public action, please share a link
 | 
					- [ ] Self-hosted
 | 
				
			||||||
* Include any error messages received in text (search does not work for images)
 | 
					
 | 
				
			||||||
* Was this a regression from previous behavior?
 | 
					**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.
 | 
				
			||||||
							
								
								
									
										2
									
								
								.github/ISSUE_TEMPLATE/config.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/ISSUE_TEMPLATE/config.yml
									
									
									
									
										vendored
									
									
								
							@ -1,4 +1,4 @@
 | 
				
			|||||||
blank_issues_enabled: true
 | 
					blank_issues_enabled: false
 | 
				
			||||||
contact_links:
 | 
					contact_links:
 | 
				
			||||||
  - name: .NET issues
 | 
					  - name: .NET issues
 | 
				
			||||||
    url: https://github.com/dotnet/runtime#filing-issues
 | 
					    url: https://github.com/dotnet/runtime#filing-issues
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										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/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.
 | 
				
			||||||
							
								
								
									
										51
									
								
								.github/workflows/check-dist.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								.github/workflows/check-dist.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,51 @@
 | 
				
			|||||||
 | 
					# `dist/index.js` is a special file in Actions.
 | 
				
			||||||
 | 
					# When you reference an action with `uses:` in a workflow,
 | 
				
			||||||
 | 
					# `index.js` is the code that will run.
 | 
				
			||||||
 | 
					# For our project, we generate this file through a build process from other source files.
 | 
				
			||||||
 | 
					# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
 | 
				
			||||||
 | 
					name: Check dist/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					on:
 | 
				
			||||||
 | 
					  push:
 | 
				
			||||||
 | 
					    branches:
 | 
				
			||||||
 | 
					      - main
 | 
				
			||||||
 | 
					    paths-ignore:
 | 
				
			||||||
 | 
					      - '**.md'
 | 
				
			||||||
 | 
					  pull_request:
 | 
				
			||||||
 | 
					    paths-ignore:
 | 
				
			||||||
 | 
					      - '**.md'
 | 
				
			||||||
 | 
					  workflow_dispatch:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					  check-dist:
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					      - uses: actions/checkout@v2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - name: Set Node.js 12.x
 | 
				
			||||||
 | 
					        uses: actions/setup-node@v1
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          node-version: 12.x
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - name: Install dependencies
 | 
				
			||||||
 | 
					        run: npm ci
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - name: Rebuild the dist/ directory
 | 
				
			||||||
 | 
					        run: npm run build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - name: Compare the expected and actual dist/ directories
 | 
				
			||||||
 | 
					        run: |
 | 
				
			||||||
 | 
					          if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
 | 
				
			||||||
 | 
					            echo "Detected uncommitted changes after build.  See status below:"
 | 
				
			||||||
 | 
					            git diff
 | 
				
			||||||
 | 
					            exit 1
 | 
				
			||||||
 | 
					          fi
 | 
				
			||||||
 | 
					        id: diff
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      # If index.js was different than expected, upload the expected version as an artifact
 | 
				
			||||||
 | 
					      - uses: actions/upload-artifact@v4
 | 
				
			||||||
 | 
					        if: ${{ failure() && steps.diff.conclusion == 'failure' }}
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          name: dist
 | 
				
			||||||
 | 
					          path: dist/
 | 
				
			||||||
							
								
								
									
										11
									
								
								.github/workflows/licensed.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								.github/workflows/licensed.yml
									
									
									
									
										vendored
									
									
								
							@ -1,8 +1,13 @@
 | 
				
			|||||||
name: Licensed
 | 
					name: Licensed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
on:
 | 
					on:
 | 
				
			||||||
  push: {branches: main}
 | 
					  push:
 | 
				
			||||||
  pull_request: {branches: main}
 | 
					    branches:
 | 
				
			||||||
 | 
					      - main
 | 
				
			||||||
 | 
					  pull_request:
 | 
				
			||||||
 | 
					    branches:
 | 
				
			||||||
 | 
					      - main
 | 
				
			||||||
 | 
					  workflow_dispatch:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
jobs:
 | 
					jobs:
 | 
				
			||||||
  test:
 | 
					  test:
 | 
				
			||||||
@ -14,7 +19,7 @@ jobs:
 | 
				
			|||||||
      - name: Install licensed
 | 
					      - name: Install licensed
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
          cd $RUNNER_TEMP
 | 
					          cd $RUNNER_TEMP
 | 
				
			||||||
          curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz
 | 
					          curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.3.1/licensed-3.3.1-linux-x64.tar.gz
 | 
				
			||||||
          sudo tar -xzf licensed.tar.gz
 | 
					          sudo tar -xzf licensed.tar.gz
 | 
				
			||||||
          sudo mv licensed /usr/local/bin/licensed
 | 
					          sudo mv licensed /usr/local/bin/licensed
 | 
				
			||||||
      - run: licensed status
 | 
					      - run: licensed status
 | 
				
			||||||
							
								
								
									
										20
									
								
								.github/workflows/publish-immutable-action.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								.github/workflows/publish-immutable-action.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					name: 'Publish Immutable Action Version'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					on:
 | 
				
			||||||
 | 
					  release:
 | 
				
			||||||
 | 
					    types: [published]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					  publish:
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    permissions:
 | 
				
			||||||
 | 
					      contents: read
 | 
				
			||||||
 | 
					      id-token: write
 | 
				
			||||||
 | 
					      packages: write
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					      - name: Checking out
 | 
				
			||||||
 | 
					        uses: actions/checkout@v4
 | 
				
			||||||
 | 
					      - name: Publish
 | 
				
			||||||
 | 
					        id: publish
 | 
				
			||||||
 | 
					        uses: actions/publish-immutable-action@v0.0.4
 | 
				
			||||||
							
								
								
									
										28
									
								
								.github/workflows/release-new-action-version.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								.github/workflows/release-new-action-version.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					name: Release new action version
 | 
				
			||||||
 | 
					on:
 | 
				
			||||||
 | 
					  release:
 | 
				
			||||||
 | 
					    types: [released]
 | 
				
			||||||
 | 
					  workflow_dispatch:
 | 
				
			||||||
 | 
					    inputs:
 | 
				
			||||||
 | 
					      TAG_NAME:
 | 
				
			||||||
 | 
					        description: 'Tag name that the major tag will point to'
 | 
				
			||||||
 | 
					        required: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					env:
 | 
				
			||||||
 | 
					  TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
 | 
				
			||||||
 | 
					permissions:
 | 
				
			||||||
 | 
					  contents: write
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					  update_tag:
 | 
				
			||||||
 | 
					    name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes
 | 
				
			||||||
 | 
					    environment:
 | 
				
			||||||
 | 
					      name: releaseNewActionVersion
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					    - name: Update the ${{ env.TAG_NAME }} tag
 | 
				
			||||||
 | 
					      id: update-major-tag
 | 
				
			||||||
 | 
					      uses: actions/publish-action@v0.1.0
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        source-tag: ${{ env.TAG_NAME }}
 | 
				
			||||||
 | 
					        slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
 | 
				
			||||||
							
								
								
									
										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-22.04, 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" }
 | 
				
			||||||
							
								
								
									
										153
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										153
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							@ -2,10 +2,14 @@ name: Main workflow
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
on:
 | 
					on:
 | 
				
			||||||
  pull_request:
 | 
					  pull_request:
 | 
				
			||||||
 | 
					    paths-ignore:
 | 
				
			||||||
 | 
					      - '**.md'
 | 
				
			||||||
  push:
 | 
					  push:
 | 
				
			||||||
    branches:
 | 
					    branches:
 | 
				
			||||||
      - main
 | 
					      - main
 | 
				
			||||||
      - releases/*
 | 
					      - releases/*
 | 
				
			||||||
 | 
					    paths-ignore:
 | 
				
			||||||
 | 
					      - '**.md'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
jobs:
 | 
					jobs:
 | 
				
			||||||
  build:
 | 
					  build:
 | 
				
			||||||
@ -13,7 +17,7 @@ jobs:
 | 
				
			|||||||
    strategy:
 | 
					    strategy:
 | 
				
			||||||
      fail-fast: false
 | 
					      fail-fast: false
 | 
				
			||||||
      matrix:
 | 
					      matrix:
 | 
				
			||||||
        operating-system: [ubuntu-latest, windows-latest, macOS-latest]
 | 
					        operating-system: [ubuntu-22.04, windows-latest, macos-13]
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
    - name: Checkout
 | 
					    - name: Checkout
 | 
				
			||||||
      uses: actions/checkout@v2
 | 
					      uses: actions/checkout@v2
 | 
				
			||||||
@ -29,34 +33,41 @@ jobs:
 | 
				
			|||||||
      if: runner.os != 'windows'
 | 
					      if: runner.os != 'windows'
 | 
				
			||||||
      run: __tests__/verify-no-unstaged-changes.sh
 | 
					      run: __tests__/verify-no-unstaged-changes.sh
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  test:
 | 
					  test-setup-multiple-versions:
 | 
				
			||||||
    runs-on: ${{ matrix.operating-system }}
 | 
					    runs-on: ${{ matrix.operating-system }}
 | 
				
			||||||
    strategy:
 | 
					    strategy:
 | 
				
			||||||
      fail-fast: false
 | 
					      fail-fast: false
 | 
				
			||||||
      matrix:
 | 
					      matrix:
 | 
				
			||||||
        operating-system: [ubuntu-latest, windows-latest, macOS-latest]
 | 
					        operating-system: [ubuntu-22.04, windows-latest, macOS-latest]
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
      - name: Checkout
 | 
					      - name: Checkout
 | 
				
			||||||
        uses: actions/checkout@v2
 | 
					        uses: actions/checkout@v2
 | 
				
			||||||
      - name: Clear tool cache (macOS)
 | 
					      - name: Clear toolcache
 | 
				
			||||||
        if: runner.os == 'macos'
 | 
					        shell: pwsh
 | 
				
			||||||
        run: |
 | 
					        run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
 | 
				
			||||||
          echo $PATH
 | 
					      - name: Setup dotnet 2.2.402 and 3.1.404
 | 
				
			||||||
          dotnet --info
 | 
					        uses: ./
 | 
				
			||||||
          rm -rf "/Users/runner/.dotnet"
 | 
					        with:
 | 
				
			||||||
      - name: Clear tool cache (Ubuntu)
 | 
					          dotnet-version: |
 | 
				
			||||||
        if: runner.os == 'linux'
 | 
					             2.2.402
 | 
				
			||||||
        run: |
 | 
					             3.1.404
 | 
				
			||||||
          echo $PATH
 | 
					             3.0.x
 | 
				
			||||||
          dotnet --info
 | 
					      - name: Verify dotnet
 | 
				
			||||||
          rm -rf "/usr/share/dotnet"
 | 
					        shell: pwsh
 | 
				
			||||||
      - name: Clear tool cache (Windows)
 | 
					        run: __tests__/verify-dotnet.ps1 2.2.402 3.1.404 '3.0'
 | 
				
			||||||
        if: runner.os == 'windows'
 | 
					
 | 
				
			||||||
        run: |
 | 
					  test-setup-full-version:
 | 
				
			||||||
          echo $env:PATH
 | 
					    runs-on: ${{ matrix.operating-system }}
 | 
				
			||||||
          dotnet --info
 | 
					    strategy:
 | 
				
			||||||
          Remove-Item $env:LocalAppData\Microsoft\dotnet/*  -Recurse -Force -ErrorAction SilentlyContinue
 | 
					      fail-fast: false
 | 
				
			||||||
          Remove-Item "$env:ProgramFiles\dotnet/*"  -Recurse -Force -ErrorAction SilentlyContinue
 | 
					      matrix:
 | 
				
			||||||
 | 
					        operating-system: [ubuntu-22.04, windows-latest, macos-13]
 | 
				
			||||||
 | 
					    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
 | 
					      # Side-by-side install of 2.2 and 3.1 used for the test project
 | 
				
			||||||
      - name: Setup dotnet 2.2.402
 | 
					      - name: Setup dotnet 2.2.402
 | 
				
			||||||
        uses: ./
 | 
					        uses: ./
 | 
				
			||||||
@ -70,26 +81,102 @@ jobs:
 | 
				
			|||||||
          source-url: https://api.nuget.org/v3/index.json
 | 
					          source-url: https://api.nuget.org/v3/index.json
 | 
				
			||||||
        env:
 | 
					        env:
 | 
				
			||||||
          NUGET_AUTH_TOKEN: NOTATOKEN
 | 
					          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
 | 
					      - name: Verify dotnet
 | 
				
			||||||
        if: runner.os != 'windows'
 | 
					        shell: pwsh
 | 
				
			||||||
        run: __tests__/verify-dotnet.sh 3.1.201 2.2.402
 | 
					        run: __tests__/verify-dotnet.ps1 3.1.201 2.2.402
 | 
				
			||||||
      - name: Verify dotnet (Windows)
 | 
					
 | 
				
			||||||
        if: runner.os == 'windows'
 | 
					  test-setup-without-patch-version:
 | 
				
			||||||
        run: __tests__/verify-dotnet.ps1 3.1.201
 | 
					    runs-on: ${{ matrix.operating-system }}
 | 
				
			||||||
 | 
					    strategy:
 | 
				
			||||||
 | 
					      fail-fast: false
 | 
				
			||||||
 | 
					      matrix:
 | 
				
			||||||
 | 
					        operating-system: [ubuntu-22.04, 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-22.04, 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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  test-setup-with-wildcard:
 | 
				
			||||||
 | 
					    runs-on: ${{ matrix.operating-system }}
 | 
				
			||||||
 | 
					    strategy:
 | 
				
			||||||
 | 
					      fail-fast: false
 | 
				
			||||||
 | 
					      matrix:
 | 
				
			||||||
 | 
					        operating-system: [ubuntu-22.04, 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:
 | 
					  test-proxy:
 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ubuntu-22.04
 | 
				
			||||||
    container:
 | 
					    container:
 | 
				
			||||||
      image: mcr.microsoft.com/dotnet/core/runtime-deps:3.0-bionic
 | 
					      image: ubuntu:22.04
 | 
				
			||||||
      options: --dns 127.0.0.1
 | 
					      options: --dns 127.0.0.1
 | 
				
			||||||
    services:
 | 
					    services:
 | 
				
			||||||
      squid-proxy:
 | 
					      squid-proxy:
 | 
				
			||||||
        image: datadog/squid:latest
 | 
					        image: ubuntu/squid:latest
 | 
				
			||||||
        ports:
 | 
					        ports:
 | 
				
			||||||
          - 3128:3128
 | 
					          - 3128:3128
 | 
				
			||||||
    env:
 | 
					    env:
 | 
				
			||||||
      https_proxy: http://squid-proxy:3128
 | 
					      https_proxy: http://squid-proxy:3128
 | 
				
			||||||
      http_proxy: http://squid-proxy:3128
 | 
					      http_proxy: http://squid-proxy:3128
 | 
				
			||||||
 | 
					      DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
      - name: Checkout
 | 
					      - name: Checkout
 | 
				
			||||||
        uses: actions/checkout@v2
 | 
					        uses: actions/checkout@v2
 | 
				
			||||||
@ -98,7 +185,7 @@ jobs:
 | 
				
			|||||||
      - name: Install curl
 | 
					      - name: Install curl
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
          apt update
 | 
					          apt update
 | 
				
			||||||
          apt -y install curl
 | 
					          apt -y install curl libssl-dev
 | 
				
			||||||
      - name: Setup dotnet 3.1.201
 | 
					      - name: Setup dotnet 3.1.201
 | 
				
			||||||
        uses: ./
 | 
					        uses: ./
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
@ -110,10 +197,10 @@ jobs:
 | 
				
			|||||||
        run: __tests__/verify-dotnet.sh 3.1.201
 | 
					        run: __tests__/verify-dotnet.sh 3.1.201
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  test-bypass-proxy:
 | 
					  test-bypass-proxy:
 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ubuntu-22.04
 | 
				
			||||||
    env:
 | 
					    env:
 | 
				
			||||||
      https_proxy: http://no-such-proxy:3128
 | 
					      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
 | 
					      no_proxy: github.com,download.visualstudio.microsoft.com,api.nuget.org,builds.dotnet.microsoft.com,ci.dot.net
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
      - name: Checkout
 | 
					      - name: Checkout
 | 
				
			||||||
        uses: actions/checkout@v2
 | 
					        uses: actions/checkout@v2
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								.licenses/npm/@actions/core.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/core.dep.yml
									
									
									
										generated
									
									
									
								
							@ -1,6 +1,6 @@
 | 
				
			|||||||
---
 | 
					---
 | 
				
			||||||
name: "@actions/core"
 | 
					name: "@actions/core"
 | 
				
			||||||
version: 1.2.5
 | 
					version: 1.6.0
 | 
				
			||||||
type: npm
 | 
					type: npm
 | 
				
			||||||
summary: Actions core lib
 | 
					summary: Actions core lib
 | 
				
			||||||
homepage: https://github.com/actions/toolkit/tree/main/packages/core
 | 
					homepage: https://github.com/actions/toolkit/tree/main/packages/core
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										32
									
								
								.licenses/npm/@actions/http-client-1.0.11.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								.licenses/npm/@actions/http-client-1.0.11.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					---
 | 
				
			||||||
 | 
					name: "@actions/http-client"
 | 
				
			||||||
 | 
					version: 1.0.11
 | 
				
			||||||
 | 
					type: npm
 | 
				
			||||||
 | 
					summary: Actions Http Client
 | 
				
			||||||
 | 
					homepage: https://github.com/actions/http-client#readme
 | 
				
			||||||
 | 
					license: mit
 | 
				
			||||||
 | 
					licenses:
 | 
				
			||||||
 | 
					- sources: LICENSE
 | 
				
			||||||
 | 
					  text: |
 | 
				
			||||||
 | 
					    Actions Http Client for Node.js
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Copyright (c) GitHub, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    All rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    MIT License
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 | 
				
			||||||
 | 
					    associated documentation files (the "Software"), to deal in the Software without restriction,
 | 
				
			||||||
 | 
					    including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
 | 
				
			||||||
 | 
					    and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
 | 
				
			||||||
 | 
					    subject to the following conditions:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 | 
				
			||||||
 | 
					    LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
 | 
				
			||||||
 | 
					    NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 | 
				
			||||||
 | 
					    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 | 
				
			||||||
 | 
					    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
				
			||||||
 | 
					notices: []
 | 
				
			||||||
							
								
								
									
										52
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										52
									
								
								README.md
									
									
									
									
									
								
							@ -4,16 +4,16 @@
 | 
				
			|||||||
  <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 core cli](https://github.com/dotnet/cli) environment for use in actions by:
 | 
					This action sets up a [.NET CLI](https://github.com/dotnet/sdk) environment for use in actions by:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- optionally downloading and caching a version of dotnet by SDK version and adding to PATH
 | 
					- optionally downloading and caching a version(s) of dotnet by SDK version(s) and adding to PATH
 | 
				
			||||||
- registering problem matchers for error output
 | 
					- registering problem matchers for error output
 | 
				
			||||||
- setting up authentication to private package sources like GitHub Packages
 | 
					- setting up authentication to private package sources like GitHub Packages
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Please Note: GitHub hosted runners have some versions of the .NET SDK
 | 
					Please Note: GitHub hosted runners have some versions of the .NET SDK
 | 
				
			||||||
preinstalled. Installed versions are subject to change. Please refer to the
 | 
					preinstalled. Installed versions are subject to change. Please refer to the
 | 
				
			||||||
documentation
 | 
					documentation
 | 
				
			||||||
[software installed on github hosted runners](https://help.github.com/en/actions/reference/software-installed-on-github-hosted-runners)
 | 
					[software installed on github hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software)
 | 
				
			||||||
for .NET SDK versions that are currently available.
 | 
					for .NET SDK versions that are currently available.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Usage
 | 
					# Usage
 | 
				
			||||||
@ -23,12 +23,36 @@ See [action.yml](action.yml)
 | 
				
			|||||||
Basic:
 | 
					Basic:
 | 
				
			||||||
```yaml
 | 
					```yaml
 | 
				
			||||||
steps:
 | 
					steps:
 | 
				
			||||||
- uses: actions/checkout@main
 | 
					- uses: actions/checkout@v2
 | 
				
			||||||
- uses: actions/setup-dotnet@v1
 | 
					- uses: actions/setup-dotnet@v1
 | 
				
			||||||
  with:
 | 
					  with:
 | 
				
			||||||
    dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel
 | 
					    dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel
 | 
				
			||||||
- run: dotnet build <my project>
 | 
					- run: dotnet build <my project>
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					Multiple versions:
 | 
				
			||||||
 | 
					> Note: In case multiple versions are installed, the latest .NET version will be used by default unless another version is specified in the `global.json` file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```yml
 | 
				
			||||||
 | 
					steps:
 | 
				
			||||||
 | 
					- uses: actions/checkout@v2
 | 
				
			||||||
 | 
					- name: Setup dotnet
 | 
				
			||||||
 | 
					  uses: actions/setup-dotnet@v1
 | 
				
			||||||
 | 
					  with:
 | 
				
			||||||
 | 
					    dotnet-version: | 
 | 
				
			||||||
 | 
					      3.1.x
 | 
				
			||||||
 | 
					      5.0.x
 | 
				
			||||||
 | 
					- run: dotnet build <my project>
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					Preview version:
 | 
				
			||||||
 | 
					```yml
 | 
				
			||||||
 | 
					steps:
 | 
				
			||||||
 | 
					- uses: actions/checkout@v2
 | 
				
			||||||
 | 
					- uses: actions/setup-dotnet@v1
 | 
				
			||||||
 | 
					  with:
 | 
				
			||||||
 | 
					    dotnet-version: '6.0.x'
 | 
				
			||||||
 | 
					    include-prerelease: true
 | 
				
			||||||
 | 
					- run: dotnet build <my project>
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Matrix Testing:
 | 
					Matrix Testing:
 | 
				
			||||||
```yaml
 | 
					```yaml
 | 
				
			||||||
@ -37,7 +61,7 @@ jobs:
 | 
				
			|||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
    strategy:
 | 
					    strategy:
 | 
				
			||||||
      matrix:
 | 
					      matrix:
 | 
				
			||||||
        dotnet: [ '2.2.103', '3.0', '3.1.x' ]
 | 
					        dotnet: [ '2.1.x', '3.1.x', '5.0.x' ]
 | 
				
			||||||
    name: Dotnet ${{ matrix.dotnet }} sample
 | 
					    name: Dotnet ${{ matrix.dotnet }} sample
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
      - uses: actions/checkout@v2
 | 
					      - uses: actions/checkout@v2
 | 
				
			||||||
@ -59,7 +83,7 @@ jobs:
 | 
				
			|||||||
      - name: Setup dotnet
 | 
					      - name: Setup dotnet
 | 
				
			||||||
        uses: actions/setup-dotnet@v1
 | 
					        uses: actions/setup-dotnet@v1
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          dotnet-version: '2.2.103'
 | 
					          dotnet-version: '2.1.x'
 | 
				
			||||||
      - name: Setup dotnet
 | 
					      - name: Setup dotnet
 | 
				
			||||||
        uses: actions/setup-dotnet@v1
 | 
					        uses: actions/setup-dotnet@v1
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
@ -85,7 +109,7 @@ steps:
 | 
				
			|||||||
- name: Publish the package to GPR
 | 
					- name: Publish the package to GPR
 | 
				
			||||||
  run: dotnet nuget push <my project>/bin/Release/*.nupkg
 | 
					  run: dotnet nuget push <my project>/bin/Release/*.nupkg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Authticates packages to push to Azure Artifacts
 | 
					# Authenticates packages to push to Azure Artifacts
 | 
				
			||||||
- uses: actions/setup-dotnet@v1
 | 
					- uses: actions/setup-dotnet@v1
 | 
				
			||||||
  with:
 | 
					  with:
 | 
				
			||||||
    source-url: https://pkgs.dev.azure.com/<your-organization>/_packaging/<your-feed-name>/nuget/v3/index.json
 | 
					    source-url: https://pkgs.dev.azure.com/<your-organization>/_packaging/<your-feed-name>/nuget/v3/index.json
 | 
				
			||||||
@ -93,11 +117,21 @@ steps:
 | 
				
			|||||||
    NUGET_AUTH_TOKEN: ${{secrets.AZURE_DEVOPS_PAT}} # Note, create a secret with this name in Settings
 | 
					    NUGET_AUTH_TOKEN: ${{secrets.AZURE_DEVOPS_PAT}} # Note, create a secret with this name in Settings
 | 
				
			||||||
- name: Publish the package to Azure Artifacts
 | 
					- name: Publish the package to Azure Artifacts
 | 
				
			||||||
  run: dotnet nuget push <my project>/bin/Release/*.nupkg
 | 
					  run: dotnet nuget push <my project>/bin/Release/*.nupkg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Authenticates packages to push to nuget.org.
 | 
				
			||||||
 | 
					# It's only the way to push a package to nuget.org feed for macOS/Linux machines due to API key config store limitations.
 | 
				
			||||||
 | 
					- uses: actions/setup-dotnet@v1
 | 
				
			||||||
 | 
					  with:
 | 
				
			||||||
 | 
					    dotnet-version: 3.1.x
 | 
				
			||||||
 | 
					- name: Publish the package to nuget.org
 | 
				
			||||||
 | 
					  run: dotnet nuget push */bin/Release/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
 | 
				
			||||||
 | 
					  env:
 | 
				
			||||||
 | 
					    NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Environment Variables to use with dotnet
 | 
					## Environment Variables to use with dotnet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Some environment variables may be necessary for your particular case or to improve logging. Some examples are listed below, but the full list with complete details can be found here: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet#environment-variables
 | 
					Some environment variables may be necessary for your particular case or to improve logging. Some examples are listed below, but the full list with complete details can be found here: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- DOTNET_NOLOGO - removes logo and telemetry message from first run of dotnet cli (default: false)
 | 
					- DOTNET_NOLOGO - removes logo and telemetry message from first run of dotnet cli (default: false)
 | 
				
			||||||
- DOTNET_CLI_TELEMETRY_OPTOUT - opt-out of telemetry being sent to Microsoft (default: false)
 | 
					- DOTNET_CLI_TELEMETRY_OPTOUT - opt-out of telemetry being sent to Microsoft (default: false)
 | 
				
			||||||
@ -113,7 +147,7 @@ build:
 | 
				
			|||||||
    - uses: actions/checkout@main
 | 
					    - uses: actions/checkout@main
 | 
				
			||||||
    - uses: actions/setup-dotnet@v1
 | 
					    - uses: actions/setup-dotnet@v1
 | 
				
			||||||
      with:
 | 
					      with:
 | 
				
			||||||
        dotnet-version: '3.1.100' # SDK Version to use.
 | 
					        dotnet-version: '3.1.x' # SDK Version to use.
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# License
 | 
					# License
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										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 ($srcPath in $dotnetPaths[$args[0]]) {
 | 
				
			||||||
 | 
					    if (Test-Path $srcPath) {
 | 
				
			||||||
 | 
					        Write-Host "Move $srcPath path"
 | 
				
			||||||
 | 
					        $dstPath = Join-Path ([IO.Path]::GetTempPath()) ([IO.Path]::GetRandomFileName())
 | 
				
			||||||
 | 
					        Move-Item -Path $srcPath -Destination $dstPath
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -4,79 +4,21 @@ import os = require('os');
 | 
				
			|||||||
import path = require('path');
 | 
					import path = require('path');
 | 
				
			||||||
import hc = require('@actions/http-client');
 | 
					import hc = require('@actions/http-client');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import each from 'jest-each';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
process.env['RUNNER_TOOL_CACHE'] = toolDir;
 | 
					process.env['RUNNER_TOOL_CACHE'] = toolDir;
 | 
				
			||||||
process.env['RUNNER_TEMP'] = tempDir;
 | 
					process.env['RUNNER_TEMP'] = tempDir;
 | 
				
			||||||
import * as setup from '../src/setup-dotnet';
 | 
					 | 
				
			||||||
import * as installer from '../src/installer';
 | 
					import * as installer from '../src/installer';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const IS_WINDOWS = process.platform === 'win32';
 | 
					const IS_WINDOWS = process.platform === 'win32';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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();
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
describe('installer tests', () => {
 | 
					describe('installer tests', () => {
 | 
				
			||||||
  beforeAll(async () => {
 | 
					  beforeAll(async () => {
 | 
				
			||||||
    process.env.RUNNER_TOOL_CACHE = toolDir;
 | 
					    process.env.RUNNER_TOOL_CACHE = toolDir;
 | 
				
			||||||
    process.env.DOTNET_INSTALL_DIR = toolDir;
 | 
					    process.env.DOTNET_INSTALL_DIR = toolDir;
 | 
				
			||||||
    process.env.RUNNER_TEMP = tempDir;
 | 
					    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);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
@ -90,46 +32,26 @@ describe('installer tests', () => {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }, 30000);
 | 
					  }, 30000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('Resolving a normal generic version works', async () => {
 | 
					  it('Aquires multiple versions of dotnet', async () => {
 | 
				
			||||||
    const dotnetInstaller = new installer.DotnetCoreInstaller('3.1.x');
 | 
					    const versions = ['2.2.207', '3.1.120'];
 | 
				
			||||||
    let versInfo = await dotnetInstaller.resolveVersion(
 | 
					 | 
				
			||||||
      new installer.DotNetVersionInfo('3.1.x')
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expect(versInfo.startsWith('3.1.'));
 | 
					    for (const version of versions) {
 | 
				
			||||||
  }, 100000);
 | 
					      await getDotnet(version);
 | 
				
			||||||
 | 
					 | 
				
			||||||
  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);
 | 
					    expect(fs.existsSync(path.join(toolDir, 'sdk', '2.2.207'))).toBe(true);
 | 
				
			||||||
 | 
					    expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.120'))).toBe(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('Resolving a exact stable version works', async () => {
 | 
					    if (IS_WINDOWS) {
 | 
				
			||||||
    const dotnetInstaller = new installer.DotnetCoreInstaller('3.1.201');
 | 
					      expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
 | 
				
			||||||
    let versInfo = await dotnetInstaller.resolveVersion(
 | 
					    } else {
 | 
				
			||||||
      new installer.DotNetVersionInfo('3.1.201')
 | 
					      expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
 | 
				
			||||||
    );
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expect(versInfo).toBe('3.1.201');
 | 
					    expect(process.env.DOTNET_ROOT).toBeDefined;
 | 
				
			||||||
  }, 100000);
 | 
					    expect(process.env.PATH).toBeDefined;
 | 
				
			||||||
 | 
					    expect(process.env.DOTNET_ROOT).toBe(toolDir);
 | 
				
			||||||
  it('Resolving a exact preview version works', async () => {
 | 
					    expect(process.env.PATH?.startsWith(toolDir)).toBe(true);
 | 
				
			||||||
    const dotnetInstaller = new installer.DotnetCoreInstaller(
 | 
					  }, 600000);
 | 
				
			||||||
      '5.0.0-preview.6'
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
    let versInfo = await dotnetInstaller.resolveVersion(
 | 
					 | 
				
			||||||
      new installer.DotNetVersionInfo('5.0.0-preview.6')
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    expect(versInfo).toBe('5.0.0-preview.6');
 | 
					 | 
				
			||||||
  }, 100000);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('Acquires version of dotnet if no matching version is installed', async () => {
 | 
					  it('Acquires version of dotnet if no matching version is installed', async () => {
 | 
				
			||||||
    await getDotnet('3.1.201');
 | 
					    await getDotnet('3.1.201');
 | 
				
			||||||
@ -139,24 +61,30 @@ describe('installer tests', () => {
 | 
				
			|||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
 | 
					      expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }, 400000); //This needs some time to download on "slower" internet connections
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('Acquires version of dotnet from global.json if no matching version is installed', async () => {
 | 
					    expect(process.env.DOTNET_ROOT).toBeDefined;
 | 
				
			||||||
    const globalJsonPath = path.join(process.cwd(), 'global.json');
 | 
					    expect(process.env.PATH).toBeDefined;
 | 
				
			||||||
    const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version": "3.1.201"${os.EOL}}${os.EOL}}`;
 | 
					    expect(process.env.DOTNET_ROOT).toBe(toolDir);
 | 
				
			||||||
    if (!fs.existsSync(globalJsonPath)) {
 | 
					    expect(process.env.PATH?.startsWith(toolDir)).toBe(true);
 | 
				
			||||||
      fs.writeFileSync(globalJsonPath, jsonContents);
 | 
					  }, 600000); //This needs some time to download on "slower" internet connections
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    await setup.run();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).toBe(true);
 | 
					  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) {
 | 
					    if (IS_WINDOWS) {
 | 
				
			||||||
      expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
 | 
					      expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
 | 
					      expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fs.unlinkSync(globalJsonPath);
 | 
					
 | 
				
			||||||
  }, 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('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;
 | 
				
			||||||
@ -219,4 +147,5 @@ function normalizeFileContents(contents: string): string {
 | 
				
			|||||||
async function getDotnet(version: string): Promise<void> {
 | 
					async function getDotnet(version: string): Promise<void> {
 | 
				
			||||||
  const dotnetInstaller = new installer.DotnetCoreInstaller(version);
 | 
					  const dotnetInstaller = new installer.DotnetCoreInstaller(version);
 | 
				
			||||||
  await dotnetInstaller.installDotnet();
 | 
					  await dotnetInstaller.installDotnet();
 | 
				
			||||||
 | 
					  installer.DotnetCoreInstaller.addToPath();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
<Project Sdk="Microsoft.NET.Sdk">
 | 
					<Project Sdk="Microsoft.NET.Sdk">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <PropertyGroup>
 | 
					  <PropertyGroup>
 | 
				
			||||||
    <TargetFrameworks>netcoreapp3.1;netcoreapp2.2</TargetFrameworks>
 | 
					    <TargetFrameworks>netcoreapp3.1;netcoreapp3.0;netcoreapp2.2</TargetFrameworks>
 | 
				
			||||||
    <RootNamespace>sample_csproj</RootNamespace>
 | 
					    <RootNamespace>sample_csproj</RootNamespace>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <IsPackable>false</IsPackable>
 | 
					    <IsPackable>false</IsPackable>
 | 
				
			||||||
 | 
				
			|||||||
@ -7,6 +7,7 @@ const toolDir = path.join(__dirname, 'runner', 'tools2');
 | 
				
			|||||||
const tempDir = path.join(__dirname, 'runner', 'temp2');
 | 
					const tempDir = path.join(__dirname, 'runner', 'temp2');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import * as setup from '../src/setup-dotnet';
 | 
					import * as setup from '../src/setup-dotnet';
 | 
				
			||||||
 | 
					import * as dotnetInstaller from '../src/installer';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const IS_WINDOWS = process.platform === 'win32';
 | 
					const IS_WINDOWS = process.platform === 'win32';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -19,7 +20,7 @@ describe('setup-dotnet tests', () => {
 | 
				
			|||||||
    await io.rmRF(tempDir);
 | 
					    await io.rmRF(tempDir);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  afterAll(async () => {
 | 
					  afterEach(async () => {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      await io.rmRF(path.join(process.cwd(), 'global.json'));
 | 
					      await io.rmRF(path.join(process.cwd(), 'global.json'));
 | 
				
			||||||
      await io.rmRF(toolDir);
 | 
					      await io.rmRF(toolDir);
 | 
				
			||||||
@ -29,7 +30,7 @@ describe('setup-dotnet tests', () => {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }, 30000);
 | 
					  }, 30000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('Acquires version of dotnet if no matching version is installed', async () => {
 | 
					  it('Acquires version of dotnet from global.json if no matching version is installed', async () => {
 | 
				
			||||||
    const globalJsonPath = path.join(process.cwd(), 'global.json');
 | 
					    const globalJsonPath = path.join(process.cwd(), 'global.json');
 | 
				
			||||||
    const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version": "3.1.201"${os.EOL}}${os.EOL}}`;
 | 
					    const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version": "3.1.201"${os.EOL}}${os.EOL}}`;
 | 
				
			||||||
    if (!fs.existsSync(globalJsonPath)) {
 | 
					    if (!fs.existsSync(globalJsonPath)) {
 | 
				
			||||||
@ -43,6 +44,27 @@ describe('setup-dotnet tests', () => {
 | 
				
			|||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
 | 
					      expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fs.unlinkSync(globalJsonPath);
 | 
					  }, 400000);
 | 
				
			||||||
  }, 100000);
 | 
					
 | 
				
			||||||
 | 
					  it('Acquires version of dotnet from global.json with rollForward option, install the latest patch', async () => {
 | 
				
			||||||
 | 
					    const globalJsonPath = path.join(process.cwd(), 'global.json');
 | 
				
			||||||
 | 
					    const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version":"3.1.201",${os.EOL}"rollForward":"latestFeature"${os.EOL}}${os.EOL}}`;
 | 
				
			||||||
 | 
					    if (!fs.existsSync(globalJsonPath)) {
 | 
				
			||||||
 | 
					      fs.writeFileSync(globalJsonPath, jsonContents);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const version = '3.1';
 | 
				
			||||||
 | 
					    const installer = new dotnetInstaller.DotnetCoreInstaller(version);
 | 
				
			||||||
 | 
					    const patchVersion = await installer.resolveVersion(
 | 
				
			||||||
 | 
					      new dotnetInstaller.DotNetVersionInfo(version)
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    await setup.run();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    expect(fs.existsSync(path.join(toolDir, 'sdk', patchVersion))).toBe(true);
 | 
				
			||||||
 | 
					    if (IS_WINDOWS) {
 | 
				
			||||||
 | 
					      expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }, 400000);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
				
			|||||||
@ -3,30 +3,38 @@ if (!$args[0])
 | 
				
			|||||||
  throw "Must supply dotnet version argument"
 | 
					  throw "Must supply dotnet version argument"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (-Not (Test-Path "../nuget.config"))
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  throw "nuget file not generated correctly"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
$dotnet = Get-Command dotnet | Select-Object -First 1 | ForEach-Object { $_.Path }
 | 
					$dotnet = Get-Command dotnet | Select-Object -First 1 | ForEach-Object { $_.Path }
 | 
				
			||||||
Write-Host "Found '$dotnet'"
 | 
					Write-Host "Found '$dotnet'"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if($args.count -eq 1)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
  $version = & $dotnet --version | Out-String | ForEach-Object { $_.Trim() }
 | 
					  $version = & $dotnet --version | Out-String | ForEach-Object { $_.Trim() }
 | 
				
			||||||
  Write-Host "Version $version"
 | 
					  Write-Host "Version $version"
 | 
				
			||||||
if ($version -ne $args[0])
 | 
					  if (-not ($version.StartsWith($args[0].ToString())))
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
  Write-Host "PATH='$env:path'"
 | 
					    Write-Host "PATH='$env:PATH'"
 | 
				
			||||||
    throw "Unexpected version"
 | 
					    throw "Unexpected version"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if ($args[1])
 | 
					if ($args[1])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  # SDKs are listed on multiple lines with the path afterwards in square brackets
 | 
					  # SDKs are listed on multiple lines with the path afterwards in square brackets
 | 
				
			||||||
  $version = & $dotnet --list-sdks | ForEach-Object { $_.SubString(0, $_.IndexOf('[')).Trim() }
 | 
					  $versions = & $dotnet --list-sdks | ForEach-Object { $_.SubString(0, $_.IndexOf('[')).Trim() }
 | 
				
			||||||
  Write-Host "Version $version"
 | 
					  Write-Host "Installed versions: $versions"
 | 
				
			||||||
  if (-not ($version -contains $args[1]))
 | 
					  $InstalledVersionCount = 0
 | 
				
			||||||
 | 
					  foreach($arg in $args){
 | 
				
			||||||
 | 
					    foreach ($version in $versions)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    Write-Host "PATH='$env:path'"
 | 
					      if ($version.StartsWith($arg.ToString())) 
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        $InstalledVersionCount++
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					  if ( $InstalledVersionCount -ne $args.Count)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    Write-Host "PATH='$env:PATH'"
 | 
				
			||||||
    throw "Unexpected version"
 | 
					    throw "Unexpected version"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -49,6 +57,13 @@ if ($args[1])
 | 
				
			|||||||
    throw "Unexpected output"
 | 
					    throw "Unexpected output"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					if ($args[2])
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if ($sample_output -notlike "*Test Run Successful.*Test Run Successful.*Test Run Successful.*")
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    throw "Unexpected output"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if ($sample_output -notlike "*Test Run Successful.*")
 | 
					  if ($sample_output -notlike "*Test Run Successful.*")
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										91
									
								
								__tests__/versionutil.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								__tests__/versionutil.test.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,91 @@
 | 
				
			|||||||
 | 
					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.x', '3.x'],
 | 
				
			||||||
 | 
					    ['3.*', '3.*'],
 | 
				
			||||||
 | 
					    ['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',
 | 
				
			||||||
 | 
					    '*.*.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);
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
@ -1,18 +1,21 @@
 | 
				
			|||||||
name: 'Setup .NET Core SDK'
 | 
					name: 'Setup .NET Core SDK'
 | 
				
			||||||
description: 'Set up a specific version of the .NET Core CLI in the PATH and set up authentication to a private NuGet repository'
 | 
					description: 'Used to build and publish .NET source. Set up a specific version of the .NET and authentication to private NuGet repository'
 | 
				
			||||||
author: 'GitHub'
 | 
					author: 'GitHub'
 | 
				
			||||||
branding:
 | 
					branding:
 | 
				
			||||||
  icon: play
 | 
					  icon: play
 | 
				
			||||||
  color: green
 | 
					  color: green
 | 
				
			||||||
inputs:
 | 
					inputs:
 | 
				
			||||||
  dotnet-version:
 | 
					  dotnet-version:
 | 
				
			||||||
    description: 'SDK version to use. Examples: 2.2.104, 3.1, 3.1.x'
 | 
					    description: 'Optional SDK version(s) to use. If not provided, will install global.json version when available. Examples: 2.2.104, 3.1, 3.1.x'
 | 
				
			||||||
  source-url:
 | 
					  source-url:
 | 
				
			||||||
    description: 'Optional package source for which to set up authentication. Will consult any existing NuGet.config in the root of the repo and provide a temporary NuGet.config using the NUGET_AUTH_TOKEN environment variable as a ClearTextPassword'
 | 
					    description: 'Optional package source for which to set up authentication. Will consult any existing NuGet.config in the root of the repo and provide a temporary NuGet.config using the NUGET_AUTH_TOKEN environment variable as a ClearTextPassword'
 | 
				
			||||||
  owner:
 | 
					  owner:
 | 
				
			||||||
    description: 'Optional OWNER for using packages from GitHub Package Registry organizations/users other than the current repository''s owner. Only used if a GPR URL is also provided in source-url'
 | 
					    description: 'Optional OWNER for using packages from GitHub Package Registry organizations/users other than the current repository''s owner. Only used if a GPR URL is also provided in source-url'
 | 
				
			||||||
  config-file:
 | 
					  config-file:
 | 
				
			||||||
    description: 'Optional NuGet.config location, if your NuGet.config isn''t located in the root of the repo.'
 | 
					    description: 'Optional NuGet.config location, if your NuGet.config isn''t located in the root of the repo.'
 | 
				
			||||||
 | 
					  include-prerelease:
 | 
				
			||||||
 | 
					    description: 'Whether prerelease versions should be matched with non-exact versions (for example 5.0.0-preview.6 being matched by 5, 5.0, 5.x or 5.0.x). Defaults to false if not provided.'
 | 
				
			||||||
 | 
					    required: False
 | 
				
			||||||
runs:
 | 
					runs:
 | 
				
			||||||
  using: 'node12'
 | 
					  using: 'node12'
 | 
				
			||||||
  main: 'dist/index.js'
 | 
					  main: 'dist/index.js'
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1512
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1512
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -22,3 +22,13 @@ If you would like to contribute there are a few things to consider:
 | 
				
			|||||||
## Writing tests
 | 
					## 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.
 | 
					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
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1396
									
								
								externals/install-dotnet.ps1
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1396
									
								
								externals/install-dotnet.ps1
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1347
									
								
								externals/install-dotnet.sh
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1347
									
								
								externals/install-dotnet.sh
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										3983
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										3983
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										12
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								package.json
									
									
									
									
									
								
							@ -30,7 +30,7 @@
 | 
				
			|||||||
  "author": "GitHub",
 | 
					  "author": "GitHub",
 | 
				
			||||||
  "license": "MIT",
 | 
					  "license": "MIT",
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
    "@actions/core": "^1.2.5",
 | 
					    "@actions/core": "^1.6.0",
 | 
				
			||||||
    "@actions/exec": "^1.0.4",
 | 
					    "@actions/exec": "^1.0.4",
 | 
				
			||||||
    "@actions/github": "^1.1.0",
 | 
					    "@actions/github": "^1.1.0",
 | 
				
			||||||
    "@actions/http-client": "^1.0.8",
 | 
					    "@actions/http-client": "^1.0.8",
 | 
				
			||||||
@ -40,15 +40,15 @@
 | 
				
			|||||||
    "xmlbuilder": "^13.0.2"
 | 
					    "xmlbuilder": "^13.0.2"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "devDependencies": {
 | 
					  "devDependencies": {
 | 
				
			||||||
    "@types/jest": "^25.2.3",
 | 
					    "@types/jest": "^27.0.2",
 | 
				
			||||||
    "@types/node": "^12.12.62",
 | 
					    "@types/node": "^12.12.62",
 | 
				
			||||||
    "@types/semver": "^6.2.2",
 | 
					    "@types/semver": "^6.2.2",
 | 
				
			||||||
    "@zeit/ncc": "^0.21.1",
 | 
					    "@zeit/ncc": "^0.21.1",
 | 
				
			||||||
    "husky": "^4.3.0",
 | 
					    "husky": "^7.0.2",
 | 
				
			||||||
    "jest": "^26.4.2",
 | 
					    "jest": "^27.2.5",
 | 
				
			||||||
    "jest-circus": "^26.4.2",
 | 
					    "jest-circus": "^27.2.5",
 | 
				
			||||||
    "prettier": "^1.19.1",
 | 
					    "prettier": "^1.19.1",
 | 
				
			||||||
    "ts-jest": "^26.4.0",
 | 
					    "ts-jest": "^27.0.5",
 | 
				
			||||||
    "typescript": "^3.9.7",
 | 
					    "typescript": "^3.9.7",
 | 
				
			||||||
    "wget-improved": "^3.2.1"
 | 
					    "wget-improved": "^3.2.1"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,9 @@ export function configAuthentication(
 | 
				
			|||||||
) {
 | 
					) {
 | 
				
			||||||
  const existingNuGetConfig: string = path.resolve(
 | 
					  const existingNuGetConfig: string = path.resolve(
 | 
				
			||||||
    processRoot,
 | 
					    processRoot,
 | 
				
			||||||
    existingFileLocation == '' ? 'nuget.config' : existingFileLocation
 | 
					    existingFileLocation === ''
 | 
				
			||||||
 | 
					      ? getExistingNugetConfig(processRoot)
 | 
				
			||||||
 | 
					      : existingFileLocation
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const tempNuGetConfig: string = path.resolve(
 | 
					  const tempNuGetConfig: string = path.resolve(
 | 
				
			||||||
@ -25,6 +27,21 @@ export function configAuthentication(
 | 
				
			|||||||
  writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
 | 
					  writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function isValidKey(key: string): boolean {
 | 
				
			||||||
 | 
					  return /^[\w\-\.]+$/i.test(key);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function getExistingNugetConfig(processRoot: string) {
 | 
				
			||||||
 | 
					  const defaultConfigName = 'nuget.config';
 | 
				
			||||||
 | 
					  const configFileNames = fs
 | 
				
			||||||
 | 
					    .readdirSync(processRoot)
 | 
				
			||||||
 | 
					    .filter(filename => filename.toLowerCase() === defaultConfigName);
 | 
				
			||||||
 | 
					  if (configFileNames.length) {
 | 
				
			||||||
 | 
					    return configFileNames[0];
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return defaultConfigName;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function writeFeedToFile(
 | 
					function writeFeedToFile(
 | 
				
			||||||
  feedUrl: string,
 | 
					  feedUrl: string,
 | 
				
			||||||
  existingFileLocation: string,
 | 
					  existingFileLocation: string,
 | 
				
			||||||
@ -109,9 +126,9 @@ function writeFeedToFile(
 | 
				
			|||||||
  xml = xml.ele('packageSourceCredentials');
 | 
					  xml = xml.ele('packageSourceCredentials');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  sourceKeys.forEach(key => {
 | 
					  sourceKeys.forEach(key => {
 | 
				
			||||||
    if (key.indexOf(' ') > -1) {
 | 
					    if (!isValidKey(key)) {
 | 
				
			||||||
      throw new Error(
 | 
					      throw new Error(
 | 
				
			||||||
        "This action currently can't handle source names with spaces. Remove the space from your repo's NuGet.config and try again."
 | 
					        "Source name can contain letters, numbers, and '-', '_', '.' symbols only. Please, fix source name in NuGet.config and try again."
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -29,8 +29,7 @@ export class DotNetVersionInfo {
 | 
				
			|||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //Note: No support for previews when using generic
 | 
					    const parts: string[] = version.split('.');
 | 
				
			||||||
    let parts: string[] = version.split('.');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat();
 | 
					    if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -38,8 +37,10 @@ export class DotNetVersionInfo {
 | 
				
			|||||||
      this.throwInvalidVersionFormat();
 | 
					      this.throwInvalidVersionFormat();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let major = this.getVersionNumberOrThrow(parts[0]);
 | 
					    const major = this.getVersionNumberOrThrow(parts[0]);
 | 
				
			||||||
    let minor = this.getVersionNumberOrThrow(parts[1]);
 | 
					    const minor = ['x', '*'].includes(parts[1])
 | 
				
			||||||
 | 
					      ? parts[1]
 | 
				
			||||||
 | 
					      : this.getVersionNumberOrThrow(parts[1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.fullversion = major + '.' + minor;
 | 
					    this.fullversion = major + '.' + minor;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -60,7 +61,9 @@ export class DotNetVersionInfo {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private throwInvalidVersionFormat() {
 | 
					  private throwInvalidVersionFormat() {
 | 
				
			||||||
    throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*';
 | 
					    throw new Error(
 | 
				
			||||||
 | 
					      'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
@ -76,8 +79,9 @@ export class DotNetVersionInfo {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class DotnetCoreInstaller {
 | 
					export class DotnetCoreInstaller {
 | 
				
			||||||
  constructor(version: string) {
 | 
					  constructor(version: string, includePrerelease: boolean = false) {
 | 
				
			||||||
    this.version = version;
 | 
					    this.version = version;
 | 
				
			||||||
 | 
					    this.includePrerelease = includePrerelease;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public async installDotnet() {
 | 
					  public async installDotnet() {
 | 
				
			||||||
@ -146,8 +150,8 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
      const scriptPath = await io.which(escapedScript, true);
 | 
					      const scriptPath = await io.which(escapedScript, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let scriptArguments: string[] = [];
 | 
					      let scriptArguments: string[] = [];
 | 
				
			||||||
      if (this.version) {
 | 
					      if (calculatedVersion) {
 | 
				
			||||||
        scriptArguments.push('--version', this.version);
 | 
					        scriptArguments.push('--version', calculatedVersion);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
 | 
					      // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
 | 
				
			||||||
@ -161,8 +165,15 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
      });
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (resultCode != 0) {
 | 
				
			||||||
 | 
					      throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static addToPath() {
 | 
				
			||||||
    if (process.env['DOTNET_INSTALL_DIR']) {
 | 
					    if (process.env['DOTNET_INSTALL_DIR']) {
 | 
				
			||||||
      core.addPath(process.env['DOTNET_INSTALL_DIR']);
 | 
					      core.addPath(process.env['DOTNET_INSTALL_DIR']);
 | 
				
			||||||
 | 
					      core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      if (IS_WINDOWS) {
 | 
					      if (IS_WINDOWS) {
 | 
				
			||||||
        // This is the default set in install-dotnet.ps1
 | 
					        // This is the default set in install-dotnet.ps1
 | 
				
			||||||
@ -176,14 +187,14 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        // This is the default set in install-dotnet.sh
 | 
					        // This is the default set in install-dotnet.sh
 | 
				
			||||||
        core.addPath(path.join(process.env['HOME'] + '', '.dotnet'));
 | 
					        core.addPath(path.join(process.env['HOME'] + '', '.dotnet'));
 | 
				
			||||||
 | 
					        core.exportVariable(
 | 
				
			||||||
 | 
					          'DOTNET_ROOT',
 | 
				
			||||||
 | 
					          path.join(process.env['HOME'] + '', '.dotnet')
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    console.log(process.env['PATH']);
 | 
					    console.log(process.env['PATH']);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (resultCode != 0) {
 | 
					 | 
				
			||||||
      throw `Failed to install dotnet ${resultCode}. ${output}`;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // versionInfo - versionInfo of the SDK/Runtime
 | 
					  // versionInfo - versionInfo of the SDK/Runtime
 | 
				
			||||||
@ -207,13 +218,15 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
    let releasesInfo: any[] = releasesResult['releases'];
 | 
					    let releasesInfo: any[] = releasesResult['releases'];
 | 
				
			||||||
    releasesInfo = releasesInfo.filter((releaseInfo: any) => {
 | 
					    releasesInfo = releasesInfo.filter((releaseInfo: any) => {
 | 
				
			||||||
      return (
 | 
					      return (
 | 
				
			||||||
        semver.satisfies(
 | 
					        semver.satisfies(releaseInfo['sdk']['version'], versionInfo.version(), {
 | 
				
			||||||
          releaseInfo['sdk']['version'],
 | 
					          includePrerelease: this.includePrerelease
 | 
				
			||||||
          versionInfo.version()
 | 
					        }) ||
 | 
				
			||||||
        ) ||
 | 
					 | 
				
			||||||
        semver.satisfies(
 | 
					        semver.satisfies(
 | 
				
			||||||
          releaseInfo['sdk']['version-display'],
 | 
					          releaseInfo['sdk']['version-display'],
 | 
				
			||||||
          versionInfo.version()
 | 
					          versionInfo.version(),
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            includePrerelease: this.includePrerelease
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@ -222,16 +235,22 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
    let latestSdk: string = releasesResult['latest-sdk'];
 | 
					    let latestSdk: string = releasesResult['latest-sdk'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    releasesInfo = releasesInfo.filter((releaseInfo: any) =>
 | 
					    releasesInfo = releasesInfo.filter((releaseInfo: any) =>
 | 
				
			||||||
      semver.lte(releaseInfo['sdk']['version'], latestSdk)
 | 
					      semver.lte(releaseInfo['sdk']['version'], latestSdk, {
 | 
				
			||||||
 | 
					        includePrerelease: this.includePrerelease
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Sort for latest version
 | 
					    // Sort for latest version
 | 
				
			||||||
    releasesInfo = releasesInfo.sort((a, b) =>
 | 
					    releasesInfo = releasesInfo.sort((a, b) =>
 | 
				
			||||||
      semver.rcompare(a['sdk']['version'], b['sdk']['version'])
 | 
					      semver.rcompare(a['sdk']['version'], b['sdk']['version'], {
 | 
				
			||||||
 | 
					        includePrerelease: this.includePrerelease
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (releasesInfo.length == 0) {
 | 
					    if (releasesInfo.length == 0) {
 | 
				
			||||||
      throw `Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`;
 | 
					      throw new Error(
 | 
				
			||||||
 | 
					        `Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let release = releasesInfo[0];
 | 
					    let release = releasesInfo[0];
 | 
				
			||||||
@ -245,24 +264,40 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
    const response = await httpClient.getJson<any>(DotNetCoreIndexUrl);
 | 
					    const response = await httpClient.getJson<any>(DotNetCoreIndexUrl);
 | 
				
			||||||
    const result = response.result || {};
 | 
					    const result = response.result || {};
 | 
				
			||||||
    let releasesInfo: any[] = result['releases-index'];
 | 
					    let releasesInfo: any[] = result['releases-index'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    releasesInfo = releasesInfo.filter((info: any) => {
 | 
					    releasesInfo = releasesInfo.filter((info: any) => {
 | 
				
			||||||
      // channel-version is the first 2 elements of the version (e.g. 2.1), filter out versions that don't match 2.1.x.
 | 
					      // channel-version is the first 2 elements of the version (e.g. 2.1), filter out versions that don't match 2.1.x.
 | 
				
			||||||
      const sdkParts: string[] = info['channel-version'].split('.');
 | 
					      const sdkParts: string[] = info['channel-version'].split('.');
 | 
				
			||||||
      if (versionParts.length >= 2 && versionParts[1] != 'x') {
 | 
					      if (
 | 
				
			||||||
 | 
					        versionParts.length >= 2 &&
 | 
				
			||||||
 | 
					        !(versionParts[1] == 'x' || versionParts[1] == '*')
 | 
				
			||||||
 | 
					      ) {
 | 
				
			||||||
        return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1];
 | 
					        return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1];
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      return versionParts[0] == sdkParts[0];
 | 
					      return versionParts[0] == sdkParts[0];
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (releasesInfo.length === 0) {
 | 
					    if (releasesInfo.length === 0) {
 | 
				
			||||||
      throw `Could not find info for version ${versionParts.join(
 | 
					      throw new Error(
 | 
				
			||||||
 | 
					        `Could not find info for version ${versionParts.join(
 | 
				
			||||||
          '.'
 | 
					          '.'
 | 
				
			||||||
      )} at ${DotNetCoreIndexUrl}`;
 | 
					        )} at ${DotNetCoreIndexUrl}`
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return releasesInfo[0]['releases.json'];
 | 
					
 | 
				
			||||||
 | 
					    const releaseInfo = releasesInfo[0];
 | 
				
			||||||
 | 
					    if (releaseInfo['support-phase'] === 'eol') {
 | 
				
			||||||
 | 
					      core.warning(
 | 
				
			||||||
 | 
					        `${releaseInfo['product']} ${releaseInfo['channel-version']} is no longer supported and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the .NET support policy.`
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return releaseInfo['releases.json'];
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private version: string;
 | 
					  private version: string;
 | 
				
			||||||
 | 
					  private includePrerelease: boolean;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const DotNetCoreIndexUrl: string =
 | 
					const DotNetCoreIndexUrl: string =
 | 
				
			||||||
  'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json';
 | 
					  'https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json';
 | 
				
			||||||
 | 
				
			|||||||
@ -13,25 +13,30 @@ export async function run() {
 | 
				
			|||||||
    // If a valid version still can't be identified, nothing will be installed.
 | 
					    // If a valid version still can't be identified, nothing will be installed.
 | 
				
			||||||
    // Proxy, auth, (etc) are still set up, even if no version is identified
 | 
					    // Proxy, auth, (etc) are still set up, even if no version is identified
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    let version = core.getInput('dotnet-version');
 | 
					    let versions = core.getMultilineInput('dotnet-version');
 | 
				
			||||||
    if (!version) {
 | 
					    if (!versions.length) {
 | 
				
			||||||
      // Try to fall back to global.json
 | 
					      // Try to fall back to global.json
 | 
				
			||||||
      core.debug('No version found, trying to find version from global.json');
 | 
					      core.debug('No version found, trying to find version from global.json');
 | 
				
			||||||
      const globalJsonPath = path.join(process.cwd(), 'global.json');
 | 
					      const globalJsonPath = path.join(process.cwd(), 'global.json');
 | 
				
			||||||
      if (fs.existsSync(globalJsonPath)) {
 | 
					      if (fs.existsSync(globalJsonPath)) {
 | 
				
			||||||
        const globalJson = JSON.parse(
 | 
					        versions.push(getVersionFromGlobalJson(globalJsonPath));
 | 
				
			||||||
          fs.readFileSync(globalJsonPath, {encoding: 'utf8'})
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
        if (globalJson.sdk && globalJson.sdk.version) {
 | 
					 | 
				
			||||||
          version = globalJson.sdk.version;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (version) {
 | 
					    if (versions.length) {
 | 
				
			||||||
      const dotnetInstaller = new installer.DotnetCoreInstaller(version);
 | 
					      const includePrerelease: boolean =
 | 
				
			||||||
 | 
					        (core.getInput('include-prerelease') || 'false').toLowerCase() ===
 | 
				
			||||||
 | 
					        'true';
 | 
				
			||||||
 | 
					      let dotnetInstaller!: installer.DotnetCoreInstaller;
 | 
				
			||||||
 | 
					      for (const version of new Set<string>(versions)) {
 | 
				
			||||||
 | 
					        dotnetInstaller = new installer.DotnetCoreInstaller(
 | 
				
			||||||
 | 
					          version,
 | 
				
			||||||
 | 
					          includePrerelease
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
        await dotnetInstaller.installDotnet();
 | 
					        await dotnetInstaller.installDotnet();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					      installer.DotnetCoreInstaller.addToPath();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const sourceUrl: string = core.getInput('source-url');
 | 
					    const sourceUrl: string = core.getInput('source-url');
 | 
				
			||||||
    const configFile: string = core.getInput('config-file');
 | 
					    const configFile: string = core.getInput('config-file');
 | 
				
			||||||
@ -46,4 +51,21 @@ export async function run() {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function getVersionFromGlobalJson(globalJsonPath: string): string {
 | 
				
			||||||
 | 
					  let version: string = '';
 | 
				
			||||||
 | 
					  const globalJson = JSON.parse(
 | 
				
			||||||
 | 
					    // .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649
 | 
				
			||||||
 | 
					    fs.readFileSync(globalJsonPath, {encoding: 'utf8'}).trim()
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					  if (globalJson.sdk && globalJson.sdk.version) {
 | 
				
			||||||
 | 
					    version = globalJson.sdk.version;
 | 
				
			||||||
 | 
					    const rollForward = globalJson.sdk.rollForward;
 | 
				
			||||||
 | 
					    if (rollForward && rollForward === 'latestFeature') {
 | 
				
			||||||
 | 
					      const [major, minor] = version.split('.');
 | 
				
			||||||
 | 
					      version = `${major}.${minor}`;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return version;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
run();
 | 
					run();
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user