Skip to content

Instantly share code, notes, and snippets.

@0xced
Last active June 27, 2019 11:49
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 0xced/ac3c152b4ca9a2fa6fb0993078cbf874 to your computer and use it in GitHub Desktop.
Save 0xced/ac3c152b4ca9a2fa6fb0993078cbf874 to your computer and use it in GitHub Desktop.
Workarounds for using System.Data.SQLite and Microsoft.Azure.Management.ServiceBus on Mono
#!/bin/bash -e -x
# For System.Data.SQLite to work on Mono, see https://stackoverflow.com/questions/21293105/system-dllnotfoundexception-on-mono-sqlite/43173220#43173220
function Install_libSQLiteInterop
{
# Latest version is on https://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
SQLITE_VERSION=1.0.111.0
SQLITE_DYLIB=sqlite-netFx-source-${SQLITE_VERSION}/bin/2013/Release/bin/libSQLite.Interop.dylib
pushd ~/Downloads
if [ ! -f "${SQLITE_DYLIB}" ]; then
curl -LO https://system.data.sqlite.org/blobs/${SQLITE_VERSION}/sqlite-netFx-source-${SQLITE_VERSION}.zip
unzip sqlite-netFx-source-${SQLITE_VERSION}.zip -d sqlite-netFx-source-${SQLITE_VERSION} > /dev/null
bash sqlite-netFx-source-${SQLITE_VERSION}/Setup/compile-interop-assembly-release.sh # this command produces libSQLite.Interop.dylib
fi
for LIB_PATH in /Library/Frameworks/Mono.framework/Versions/*.*/lib; do
sudo cp -v "${SQLITE_DYLIB}" "${LIB_PATH}"
done
popd
}
# For Microsoft.Azure.Management.ServiceBus to work on Mono, see https://github.com/Azure/azure-sdk-for-net/issues/3410#issuecomment-392296773
function Install_FakeWindowsVersion
{
sudo mkdir -p "/Library/Frameworks/Mono.framework/Versions/Current/etc/mono/registry/LocalMachine/SOFTWARE/Microsoft/Windows NT/CurrentVersion/"
sudo tee "/Library/Frameworks/Mono.framework/Versions/Current/etc/mono/registry/LocalMachine/SOFTWARE/Microsoft/Windows NT/CurrentVersion/values.xml" > /dev/null <<EOF
<values>
<value name="ProductName" type="string">Mac OS X</value>
<value name="CurrentVersion" type="string">10.12.6</value>
<value name="CurrentBuild" type="string">16G1314</value>
</values>
EOF
}
Install_libSQLiteInterop
Install_FakeWindowsVersion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment