How do I check the version of a dll on OS X?
The dll is managed, created in C#, that's all I know.
How do I check the version of a dll on OS X?
The dll is managed, created in C#, that's all I know.
A very quick and simple way is to issue the cat command and read the last few lines e.g.
$ cat mylibrary.dll
Depends what kind of information you want to find… you can add a reference to the DLL in a project in Xamarin Studio and then expand the References folder & double-click on the DLL… this will open it in AssemblyBrowser and display the AssemblyInfo that was compiled into the DLL.
If you want to know what architecture the DLL was built for, run this in a Terminal window:
file insert_filename_here.dll
If it's a x86 (or "Any CPU") DLL, it will say:
insert_filename_here.dll: PE32 executable for MS Windows (DLL) (console) Intel 80386 32-bit Mono/.Net assembly
If it's an x64 DLL, it will say:
insert_filename_here.dll: PE32+ executable for MS Windows (DLL) (console) Mono/.Net assembly!
You can write a bit of code to do it. Create Program.cs
containing:
using System;
using System.Diagnostics;
namespace FileVersionInfoExample
{
class Program
{
static void Main(string[] args)
{
var fileName = args[0];
var fvi = FileVersionInfo.GetVersionInfo(fileName);
Console.WriteLine($"FileVersion:\t{fvi.FileVersion}");
Console.WriteLine($"ProductVersion:\t{fvi.ProductVersion}");
}
}
}
To find the version of test.dll
on mono:
csc Program.cs
mono Program.exe test.dll
To find the version of test.dll
on .NET Core, first create Program.csproj
containing:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
</Project>
then run:
dotnet run test.dll
If you have .NET Core 2.1, there is a .NET Core Global Tool, dotnet-versioninfo that you can use. It can be installed like this:
dotnet tool install --global dotnet-versioninfo
Then run:
versioninfo test.dll
If you use Mono Cecil to load the assembly into memory (AssemblyDefinition.ReadAssembly
), you can read the version attribute (AssemblyDefinition.Name.Version
).
https://github.com/jbevain/cecil/tree/master/Mono.Cecil
Reflection can also be used, but it requires you to load the assembly into an appdomain which is not efficient.
Xamarin Studio internally uses Cecil or reflection to query the same information from the assembly.
A long time ago I created a dotnet tool called DllProps for that.
$ dotnet tool install --global DllProps.Tool
$ dll-props your.dll
Company: Dll-Company
Copyright: Copyright (c) 2021
FileVersion: 9.4.2.0
ProductVersion: 9.4.2.123456
Description: Your
Go to powershell on mac.
(Get-Item "./path/to/your/file.dll").VersionInfo.ProductVersion
If you don't need it programmatically you can open it in TextEdit (Quick Look, then click the Open in TextEdit button) and scroll all the way to the bottom. You should see something like the following
<MonoTouch,Version=v1.0TFrameworkDisplayName MonoTouchXamarin.MobileXamarin Inc.(#Copyright ¬© 2011-2013 Xamarin Inc.0.7.1.0TWrapNonExceptionThrowsÄû.ÄÑSystem.Security.Permissions.SecurityPermissionAttribute, mscorlib, Version=2.0.5.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798eTSkipVerificationúŸæŸ ∞Ÿ_CorDllMainmscoree.dllˇ% Ä0ÄHX‡@@4VS_VERSION_INFOΩÔ˛?DVarFileInfo$Translation∞†StringFileInfo|000004b0<CompanyNameXamarin Inc.HFileDescriptionXamarin
.Mobile0FileVersion0.7.1.0HInternalNameXamarin.Mobile.dlll#LegalCopyrightCopyright © 2011-2013 Xamarin Inc.POriginalFilenameXamarin.Mobile.dll@ProductNameXamarin.Mobile4ProductVersion0.7.1.08Assembly Version0.7.1.0––9
I've created a macOS command line utility called win_file_version to access the version number of a Windows EXE or DLL. You can request either the numeric file version or product version, or the file version or product version string from the STRING FILE INFO section.
A description is available in the README, and the first release is available in the release section of the GitHub repository.
Enjoy.
You can use utility named strings, version starts from letter 'v', so we can grep such lines:
root@ad5596660846:/app# strings System.Threading.dll | grep '^v'
v4.0.30319
value__
value
vv:S