Azure Devops 管道 - Sqlpackage 的特定版本

问题描述 投票:0回答:2

在我的azure devops发布管道中,我需要指定使用最新版本的sqlpackage。

对于我的情况,指定“最新”或提供特定版本的 sqlpackage 的两个选项都可以。

如何做到这一点?

enter image description here

azure-devops azure-pipelines azure-pipelines-release-pipeline
2个回答
1
投票

这些要求并不是要求安装某些软件。这只是一个过滤器,用于查找所需软件(如果构建代理属性上存在该软件)。要安装最新版本,您可以尝试使用以下方式:安装,跨平台

yaml 示例:

steps:
- script: |
   dotnet tool install -g microsoft.sqlpackage
  displayName: 'Command Line Script'

- script: 'sqlpackage -version'
  displayName: 'Command Line Script'

结果:

enter image description here


0
投票

从 dotnet 工具安装对我来说不起作用,因为环境正在从 .Net 框架路径执行 sqlpackage:

C:\Program Files\Microsoft SQL Server\160\DAC\bin
。我可以覆盖 powershell 任务中的路径,但一旦进入 SqlDacpacDeploymentOnMachineGroup 任务就无法覆盖。

要安装 DacFramework 并使其可用于所有任务,我借用了这个不相关的答案:https://stackoverflow.com/a/78981969/1721635

  - task: PowerShell@2
    displayName: 'Install SqlPackage.exe'
    inputs:
      targetType: 'inline'
      script: |
        $installerUrl = 'https://aka.ms/dacfx-msi';
        $installerPath = Join-Path -Path $env:Agent_TempDirectory -ChildPath 'DacFramework.msi';
        [Net.ServicePointManager]::SecurityProtocol = "Tls12, Tls11";
        Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath;
        Start-Process -FilePath 'msiexec.exe' -ArgumentList "/i `"$installerPath`" /quiet /qn /norestart" -Wait;
        if (Get-Command 'SqlPackage.exe' -ErrorAction SilentlyContinue) {
          Write-Host "DacFx installed successfully.";
        } else {
          Write-Error "DacFx installation failed.";
          exit 1;
        }

这将获得最新的 DacFx。 (如果您有较旧的 Powershell,则需要 SecurityProtocol 行,并强制 Web 请求使用 TLSv1.2 或 v1.1)

© www.soinside.com 2019 - 2024. All rights reserved.