这些要求并不是要求安装某些软件。这只是一个过滤器,用于查找所需软件(如果构建代理属性上存在该软件)。要安装最新版本,您可以尝试使用以下方式:安装,跨平台
yaml 示例:
steps:
- script: |
dotnet tool install -g microsoft.sqlpackage
displayName: 'Command Line Script'
- script: 'sqlpackage -version'
displayName: 'Command Line Script'
结果:
从 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)