Note
this article assumes you have a problem withinstalling msodbc.msi
, but the same principles MIGHT apply to any other package which is availablein chocolatey
.
based on this link from Microsoft (please MS,
msiexec /quiet /passive /qn /i msodbcsql.msi IACCEPTMSODBCSQLLICENSETERMS=YES ADDLOCAL=ALL
would be enough to install the package on any machine from powershell
to check if a package is installed on docker using powershell
, you can use
WMIC SOFTWAREFEATURE LIST BRIEF
to see a list of all the installed packages. if your installation has gone according to your plan, then you’ll be able to see something like this:
you are not seeing your ODBC driver (or your package) in the list, then you are screwed, again! so what shall we do? okay, follow me:
- ogo to chocolatey package search and search for your package. if you find it on the list, you are in luck, otherwise, please google for other solutions! if you found your package in chocolatey, in my case msodbc then go forward:
- install
chocolatey
on your docker. I used the following command inpowershell
:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
- now you have `choco` on your system! try `choco -?` to check if it’s working. is it? wonderful, continue!
- okay, now
checkout the version of msodbc you want to install. if it already exists on the choco repository, the chances are you can install them just by using
choco install sqlserver-odbcdriver --version [your-version-here]
- now comes the “tricky” part: as I tried to use
choco install sqlserver-odbcdriver --version 12.0.4219.0
to install an older version of the driver, I was informed that the link tomicrosoft’s website containing the actual package is not available anymore!Thanks microsoft for constantly changing the links!
so how do you get past this issue? on the sidebar of the chocolatey page, there is a download button which allows you to download a.nupkg
file containing installation instructions for chocolatey. you can always install a choco-package using this file. the trick is to modify this file in a way that it points to correct paths. to do so, follow these instructions:- open
the .nupkg
with a zip-archiver. the file is nothing otherthat arenamed .zip
. you will have something like this:
- open
- go to
tools
, openchocolateyinstall.ps1
with a text editor. the contents will look something like this:
- go to
$packageName = 'sqlserver-odbcdriver' $installerType = 'msi' $silentArgs= '/Passive /NoRestart IACCEPTMSODBCSQLLICENSETERMS=YES' $url = 'https://download.microsoft.com/download/5/7/2/57249A3A-19D6-4901-ACCE-80924ABEB267/1033/x86/msodbcsql.msi' $url64 = 'https://download.microsoft.com/download/5/7/2/57249A3A-19D6-4901-ACCE-80924ABEB267/1033/amd64/msodbcsql.msi' $checksumType = 'sha256' $checksum = 'CE9B9DDD8F38926DF374C1B947DD8A312495E8D81BE985109347E432257BA53E' $checksum64 = 'CC7FD7CBB9840DE239DCC0C8AB12D2CC2BCF411AF4B0B8BD5AB0730805F2F4B3' Install-ChocolateyPackage "$packageName" "$installerType" "$silentArgs" "$url" "$url64" -validExitCodes @(0) "$checksum" "$checksumType" "$checksum64" "$checksumType"
- Microsoft has changed the links mentioned in
$url
and$url64
. you have to find the correct paths. one way is to visit microsoft’s ODBC Driver Download page, follow the links to your desired package and then check your browser’s download history for the correct link. it turns out, they have replaced the1033/amd64
and1033/x86
with/ENU/x64
and/ENU/x86
respectively. - make sure that the checksum values are also correct.
- now save the file, and compress the package-files back into a
.zip
file and rename the extension to.nupkg
. - you can now use
choco install sqlserver-odbcdriver.12.0.4219.0.nupkg
(or whatever your package is called) to install this MSI on the system.
- Microsoft has changed the links mentioned in
I’m not a chocolatey
expert, but I believe you can always create your own packages by creating a similar structure (maybe only the tools > chocolateyinstall.ps1
and package.nuspec
files are needed to create a proper package?) and ask choco
to install them for you.
hope this has helped you! 🙂 go have fun now 😉
Comments are closed, but trackbacks and pingbacks are open.