msbuild

Форк
0
/
trim-assets-version.ps1 
75 строк · 2.2 Кб
1
<#
2
.SYNOPSIS
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.
4

5
.PARAMETER InputPath
6
Full path to directory where artifact packages are stored
7

8
.PARAMETER Recursive
9
Search for NuGet packages recursively
10

11
#>
12

13
Param(
14
  [string] $InputPath,
15
  [bool] $Recursive = $true
16
)
17

18
$CliToolName = "Microsoft.DotNet.VersionTools.Cli"
19

20
function Install-VersionTools-Cli {
21
  param(
22
      [Parameter(Mandatory=$true)][string]$Version
23
  )
24

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"
27

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
30
}
31

32
# -------------------------------------------------------------------
33

34
if (!(Test-Path $InputPath)) {
35
  Write-Host "Input Path '$InputPath' does not exist"
36
  ExitWithExitCode 1
37
}
38

39
$ErrorActionPreference = 'Stop'
40
Set-StrictMode -Version 2.0
41

42
$disableConfigureToolsetImport = $true
43
$global:LASTEXITCODE = 0
44

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.
48
$ci = $true
49
. $PSScriptRoot\..\tools.ps1
50

51
try {
52
  $dotnetRoot = InitializeDotNetCli -install:$true
53
  $dotnet = "$dotnetRoot\dotnet.exe"
54

55
  $toolsetVersion = Read-ArcadeSdkVersion
56
  Install-VersionTools-Cli -Version $toolsetVersion
57

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."
61
    ExitWithExitCode 1
62
  }
63

64
  Exec-BlockVerbosely {
65
    & "$dotnet" $CliToolName trim-assets-version `
66
      --assets-path $InputPath `
67
      --recursive $Recursive
68
    Exit-IfNZEC "Sdl"
69
  }
70
}
71
catch {
72
  Write-Host $_
73
  Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_
74
  ExitWithExitCode 1
75
}

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.