3
Install and run the 'Microsoft.DotNet.VersionTools.Cli' tool with the 'trim-artifacts-version' command to trim the version from the NuGet assets file name.
6
Full path to directory where artifact packages are stored
9
Search for NuGet packages recursively
15
[bool] $Recursive = $true
18
$CliToolName = "Microsoft.DotNet.VersionTools.Cli"
20
function Install-VersionTools-Cli {
22
[Parameter(Mandatory=$true)][string]$Version
25
Write-Host "Installing the package '$CliToolName' with a version of '$version' ..."
26
$feed = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json"
28
$argumentList = @("tool", "install", "--local", "$CliToolName", "--add-source $feed", "--no-cache", "--version $Version", "--create-manifest-if-needed")
29
Start-Process "$dotnet" -Verbose -ArgumentList $argumentList -NoNewWindow -Wait
32
# -------------------------------------------------------------------
34
if (!(Test-Path $InputPath)) {
35
Write-Host "Input Path '$InputPath' does not exist"
39
$ErrorActionPreference = 'Stop'
40
Set-StrictMode -Version 2.0
42
$disableConfigureToolsetImport = $true
43
$global:LASTEXITCODE = 0
45
# `tools.ps1` checks $ci to perform some actions. Since the SDL
46
# scripts don't necessarily execute in the same agent that run the
47
# build.ps1/sh script this variable isn't automatically set.
49
. $PSScriptRoot\..\tools.ps1
52
$dotnetRoot = InitializeDotNetCli -install:$true
53
$dotnet = "$dotnetRoot\dotnet.exe"
55
$toolsetVersion = Read-ArcadeSdkVersion
56
Install-VersionTools-Cli -Version $toolsetVersion
58
$cliToolFound = (& "$dotnet" tool list --local | Where-Object {$_.Split(' ')[0] -eq $CliToolName})
59
if ($null -eq $cliToolFound) {
60
Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "The '$CliToolName' tool is not installed."
65
& "$dotnet" $CliToolName trim-assets-version `
66
--assets-path $InputPath `
67
--recursive $Recursive
73
Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_