Assembly version from command line?

后端 未结 9 1487
慢半拍i
慢半拍i 2020-12-12 21:35

Is there a Microsoft tool to get the assembly version of a DLL file from a command line?

(I know that I can code my own tool.)

相关标签:
9条回答
  • 2020-12-12 22:10

    Wow this is bad considering things like old exploitable gdiplus.dll's floating around.

    My solution is simple. batch file programming.

    This puts an nfo file in the same dir with the version

    You can GET filever.exe, which can be downloaded as part of the Windows XP SP2 Support Tools package - only 4.7MB of download.

    adobe_air_version.bat

    c:\z\filever.exe /A /D /B "C:\Program Files\Common Files\Adobe AIR\Versions\1.0\Adobe AIR.dll" >000_adobe_air.dll_VERSION.nfo
    
    exit
    

    Variation.

    Get all the versions in a directory to a text file.

    c:\z\filever.exe /A /D /B "c:\somedirectory\ *.dll *.exe >000_file_versions.nfo
    
    exit
    

    There's also Sigcheck by systernals.

    http://technet.microsoft.com/en-us/sysinternals/bb897441.aspx

    0 讨论(0)
  • 2020-12-12 22:10

    Do you use GACUTIL?

    You can get the assembly version from this command below.

    C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe /L "<your assembly name>"
    
    0 讨论(0)
  • 2020-12-12 22:13

    In Powershell

    $version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("filepath.exe").FileVersion.ToString()
    
    0 讨论(0)
  • 2020-12-12 22:16

    If you use mono and linux, try this:

    monodis --assembly MyAssembly.dll
    
    find . -name MyAssembly.dll -exec monodis --assembly {} ';' | grep Version 
    
    0 讨论(0)
  • 2020-12-12 22:21

    This is an area where PowerShell shines. If you don't already have it, install it. It's preinstalled with Windows 7.

    Running this command line:

    [System.Reflection.Assembly]::LoadFrom("C:\full\path\to\YourDllName.dll").GetName().Version
    

    outputs this:

    Major  Minor  Build  Revision
    -----  -----  -----  --------
    3      0      8      0
    

    Note that LoadFrom returns an assembly object, so you can do pretty much anything you like. No need to write a program.

    0 讨论(0)
  • For those, like I, who come looking for such a tool:

    using System;
    using System.IO;
    using System.Reflection;
    
    class Program
    {
        public static void Main(string[] args)
        {
            foreach (string arg in args)
            {
                try
                {
                    string path = Path.GetFullPath(arg);
                    var assembly = Assembly.LoadFile(path);
                    Console.Out.WriteLine(assembly.GetName().FullName);
                }
                catch (Exception exception)
                {
                    Console.Out.WriteLine(string.Format("{0}: {1}", arg, exception.Message));
                }
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题