1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System; 6 using System.IO; 7 using System.Runtime.InteropServices; 8 using System.Diagnostics; 9 using System.Reflection; 10 11 #pragma warning disable 618 12 13 namespace DPStressHarness 14 { 15 public class VersionUtil 16 { GetFileVersion(string moduleName)17 public static string GetFileVersion(string moduleName) 18 { 19 FileVersionInfo info = GetFileVersionInfo(moduleName); 20 return info.FileVersion; 21 } 22 GetPrivateBuild(string moduleName)23 public static string GetPrivateBuild(string moduleName) 24 { 25 FileVersionInfo info = GetFileVersionInfo(moduleName); 26 return info.PrivateBuild; 27 } 28 GetFileVersionInfo(string moduleName)29 private static FileVersionInfo GetFileVersionInfo(string moduleName) 30 { 31 if (File.Exists(moduleName)) 32 { 33 return FileVersionInfo.GetVersionInfo(Path.GetFullPath(moduleName)); 34 } 35 else 36 { 37 string moduleInRuntimeDir = AppContext.BaseDirectory + moduleName; 38 return FileVersionInfo.GetVersionInfo(moduleInRuntimeDir); 39 } 40 } 41 } 42 } 43