I am attempting to run a SqlPackage /Action:Publish ...
command in a PowerShell pwsh
task on an Ubuntu agent. I installed the tool using dotnet tool install --global microsoft.sqlpackage
. However, when I attempt to call SqlPackage after this successful install, I am met with the following error:
dotnet tool install --global microsoft.sqlpackage
You can invoke the tool using the following command: sqlpackage
Tool 'microsoft.sqlpackage' (version '162.2.111') was successfully installed.
SqlPackage /Action:Publish [...]
SqlPackage: /home/vsts/work/_temp/af18b7cc-867a-478a-a211-4ea3963f2b75.ps1:19
Line |
19 | SqlPackage /Action:Publish /SourceFile:"$($dacpac.FullName)" /TargetConnec …
| ~~~~~~~~~~
| The term 'SqlPackage' is not recognized as a name of a cmdlet, function,
| script file, or executable program. Check the spelling of the name, or
| if a path was included, verify that the path is correct and try again.
Why is this failing, even though I installed the tool? Separating the task out into separate install and SqlPackage tasks (effectively restarting PWSH session) did not solve the issue. The same problem happens whether on a cloud (ubuntu-latest
) agent or a self-hosted Linux agent.
It took me a while to remember that Linux is very case-sensitive. Changing my command from SqlPackage /Action:Publish ...
to sqlpackage /Action:Publish ...
solved my issue.
In addition, I noticed that some agents for some reason refuse to use the tools in PATH for some reason. Fully-qualifying the tool with & $HOME/.dotnet/tools/sqlpackage /Action:Publish ...
worked for me, for both Linux and Windows agents.