locked
How to have a version number or release code on the bin MVC dll file RRS feed

  • Question

  • User1868852945 posted

    Is there a good way to have a version number (or release code) on the main dll file for an MVC webapp?  Hopefully there is a property for this such that I can assign a number to it and retrieve it at startup runtime?  This way I can alert the user to the need to upgrade should their software be out of date..

    Thanks.

    Saturday, April 13, 2019 1:59 AM

Answers

  • User1724605321 posted

    Hi gunderj ,

    There are two possible 'versions'  , one is windows filesystem file version, applicable to all executable files . To get that in c# :

    // Get the file version for the notepad.
    FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(@"C:\MyAssembly.dll");
    
    // Print the file name and version number.
    Console.WriteLine("File: " + myFileVersionInfo.FileDescription + '\n' +
                      "Version number: " + myFileVersionInfo.FileVersion);

    One is assembly build version, which is embedded in a .NET assembly by the compiler (obviously only applicable to .NET assembly dll and exe files) :

    AssemblyName.GetAssemblyName(@"c:\path\to\file.dll").Version

    Reference : Programmatically get the version number of a DLL

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 15, 2019 2:59 AM

All replies

  • User475983607 posted

    Is there a good way to have a version number (or release code) on the main dll file for an MVC webapp?  Hopefully there is a property for this such that I can assign a number to it and retrieve it at startup runtime?  This way I can alert the user to the need to upgrade should their software be out of date..

    My best guess is you are trying to version a DLL that you created?  If so, simply right click the project in solution explorer and select properties.  Go to the "Application" screen and click Assembly Information.  Set the Assembly and File Version to what you like.

    Saturday, April 13, 2019 1:12 PM
  • User1724605321 posted

    Hi gunderj ,

    There are two possible 'versions'  , one is windows filesystem file version, applicable to all executable files . To get that in c# :

    // Get the file version for the notepad.
    FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(@"C:\MyAssembly.dll");
    
    // Print the file name and version number.
    Console.WriteLine("File: " + myFileVersionInfo.FileDescription + '\n' +
                      "Version number: " + myFileVersionInfo.FileVersion);

    One is assembly build version, which is embedded in a .NET assembly by the compiler (obviously only applicable to .NET assembly dll and exe files) :

    AssemblyName.GetAssemblyName(@"c:\path\to\file.dll").Version

    Reference : Programmatically get the version number of a DLL

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 15, 2019 2:59 AM