I'm trying to get sqlpackage to work on a build server (works fine in local dev environment), but keep getting the below output when trying to run it:
You must install .NET to run this application.
App: C:\Users\its-bi-cicd-svc-p\.dotnet-cli-tools\tools\sqlpackage.exe
Architecture: x64
App host version: 7.0.5
.NET location: Not found
I'm using the dotnet SDK installed in place as per this article, running sqlpackage with the working directory set to the SDK install directory, but still get the same message. I also have PowerShell 7.3.4 installed so the 7.0.5 .NET runtime is definitely installed on the machine (tested with [Environment]::Version).
The solution in the article here is just to install the runtime, but I would have thought the whole point of having the SDK built into the CI pipeline is so we don't have to maintain multiple versions of the same .NET runtime, all getting out of sync with each other. The sqlpackage tool was installed by using the SDK, why it isn't using it as the default runtime, I don't know! I also don't particularly want to bloat the build server with the SDK runtime, the PowerShell runtime and another runtime.
Where is sqlpackage looking for the .NET version and how do I get sqlpackage to locate the SDK version? The docs don't suggest there's anyway of passing a .NET location to override the defaults so I'm stumped as to what Microsoft expect us to do here
Looking at this doc, it turns out tools installed via the v7 SDK only look for a globally installed location, and in the location specified in the DOTNET_ROOT environment variable. There's also potentially the option of using dotnet tool run, but I haven't worked out how to use this yet.
Also should be noted that sqlpackage requires v6 of the runtime at the time of writing, so that needs to be installed alongside the SDK installation. The dotnet installer can do this by specifying the runtime version and using the -Runtime "dotnet" parameter