How can I get the executing assembly version?

前端 未结 6 1583
慢半拍i
慢半拍i 2020-12-07 13:51

I am trying to get the executing assembly version in C# 3.0 using the following code:

var assemblyFullName = Assembly.GetExecutingAssembly().FullName;
var ve         


        
6条回答
  •  再見小時候
    2020-12-07 13:54

    Product Version may be preferred if you're using versioning via GitVersion or other versioning software.

    To get this from within your class library you can call System.Diagnostics.FileVersionInfo.ProductVersion:

    using System.Diagnostics;
    using System.Reflection;
    
    //...
    
    var assemblyLocation = Assembly.GetExecutingAssembly().Location;
    var productVersion = FileVersionInfo.GetVersionInfo(assemblyLocation).ProductVersion
    

提交回复
热议问题