Get assembly version in PCL

后端 未结 3 1145
悲哀的现实
悲哀的现实 2021-01-01 16:44

I have the following line of code in .NET 4.5 that I am trying to build as Portable Class Library. It\'s purpose is to get assembly version:

this.GetType().A         


        
3条回答
  •  梦毁少年i
    2021-01-01 17:40

    I now use the following:

    [assembly: AssemblyTitle(AssemblyInfo.AssemblyTitle)]
    [assembly: AssemblyProduct(AssemblyInfo.AssemblyProduct)]
    
    [assembly: AssemblyVersion(AssemblyInfo.AssemblyVersion)]
    [assembly: AssemblyFileVersion(AssemblyInfo.AssemblyFileVersion)]
    [assembly: AssemblyInformationalVersion(AssemblyInfo.AssemblyInformationalVersion)]
    
    internal class AssemblyInfo
    {
        public const string AssemblyTitle = "...";
        public const string AssemblyProduct = "...";
    
        public const string AssemblyVersion = "1.0.0.0";
        public const string AssemblyFileVersion = "1.0.0.0";
        public const string AssemblyInformationalVersion = "1.0.0.0-dev";
    }
    

    This allows me to reference any of the constants within the assembly without using reflection, e.g. AssemblyInfo.AssemblyProduct.

提交回复
热议问题