Install SqlPackage on macOS with dotnet CLI

Install SqlPackage on macOS with dotnet CLI

Table of Contents

A long time ago in a galaxy far, far away…

This post is over 12 months old, that's a long time in tech! Please be mindful of that when reading this post, young Padawan, as it could be outdated. I try to keep things up to date as much as possible. If you think something needs updating, please let me know in the comments.

Introduction

Installing sqlpackage on a Mac used to be a bit of a pain because of the security constraints that occur because Microsoft do not sign their packages properly and I wrote about working around those complexities in 2023. But we can just install it using dotnet which makes all those issues go away.

Prerequisites

Before installing sqlpackage, you will need to have dotnet sdk isntalled. The simplest way to install that is via homebrew:

brew install dotnet-sdk --cask

Install Sqlpackage

Once you have dotnet installed, you can install sqlpackage using the following command:

dotnet tool install -g microsoft.sqlpackage

You may end up with a message warning you that the ~/.dotnet/tools path is not in the PATH environment variable and it will provide you with a command to add it.

Cleaning up Old Installations

If you have previously installed sqlpackage using the old method, you can remove it by running the following command:

rm -rd ~/.sqlpackage

And you will also want to remove the path from your bash / zsh / pwsh profiles.

Update Sqlpackage

To update sqlpackage, you can run the following command:

dotnet tool update -g microsoft.sqlpackage

References

Comments

#mtfbwy