diff --git a/Jenkinsfile b/Jenkinsfile
index aa222c8..841e5bc 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,6 +1,7 @@
node {
stage('Checkout') {
checkout scm
+ bat 'git pull --tags'
}
stage('Acquire SE') {
@@ -14,7 +15,7 @@ node {
}
stage('Build') {
- bat "\"${tool 'MSBuild'}msbuild\" Torch.sln /p:Configuration=Release /p:Platform=x64 /t:TransformOnBuild"
+ currentBuild.description = bat(returnStdout: true, script: '@powershell -File Versioning/version.ps1').trim()
bat "\"${tool 'MSBuild'}msbuild\" Torch.sln /p:Configuration=Release /p:Platform=x64"
}
@@ -37,9 +38,20 @@ node {
}
stage('Archive') {
- bat "IF EXIST bin\\torch-${BRANCH_NAME}.zip DEL bin\\torch-${BRANCH_NAME}.zip"
- bat "powershell -Command \"Add-Type -Assembly System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::CreateFromDirectory(\\\"\$PWD\\bin\\x64\\Release\\\", \\\"\$PWD\\bin\\torch-${BRANCH_NAME}.zip\\\")\""
- archiveArtifacts artifacts: 'bin/torch-${BRANCH_NAME}.zip', caseSensitive: false, fingerprint: true, onlyIfSuccessful: true
+ bat '''IF EXIST bin\\torch-server.zip DEL bin\\torch-server.zip
+ IF EXIST bin\\package-server RMDIR /S /Q bin\\package-server
+ xcopy bin\\x64\\Release bin\\package-server\\
+ del bin\\package-server\\Torch.Client*'''
+ bat "powershell -Command \"Add-Type -Assembly System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::CreateFromDirectory(\\\"\$PWD\\bin\\package-server\\\", \\\"\$PWD\\bin\\torch-server.zip\\\")\""
+ archiveArtifacts artifacts: 'bin/torch-server.zip', caseSensitive: false, onlyIfSuccessful: true
+
+ bat '''IF EXIST bin\\torch-client.zip DEL bin\\torch-client.zip
+ IF EXIST bin\\package-client RMDIR /S /Q bin\\package-client
+ xcopy bin\\x64\\Release bin\\package-client\\
+ del bin\\package-client\\Torch.Server*'''
+ bat "powershell -Command \"Add-Type -Assembly System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::CreateFromDirectory(\\\"\$PWD\\bin\\package-client\\\", \\\"\$PWD\\bin\\torch-client.zip\\\")\""
+ archiveArtifacts artifacts: 'bin/torch-client.zip', caseSensitive: false, onlyIfSuccessful: true
+
archiveArtifacts artifacts: 'bin/x64/Release/Torch*', caseSensitive: false, fingerprint: true, onlyIfSuccessful: true
}
}
\ No newline at end of file
diff --git a/Torch.API/Plugins/PluginAttribute.cs b/Torch.API/Plugins/PluginAttribute.cs
index 867555c..7b60e32 100644
--- a/Torch.API/Plugins/PluginAttribute.cs
+++ b/Torch.API/Plugins/PluginAttribute.cs
@@ -1,22 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Torch.API.Plugins
{
+ ///
+ /// Indicates that the given type should be loaded by the plugin manager as a plugin.
+ ///
+ [AttributeUsage(AttributeTargets.Class)]
public class PluginAttribute : Attribute
{
+ ///
+ /// The display name of the plugin
+ ///
public string Name { get; }
+ ///
+ /// The version of the plugin
+ ///
public Version Version { get; }
+ ///
+ /// The GUID of the plugin
+ ///
public Guid Guid { get; }
+ ///
+ /// Creates a new plugin attribute with the given attributes
+ ///
+ ///
+ ///
+ ///
public PluginAttribute(string name, string version, string guid)
{
Name = name;
Version = Version.Parse(version);
Guid = Guid.Parse(guid);
}
+
+ ///
+ /// Creates a new plugin attribute with the given attributes. Version is computed as the version of the assembly containing the given type.
+ ///
+ ///
+ /// Version is this type's assembly's version
+ ///
+ public PluginAttribute(string name, Type versionSupplier, string guid)
+ {
+ Name = name;
+ Version = versionSupplier.Assembly.GetName().Version;
+ Guid = Guid.Parse(guid);
+ }
}
}
diff --git a/Torch.API/Properties/AssemblyInfoGen.tt b/Torch.API/Properties/AssemblyInfoGen.tt
deleted file mode 100644
index 4069a38..0000000
--- a/Torch.API/Properties/AssemblyInfoGen.tt
+++ /dev/null
@@ -1,12 +0,0 @@
-<#@ template debug="false" hostspecific="false" language="C#" #>
-<#@ output extension=".cs" #>
-using System.Reflection;
-
-<# var dt = DateTime.UtcNow;
- int major = 1;
- int minor = 0;
- int build = dt.DayOfYear;
- int rev = (int)dt.TimeOfDay.TotalMinutes / 2;
-#>
-[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
-[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
\ No newline at end of file
diff --git a/Torch.API/Torch.API.csproj b/Torch.API/Torch.API.csproj
index 8f2942b..99b4836 100644
--- a/Torch.API/Torch.API.csproj
+++ b/Torch.API/Torch.API.csproj
@@ -156,6 +156,9 @@
+
+ Properties\AssemblyVersion.cs
+
@@ -175,11 +178,6 @@
-
- AssemblyInfoGen.tt
- True
- True
-
@@ -188,12 +186,6 @@
-
-
- TextTemplatingFileGenerator
- AssemblyInfoGen.cs
-
-
diff --git a/Torch.Client.Tests/Properties/AssemblyInfoGen.tt b/Torch.Client.Tests/Properties/AssemblyInfoGen.tt
deleted file mode 100644
index 4069a38..0000000
--- a/Torch.Client.Tests/Properties/AssemblyInfoGen.tt
+++ /dev/null
@@ -1,12 +0,0 @@
-<#@ template debug="false" hostspecific="false" language="C#" #>
-<#@ output extension=".cs" #>
-using System.Reflection;
-
-<# var dt = DateTime.UtcNow;
- int major = 1;
- int minor = 0;
- int build = dt.DayOfYear;
- int rev = (int)dt.TimeOfDay.TotalMinutes / 2;
-#>
-[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
-[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
\ No newline at end of file
diff --git a/Torch.Client.Tests/Torch.Client.Tests.csproj b/Torch.Client.Tests/Torch.Client.Tests.csproj
index 0c86947..d73b8d4 100644
--- a/Torch.Client.Tests/Torch.Client.Tests.csproj
+++ b/Torch.Client.Tests/Torch.Client.Tests.csproj
@@ -60,12 +60,10 @@
-
-
- AssemblyInfoGen.tt
- True
- True
+
+ Properties\AssemblyVersion.cs
+
@@ -90,12 +88,6 @@
-
-
- TextTemplatingFileGenerator
- AssemblyInfoGen.cs
-
-
diff --git a/Torch.Client/Properties/AssemblyInfoGen.tt b/Torch.Client/Properties/AssemblyInfoGen.tt
deleted file mode 100644
index 4069a38..0000000
--- a/Torch.Client/Properties/AssemblyInfoGen.tt
+++ /dev/null
@@ -1,12 +0,0 @@
-<#@ template debug="false" hostspecific="false" language="C#" #>
-<#@ output extension=".cs" #>
-using System.Reflection;
-
-<# var dt = DateTime.UtcNow;
- int major = 1;
- int minor = 0;
- int build = dt.DayOfYear;
- int rev = (int)dt.TimeOfDay.TotalMinutes / 2;
-#>
-[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
-[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
\ No newline at end of file
diff --git a/Torch.Client/Torch.Client.csproj b/Torch.Client/Torch.Client.csproj
index 937b43a..abe6a5f 100644
--- a/Torch.Client/Torch.Client.csproj
+++ b/Torch.Client/Torch.Client.csproj
@@ -118,12 +118,10 @@
-
-
- AssemblyInfoGen.tt
- True
- True
+
+ Properties\AssemblyVersion.cs
+
@@ -169,12 +167,6 @@
-
-
- TextTemplatingFileGenerator
- AssemblyInfoGen.cs
-
-
diff --git a/Torch.Server.Tests/Properties/AssemblyInfoGen.tt b/Torch.Server.Tests/Properties/AssemblyInfoGen.tt
deleted file mode 100644
index 4cb8d7e..0000000
--- a/Torch.Server.Tests/Properties/AssemblyInfoGen.tt
+++ /dev/null
@@ -1,12 +0,0 @@
-<#@ template debug="false" hostspecific="false" language="C#" #>
-<#@ output extension=".cs" #>
-using System.Reflection;
-
-<# var dt = DateTime.UtcNow;
- int major = 1;
- int minor = 1;
- int build = dt.DayOfYear;
- int rev = (int)dt.TimeOfDay.TotalMinutes / 2;
-#>
-[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
-[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
\ No newline at end of file
diff --git a/Torch.Server.Tests/Torch.Server.Tests.csproj b/Torch.Server.Tests/Torch.Server.Tests.csproj
index 7ad592a..a3e28b1 100644
--- a/Torch.Server.Tests/Torch.Server.Tests.csproj
+++ b/Torch.Server.Tests/Torch.Server.Tests.csproj
@@ -60,12 +60,10 @@
-
-
- AssemblyInfoGen.tt
- True
- True
+
+ Properties\AssemblyVersion.cs
+
@@ -90,12 +88,6 @@
-
-
- TextTemplatingFileGenerator
- AssemblyInfoGen.cs
-
-
\ No newline at end of file
diff --git a/Torch.Server/Properties/AssemblyInfoGen.tt b/Torch.Server/Properties/AssemblyInfoGen.tt
deleted file mode 100644
index 4cb8d7e..0000000
--- a/Torch.Server/Properties/AssemblyInfoGen.tt
+++ /dev/null
@@ -1,12 +0,0 @@
-<#@ template debug="false" hostspecific="false" language="C#" #>
-<#@ output extension=".cs" #>
-using System.Reflection;
-
-<# var dt = DateTime.UtcNow;
- int major = 1;
- int minor = 1;
- int build = dt.DayOfYear;
- int rev = (int)dt.TimeOfDay.TotalMinutes / 2;
-#>
-[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
-[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
\ No newline at end of file
diff --git a/Torch.Server/Torch.Server.csproj b/Torch.Server/Torch.Server.csproj
index 1ce4b21..fbfab75 100644
--- a/Torch.Server/Torch.Server.csproj
+++ b/Torch.Server/Torch.Server.csproj
@@ -187,14 +187,12 @@
+
+ Properties\AssemblyVersion.cs
+
-
- True
- True
- AssemblyInfoGen.tt
-
@@ -361,12 +359,6 @@
-
-
- TextTemplatingFileGenerator
- AssemblyInfoGen.cs
-
-
diff --git a/Torch.Tests/Properties/AssemblyInfoGen.tt b/Torch.Tests/Properties/AssemblyInfoGen.tt
deleted file mode 100644
index 4069a38..0000000
--- a/Torch.Tests/Properties/AssemblyInfoGen.tt
+++ /dev/null
@@ -1,12 +0,0 @@
-<#@ template debug="false" hostspecific="false" language="C#" #>
-<#@ output extension=".cs" #>
-using System.Reflection;
-
-<# var dt = DateTime.UtcNow;
- int major = 1;
- int minor = 0;
- int build = dt.DayOfYear;
- int rev = (int)dt.TimeOfDay.TotalMinutes / 2;
-#>
-[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
-[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
\ No newline at end of file
diff --git a/Torch.Tests/Torch.Tests.csproj b/Torch.Tests/Torch.Tests.csproj
index 02fad1d..fc5f81a 100644
--- a/Torch.Tests/Torch.Tests.csproj
+++ b/Torch.Tests/Torch.Tests.csproj
@@ -60,12 +60,10 @@
-
-
- AssemblyInfoGen.tt
- True
- True
+
+ Properties\AssemblyVersion.cs
+
@@ -85,12 +83,6 @@
-
-
- TextTemplatingFileGenerator
- AssemblyInfoGen.cs
-
-
diff --git a/Torch.sln b/Torch.sln
index d99ed03..a1a48ba 100644
--- a/Torch.sln
+++ b/Torch.sln
@@ -22,6 +22,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Torch.Server.Tests", "Torch
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Torch.Client.Tests", "Torch.Client.Tests\Torch.Client.Tests.csproj", "{632E78C0-0DAC-4B71-B411-2F1B333CC310}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Versioning", "Versioning", "{762F6A0D-55EF-4173-8CDE-309D183F40C4}"
+ ProjectSection(SolutionItems) = preProject
+ Versioning\AssemblyVersion.cs = Versioning\AssemblyVersion.cs
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -60,6 +65,9 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {762F6A0D-55EF-4173-8CDE-309D183F40C4} = {7AD02A71-1D4C-48F9-A8C1-789A5512424F}
+ EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB51D91F-958D-4B63-A897-3C40642ACD3E}
EndGlobalSection
diff --git a/Torch/Properties/AssemblyInfoGen.tt b/Torch/Properties/AssemblyInfoGen.tt
deleted file mode 100644
index 4069a38..0000000
--- a/Torch/Properties/AssemblyInfoGen.tt
+++ /dev/null
@@ -1,12 +0,0 @@
-<#@ template debug="false" hostspecific="false" language="C#" #>
-<#@ output extension=".cs" #>
-using System.Reflection;
-
-<# var dt = DateTime.UtcNow;
- int major = 1;
- int minor = 0;
- int build = dt.DayOfYear;
- int rev = (int)dt.TimeOfDay.TotalMinutes / 2;
-#>
-[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
-[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= build #>.<#= rev #>")]
\ No newline at end of file
diff --git a/Torch/Torch.csproj b/Torch/Torch.csproj
index 2d4d9d2..77002b8 100644
--- a/Torch/Torch.csproj
+++ b/Torch/Torch.csproj
@@ -149,16 +149,14 @@
+
+ Properties\AssemblyVersion.cs
+
-
- AssemblyInfoGen.tt
- True
- True
-
@@ -222,12 +220,6 @@
Designer
-
-
- TextTemplatingFileGenerator
- AssemblyInfoGen.cs
-
-
diff --git a/Torch/TorchBase.cs b/Torch/TorchBase.cs
index b038b72..3a40a23 100644
--- a/Torch/TorchBase.cs
+++ b/Torch/TorchBase.cs
@@ -53,7 +53,13 @@ namespace Torch
///
public ITorchConfig Config { get; protected set; }
///
- public Version TorchVersion { get; protected set; }
+ public Version TorchVersion { get; }
+
+ ///
+ /// The version of Torch used, with extra data.
+ ///
+ public string TorchVersionVerbose { get; }
+
///
public Version GameVersion { get; private set; }
///
@@ -107,7 +113,8 @@ namespace Torch
Instance = this;
- TorchVersion = Assembly.GetExecutingAssembly().GetName().Version;
+ TorchVersion = Assembly.GetExecutingAssembly().GetName().Version;
+ TorchVersionVerbose = Assembly.GetEntryAssembly().GetCustomAttribute()?.InformationalVersion ?? TorchVersion.ToString();
RunArgs = new string[0];
Managers = new DependencyManager();
@@ -156,7 +163,7 @@ namespace Torch
{
callback?.Invoke(SaveGameStatus.GameNotReady);
}
- else if(MyAsyncSaving.InProgress)
+ else if (MyAsyncSaving.InProgress)
{
callback?.Invoke(SaveGameStatus.SaveInProgress);
}
@@ -245,11 +252,11 @@ namespace Torch
SpaceEngineersGame.SetupBasicGameInfo();
SpaceEngineersGame.SetupPerGameSettings();
- TorchVersion = Assembly.GetEntryAssembly().GetName().Version;
+ Debug.Assert(MyPerGameSettings.BasicGameInfo.GameVersion != null, "MyPerGameSettings.BasicGameInfo.GameVersion != null");
GameVersion = new Version(new MyVersion(MyPerGameSettings.BasicGameInfo.GameVersion.Value).FormattedText.ToString().Replace("_", "."));
- var verInfo = $"{Config.InstanceName} - Torch {TorchVersion}, SE {GameVersion}";
- try { Console.Title = verInfo; }
- catch {
+ try { Console.Title = $"{Config.InstanceName} - Torch {TorchVersion}, SE {GameVersion}"; }
+ catch
+ {
///Running as service
}
@@ -258,7 +265,8 @@ namespace Torch
#else
Log.Info("RELEASE");
#endif
- Log.Info(verInfo);
+ Log.Info($"Torch Version: {TorchVersionVerbose}");
+ Log.Info($"Game Version: {GameVersion}");
Log.Info($"Executing assembly: {Assembly.GetEntryAssembly().FullName}");
Log.Info($"Executing directory: {AppDomain.CurrentDomain.BaseDirectory}");
@@ -317,19 +325,19 @@ namespace Torch
///
public virtual void Start()
{
-
+
}
///
public virtual void Stop()
{
-
+
}
///
public virtual void Restart()
{
-
+
}
///
@@ -347,7 +355,7 @@ namespace Torch
///
public virtual void Update()
{
- Plugins.UpdatePlugins();
+ GetManager().UpdatePlugins();
}
}
}
diff --git a/Versioning/AssemblyVersion.cs b/Versioning/AssemblyVersion.cs
new file mode 100644
index 0000000..c663bea
--- /dev/null
+++ b/Versioning/AssemblyVersion.cs
@@ -0,0 +1,4 @@
+using System.Reflection;
+
+[assembly: AssemblyVersion("0.0.0.0")]
+[assembly: AssemblyInformationalVersion("v0.0.0-dev")]
diff --git a/Versioning/version.ps1 b/Versioning/version.ps1
new file mode 100644
index 0000000..2e624b4
--- /dev/null
+++ b/Versioning/version.ps1
@@ -0,0 +1,20 @@
+$gitVersion = git describe --tags
+$gitSimpleVersion = git describe --tags --abbrev=0
+if ($gitSimpleVersion.Equals($gitVersion)) {
+ $buildSalt = 0
+} else {
+ $gitLatestCommit = git rev-parse --short HEAD
+ $buildSalt = [System.Numerics.BigInteger]::Abs([System.Numerics.BigInteger]::Parse($gitLatestCommit, [System.Globalization.NumberStyles]::HexNumber) % 16383) + 1
+}
+$dotNetVersion = echo $gitSimpleVersion | Select-String -Pattern "([0-9]+)\.([0-9]+)\.([0-9]+)" | % {$_.Matches} | %{$_.Groups[1].Value+"."+$_.Groups[2].Value+"."+$_.Groups[3].Value+".$buildSalt"}
+
+$fileContent = @"
+using System.Reflection;
+
+[assembly: AssemblyVersion("$dotNetVersion")]
+[assembly: AssemblyInformationalVersion("$gitVersion")]
+"@
+
+echo $fileContent | Set-Content "$PSScriptRoot/AssemblyVersion.cs"
+
+echo "$gitVersion / $dotNetVersion"
\ No newline at end of file