2019-01-12 01:39:30 +00:00
|
|
|
param (
|
2019-05-15 12:11:39 +00:00
|
|
|
$darcVersion = $null,
|
2019-11-22 13:41:58 +00:00
|
|
|
$versionEndpoint = 'https://maestro-prod.westus2.cloudapp.azure.com/api/assets/darc-version?api-version=2019-01-16',
|
|
|
|
$verbosity = 'minimal',
|
2019-10-24 22:05:36 +00:00
|
|
|
$toolpath = $null
|
2019-01-12 01:39:30 +00:00
|
|
|
)
|
|
|
|
|
2018-10-22 05:07:26 +00:00
|
|
|
. $PSScriptRoot\tools.ps1
|
|
|
|
|
2020-03-05 13:49:44 +00:00
|
|
|
function InstallDarcCli ($darcVersion, $toolpath) {
|
2019-11-22 13:41:58 +00:00
|
|
|
$darcCliPackageName = 'microsoft.dotnet.darc'
|
2018-12-19 20:55:42 +00:00
|
|
|
|
|
|
|
$dotnetRoot = InitializeDotNetCli -install:$true
|
|
|
|
$dotnet = "$dotnetRoot\dotnet.exe"
|
2019-06-08 12:08:27 +00:00
|
|
|
$toolList = & "$dotnet" tool list -g
|
2018-10-22 05:07:26 +00:00
|
|
|
|
|
|
|
if ($toolList -like "*$darcCliPackageName*") {
|
2019-06-08 12:08:27 +00:00
|
|
|
& "$dotnet" tool uninstall $darcCliPackageName -g
|
2018-10-22 05:07:26 +00:00
|
|
|
}
|
|
|
|
|
2019-05-15 12:11:39 +00:00
|
|
|
# If the user didn't explicitly specify the darc version,
|
|
|
|
# query the Maestro API for the correct version of darc to install.
|
2019-01-12 01:39:30 +00:00
|
|
|
if (-not $darcVersion) {
|
2019-05-15 12:11:39 +00:00
|
|
|
$darcVersion = $(Invoke-WebRequest -Uri $versionEndpoint -UseBasicParsing).Content
|
2019-01-12 01:39:30 +00:00
|
|
|
}
|
2019-06-08 12:08:27 +00:00
|
|
|
|
2020-01-30 13:35:10 +00:00
|
|
|
$arcadeServicesSource = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json'
|
2018-10-22 05:07:26 +00:00
|
|
|
|
2019-01-12 01:39:30 +00:00
|
|
|
Write-Host "Installing Darc CLI version $darcVersion..."
|
2019-11-22 13:41:58 +00:00
|
|
|
Write-Host 'You may need to restart your command window if this is the first dotnet tool you have installed.'
|
2019-10-24 22:05:36 +00:00
|
|
|
if (-not $toolpath) {
|
2020-01-30 13:35:10 +00:00
|
|
|
Write-Host "'$dotnet' tool install $darcCliPackageName --version $darcVersion --add-source '$arcadeServicesSource' -v $verbosity -g"
|
2019-10-24 22:05:36 +00:00
|
|
|
& "$dotnet" tool install $darcCliPackageName --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity -g
|
|
|
|
}else {
|
2020-03-05 13:49:44 +00:00
|
|
|
Write-Host "'$dotnet' tool install $darcCliPackageName --version $darcVersion --add-source '$arcadeServicesSource' -v $verbosity --tool-path '$toolpath'"
|
2019-11-22 13:41:58 +00:00
|
|
|
& "$dotnet" tool install $darcCliPackageName --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity --tool-path "$toolpath"
|
2019-10-24 22:05:36 +00:00
|
|
|
}
|
2018-10-22 05:07:26 +00:00
|
|
|
}
|
|
|
|
|
2019-11-22 13:41:58 +00:00
|
|
|
try {
|
2020-03-05 13:49:44 +00:00
|
|
|
InstallDarcCli $darcVersion $toolpath
|
2019-11-22 13:41:58 +00:00
|
|
|
}
|
|
|
|
catch {
|
|
|
|
Write-Host $_.ScriptStackTrace
|
|
|
|
Write-PipelineTelemetryError -Category 'Darc' -Message $_
|
|
|
|
ExitWithExitCode 1
|
2020-04-24 18:40:44 +00:00
|
|
|
}
|