如何在 Azure Pipeline 中使用 dotnet list --deprecated 来中断构建

2024-05-13

我想检查我的解决方案是否使用了已弃用的 NuGet-Packages。

所以我添加了

- task: dotNetCoreCLI@2
  name: checkDeprecatedNuGet
  inputs:
    command: 'custom'
    projects: '**/*.sln'
    custom: 'list'
    arguments: 'package --deprecated'

现在它列出了已弃用的软件包,但构建成功。

在这种情况下是否有可能破坏构建?


这是我现在使用的解决方案:

$projectDirectory = "$(Agent.BuildDirectory)/s/$(RepoName)"
$solutions = Get-ChildItem -Path $projectDirectory/** -Name -Include *.sln
foreach ($solution in $solutions)
{
  $output = dotnet list $projectDirectory/$solution package --deprecated
  $errors = $output | Select-String '>'
  
  if ($errors.Count -gt 0)
  {
    foreach ($err in $errors)
    {
      Write-Host "##vso[task.logissue type=error]Reference to deprecated NuGet-package $err"
    }
    exit 1
  }
  else
  {
    Write-Host "No deprecated NuGet-package"
    exit 0
  }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 Azure Pipeline 中使用 dotnet list --deprecated 来中断构建 的相关文章

随机推荐