如何引用ASSEMBLYVERSION和ASSEMBLYFILEVERSION?

时间:2009-07-10 19:33:00

标签: visual-studio build versioning compilation

我需要显示AssemblyVersion和AssemblyFileVersion。在AssemblyInfo.cs中,我有: [assembly:AssemblyVersion(“1.0。*”)] [assembly:AssemblyFileVersion(“2009.8.0”)]

然而,当我参考上述内容时,我只得到“2009.8.0”: 公共类VersionInfo     {         public static string AppVersion()         {             return System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly()。Location).FileMajorPart +“。” + System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly()。Location).FileMinorPart +“。” + System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly()。Location).FileBuildPart;          }     }

如何显示两个值? 感谢。

1 个答案:

答案 0 :(得分:2)

Application.ProductVersion版本将返回AssemblyFileVersion

public string AppVersion() 
{ 
  return Application.ProductVersion + "." + 
    Assembly.GetExecutingAssembly().GetName().Version.ToString();
}