public static String AssemblyFileVersionInfo(this System.Reflection.Assembly assembly) { String InfoStr; #if UseWindowsDesktop FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); String AsemVersion = fileVersionInfo.FileVersion; if (fileVersionInfo.FileBuildPart != 0) { String buildNoString = DateTimeBuildNo.ToBuildDateString(fileVersionInfo.FileBuildPart, fileVersionInfo.FilePrivatePart); InfoStr = String.Format("{0} {1}", AsemVersion, buildNoString); } else { InfoStr = AsemVersion; } #else // AssemblyVersionAttribute ava = assembly.GetCustomAttribute<AssemblyVersionAttribute>(); AssemblyFileVersionAttribute afva = assembly.GetCustomAttribute <AssemblyFileVersionAttribute>(); if (afva != null) { String AsemVersion = afva.Version; String[] parts = AsemVersion.Split('.'); if (parts.Length >= 2) { Int32 FileBuildPart = 0; Int32 FilePrivatePart = 0; Int32.TryParse(parts[2], out FileBuildPart); if (parts.Length >= 3) { Int32.TryParse(parts[3], out FilePrivatePart); } String buildNoString = DateTimeBuildNo.ToBuildDateString(FileBuildPart, FilePrivatePart); InfoStr = String.Format("{0} {1}", AsemVersion, buildNoString); } else { InfoStr = afva.Version; } } else { InfoStr = "null"; } #endif // UseWindowsDesktop return(InfoStr); }
public static String AssemblyVersionInfo(this System.Reflection.Assembly assembly) { System.Reflection.AssemblyName AsmName = assembly.GetName(); Version AsemVersion = AsmName.Version; String InfoStr; if (AsemVersion.Build != 0) { String buildNoString = DateTimeBuildNo.ToBuildDateString(AsemVersion.Build, AsemVersion.Revision); InfoStr = String.Format("{0} {1}", AsemVersion.ToString(), buildNoString); } else { InfoStr = AsemVersion.ToString(); } return(InfoStr); }