This is a really old question and just about everything has changed, but as of dotnet 2.1 (so you can dotnet tool install
) you can install dotnet-ildasm
:
dotnet tool install --tool-path . dotnet-ildasm
Then you can use this function:
function dll_version {
local dll="$1"
local version_line
local version
version_line="$(./dotnet-ildasm "$dll" | grep AssemblyFileVersionAttribute)"
# Uses SerString format:
# 01 00 is Prolog
# SZARRAY for NumElem
# version chars for Elem
# 00 00 for NamedArgs
# See:
# https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-335.pdf#%5B%7B%22num%22%3A2917%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C87%2C321%2C0%5D
[[ $version_line =~ \(\ 01\ 00\ [0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF]\ (.*)\ 00\ 00\ \)$ ]]
dotcount=0
for i in ${BASH_REMATCH[1]}; do
if [[ $i =~ ^2[eE]$ ]]; then
(( dotcount++ ))
fi
if (( dotcount == 3 )); then
break
fi
echo -n -e "\u$i"
done
}