Skip to content

Commit

Permalink
Use NuGetAuthenticate in AzP instead of hand installation
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed Jun 28, 2021
1 parent 4dbf55a commit d3b2f39
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion azure-pipelines/install-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ parameters:

steps:

- task: NuGetAuthenticate@0
displayName: Authenticate NuGet feeds
inputs:
forceReinstallCredentialProvider: true

- powershell: |
$AccessToken = '$(System.AccessToken)' # Avoid specifying the access token directly on the init.ps1 command line to avoid it showing up in errors
.\init.ps1 -AccessToken $AccessToken ${{ parameters['initArgs'] }} -UpgradePrerequisites
.\init.ps1 -AccessToken $AccessToken ${{ parameters['initArgs'] }} -UpgradePrerequisites -NoNuGetCredProvider
dotnet --info
# Print mono version if it is present.
Expand Down
10 changes: 9 additions & 1 deletion init.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it.
.PARAMETER NoPrerequisites
Skips the installation of prerequisite software (e.g. SDKs, tools).
.PARAMETER NoNuGetCredProvider
Skips the installation of the NuGet credential provider. Useful in pipelines with the `NuGetAuthenticate` task, as a workaround for https://github.com/microsoft/artifacts-credprovider/issues/244.
This switch is ignored and installation is skipped when -NoPrerequisites is specified.
.PARAMETER UpgradePrerequisites
Takes time to install prerequisites even if they are already present in case they need to be upgraded.
No effect if -NoPrerequisites is specified.
Expand All @@ -35,6 +38,8 @@ Param (
[Parameter()]
[switch]$NoPrerequisites,
[Parameter()]
[switch]$NoNuGetCredProvider,
[Parameter()]
[switch]$UpgradePrerequisites,
[Parameter()]
[switch]$NoRestore,
Expand All @@ -45,7 +50,10 @@ Param (
$EnvVars = @{}

if (!$NoPrerequisites) {
& "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken -Force:$UpgradePrerequisites
if (!$NoNuGetCredProvider) {
& "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken -Force:$UpgradePrerequisites
}

& "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality
if ($LASTEXITCODE -eq 3010) {
Exit 3010
Expand Down

0 comments on commit d3b2f39

Please sign in to comment.