diff --git a/ServerHost.sln b/ServerHost.sln
index 1a7e957..9c08190 100644
--- a/ServerHost.sln
+++ b/ServerHost.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
+# Visual Studio 15
+VisualStudioVersion = 15.0.27004.2005
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerHost", "ServerHost\ServerHost.csproj", "{98D61E3E-76A7-4664-BAF7-FBBF41A798D9}"
EndProject
@@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Build.sh = Build.sh
Clean.cmd = Clean.cmd
documentation\DocFormatter.xsl = documentation\DocFormatter.xsl
+ GitVersion.yml = GitVersion.yml
init.cmd = init.cmd
init.ps1 = init.ps1
nuget-restore.cmd = nuget-restore.cmd
@@ -54,4 +55,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {4610FE64-924F-434C-B353-293C0D630539}
+ EndGlobalSection
EndGlobal
diff --git a/ServerHost/LibraryVersionInfo.cs b/ServerHost/LibraryVersionInfo.cs
new file mode 100644
index 0000000..4abb942
--- /dev/null
+++ b/ServerHost/LibraryVersionInfo.cs
@@ -0,0 +1,79 @@
+// Copyright (c) Jorgen Thelin. All rights reserved.
+// Licensed with Apache 2.0 https://github.com/jthelin/ServerHost/blob/master/LICENSE
+
+using System.Diagnostics;
+using System.Reflection;
+
+namespace Server.Host
+{
+ ///
+ /// Version info for ServerHost library.
+ ///
+ ///
+ /// Based on the Orleans.Runtime.RuntimeVersion class.
+ /// https://github.com/dotnet/orleans/blob/master/src/Orleans/Runtime/RuntimeVersion.cs
+ ///
+ public static class LibraryVersionInfo
+ {
+ private static readonly TypeInfo libraryTypeInfo = typeof(ServerHost).GetTypeInfo();
+
+ ///
+ /// The full version string of the library.
+ /// eg: '2012.5.9.51607 Build:12345 Timestamp: 20120509-185359'
+ ///
+ public static string Current
+ {
+ get
+ {
+ Assembly me = libraryTypeInfo.Assembly;
+ FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(me.Location);
+ // progVersionInfo.IsDebug; does not work
+ bool isDebug = IsAssemblyDebugBuild(me);
+ string productVersion = versionInfo.ProductVersion + (isDebug ? " (Debug)" : " (Release)");
+ return string.IsNullOrEmpty(productVersion) ? ApiVersion : productVersion;
+ }
+ }
+
+ ///
+ /// The ApiVersion of the library.
+ /// eg: '1.0.0.0'
+ ///
+ public static string ApiVersion
+ {
+ get
+ {
+ Assembly me = libraryTypeInfo.Assembly;
+ AssemblyName libraryInfo = me.GetName();
+ return libraryInfo.Version.ToString();
+ }
+ }
+
+ ///
+ /// The FileVersion of the library.
+ /// eg: '2012.5.9.51607'
+ ///
+ public static string FileVersion
+ {
+ get
+ {
+ Assembly me = libraryTypeInfo.Assembly;
+ FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(me.Location);
+ string fileVersion = versionInfo.FileVersion;
+ return string.IsNullOrEmpty(fileVersion) ? ApiVersion : fileVersion;
+ }
+ }
+
+ private static bool IsAssemblyDebugBuild(Assembly assembly)
+ {
+ foreach (object attribute in assembly.GetCustomAttributes(false))
+ {
+ DebuggableAttribute debuggableAttribute = attribute as DebuggableAttribute;
+ if (debuggableAttribute != null)
+ {
+ return debuggableAttribute.IsJITTrackingEnabled;
+ }
+ }
+ return false;
+ }
+ }
+}
diff --git a/ServerHost/Properties/AssemblyInfo.cs b/ServerHost/Properties/AssemblyInfo.cs
index 3b8ae1a..882177e 100644
--- a/ServerHost/Properties/AssemblyInfo.cs
+++ b/ServerHost/Properties/AssemblyInfo.cs
@@ -20,16 +20,3 @@
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e9fff8d5-f4c0-483d-aee6-5ff82afd434f")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/ServerHost/ServerHost.csproj b/ServerHost/ServerHost.csproj
index c467edd..688d662 100644
--- a/ServerHost/ServerHost.csproj
+++ b/ServerHost/ServerHost.csproj
@@ -47,6 +47,7 @@
+
@@ -77,6 +78,8 @@
+
+
\ No newline at end of file
diff --git a/ServerHost/packages.config b/ServerHost/packages.config
index 495bf34..8b1d578 100644
--- a/ServerHost/packages.config
+++ b/ServerHost/packages.config
@@ -1,5 +1,6 @@
+
-
\ No newline at end of file
+
diff --git a/Tests/ServerHostTests.cs b/Tests/ServerHostTests.cs
index 2a5074a..db4f01d 100644
--- a/Tests/ServerHostTests.cs
+++ b/Tests/ServerHostTests.cs
@@ -3,7 +3,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
-using System.IO;
using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
@@ -15,6 +14,28 @@ public sealed class ServerHostTests : IClassFixture, IDisposa
private readonly ITestOutputHelper _output;
private readonly string _className;
+ #region Test Initialization / Cleanup methods
+
+ // TestInitialize
+ public ServerHostTests(ITestOutputHelper output, ServerHostFixture fixture)
+ {
+ _output = output;
+ _className = GetType().Name;
+
+ _output.WriteLine("{0} TestInitialize", _className);
+ _output.WriteLine("{0} Fixture = {1}", _className, fixture);
+ }
+
+ // TestCleanup
+ public void Dispose()
+ {
+ _output.WriteLine("{0} TestCleanup", _className);
+
+ _output.WriteLine("{0} UnloadAllServers", _className);
+ ServerHost.UnloadAllServers();
+ }
+ #endregion
+
[Fact]
[Trait("Category","BVT")]
[SuppressMessage("ReSharper", "ConvertToConstant.Local")]
@@ -32,28 +53,22 @@ public void LoadServerInNewAppDomain()
serverHostHandle.Server.Should().BeOfType("Server instance type.");
}
- #region Test Initialization / Cleanup methods
-
- // TestInitialize
- public ServerHostTests(ITestOutputHelper output, ServerHostFixture fixture)
+ [Fact]
+ [Trait("Category", "BVT")]
+ public void ServerHost_Version()
{
- _output = output;
- _className = GetType().Name;
- output.WriteLine("{0} TestInitialize", _className);
+ _output.WriteLine("ServerHost library API version = {0}", LibraryVersionInfo.ApiVersion);
+ _output.WriteLine("ServerHost library file version = {0}", LibraryVersionInfo.FileVersion);
+ _output.WriteLine("ServerHost library full version info string = {0}", LibraryVersionInfo.Current);
- output.WriteLine("{0} Fixture = {1}", _className, fixture);
+ string versionString = LibraryVersionInfo.FileVersion;
+ _output.WriteLine("ServerHost library version = {0}", versionString);
- output.WriteLine("{0} Current directory = {1}", _className, Directory.GetCurrentDirectory());
- }
+ versionString.Should().NotBeNullOrEmpty("Version value should be returned");
- // TestCleanup
- public void Dispose()
- {
- _output.WriteLine("{0} TestCleanup", _className);
-
- _output.WriteLine("{0} UnloadAllServers", _className);
- ServerHost.UnloadAllServers();
+ versionString.Should().Contain(".", "Version format = Major.Minor");
+ versionString.Should().NotStartWith("1.0.0.0", "Version should be specific.");
+ versionString.Should().NotStartWith("0.0.0.0", "Version should not be zero.");
}
- #endregion
}
}