Skip to content

Instantly share code, notes, and snippets.

@drmohundro
Created May 26, 2020 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drmohundro/8727c9bb70f749a7e31e41740f29f58f to your computer and use it in GitHub Desktop.
Save drmohundro/8727c9bb70f749a7e31e41740f29f58f to your computer and use it in GitHub Desktop.
Get sqlcmd.exe in Azure Pipelines
$ErrorActionPreference = 'Stop';
Invoke-WebRequest 'https://vstsagenttools.blob.core.windows.net/tools/SQLCMD/11.0/SQLCMD.zip' -OutFile sqlcmd.zip
try {
Add-Type -AssemblyName System.IO.Compression.FileSystem
} catch { };
[System.IO.Compression.ZipFile]::ExtractToDirectory('./sqlcmd.zip', './')
$env:PATH += ";$(Resolve-Path ./SQLCMD)";
# sqlcmd.exe will now be in your PATH
@drmohundro
Copy link
Author

drmohundro commented May 26, 2020

References include:

This is more or less how https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/SqlAzureDacpacDeploymentV1 works.

Just add a PowerShell task and use this as an inline script prior to running sqlcmd.exe.

Note that it would still be preferable to use the SqlServer PowerShell Module as an alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment