From d6bfc011279b915305dac09e82aded078b4881da Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 4 Mar 2020 14:53:12 -0700 Subject: [PATCH] - Adds print statement at startup to print/store full version. - Sets default versions in AssemblyInfo.cs to 0.0.0 - Updates script to modify versions based on CI pipline input --- .../Pepperdash Core/Logging/Debug.cs | 18 ++++++++++++++++- .../Properties/AssemblyInfo.cs | 14 ++++++++----- .../Properties/UpdateAssemblyVersion.ps1 | 20 ++++++++++++++----- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs index cf4d8df..81705bb 100644 --- a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs +++ b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs @@ -26,14 +26,23 @@ namespace PepperDash.Core /// public static string FileName = string.Format(@"app{0}Debug.json", InitialParametersClass.ApplicationNumber); + /// + /// The current debug level + /// public static int Level { get; private set; } + /// + /// Indicates if the configuration file should be read on next boot + /// public static bool DoNotLoadOnNextBoot { get; private set; } static DebugContextCollection Contexts; static int SaveTimeoutMs = 30000; + /// + /// Version of the assembly + /// public static string PepperDashCoreVersion { get; private set; } static CTimer SaveTimer; @@ -52,10 +61,17 @@ namespace PepperDash.Core { // Get the assembly version and print it to console and the log var version = Assembly.GetExecutingAssembly().GetName().Version; + var fullVersion = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false); + + AssemblyInformationalVersionAttribute fullVersionAtt = fullVersion[0] as AssemblyInformationalVersionAttribute; + + var msg = string.Format("[App {0}] Using PepperDash_Core v{1}", InitialParametersClass.ApplicationNumber, fullVersionAtt.InformationalVersion); + + CrestronConsole.PrintLine(msg); PepperDashCoreVersion = string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision); - var msg = string.Format("[App {0}] Using PepperDash_Core v{1}", InitialParametersClass.ApplicationNumber, PepperDashCoreVersion); + msg = string.Format("[App {0}] Using PepperDash_Core v{1}", InitialParametersClass.ApplicationNumber, PepperDashCoreVersion); CrestronConsole.PrintLine(msg); diff --git a/Pepperdash Core/Pepperdash Core/Properties/AssemblyInfo.cs b/Pepperdash Core/Pepperdash Core/Properties/AssemblyInfo.cs index e8edaf7..c78aadb 100644 --- a/Pepperdash Core/Pepperdash Core/Properties/AssemblyInfo.cs +++ b/Pepperdash Core/Pepperdash Core/Properties/AssemblyInfo.cs @@ -1,7 +1,11 @@ using System.Reflection; +using Crestron.SimplSharp.Reflection; + +[assembly: System.Reflection.AssemblyTitle("Pepperdash_Core")] +[assembly: System.Reflection.AssemblyCompany("PepperDash Technology Corporation")] +[assembly: System.Reflection.AssemblyProduct("Pepperdash_Core")] +[assembly: System.Reflection.AssemblyCopyright("Copyright © PepperDash 2019")] +[assembly: System.Reflection.AssemblyVersion("0.0.0.*")] +[assembly: System.Reflection.AssemblyInformationalVersion("0.0.0-buildType-buildNumber")] +[assembly: Crestron.SimplSharp.Reflection.AssemblyInformationalVersion("0.0.0-buildType-buildNumber")] -[assembly: AssemblyTitle("Pepperdash_Core")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Pepperdash_Core")] -[assembly: AssemblyCopyright("Copyright © PepperDash 2019")] -[assembly: AssemblyVersion("1.0.0.*")] diff --git a/Pepperdash Core/Pepperdash Core/Properties/UpdateAssemblyVersion.ps1 b/Pepperdash Core/Pepperdash Core/Properties/UpdateAssemblyVersion.ps1 index f1c6c38..396b5cf 100644 --- a/Pepperdash Core/Pepperdash Core/Properties/UpdateAssemblyVersion.ps1 +++ b/Pepperdash Core/Pepperdash Core/Properties/UpdateAssemblyVersion.ps1 @@ -1,13 +1,23 @@ function Update-SourceVersion { Param ([string]$Version) - $NewVersion = ‘AssemblyVersion("‘ + $Version + ‘.*")’; + $fullVersion = $Version + $baseVersion = [regex]::Match($Version, "(\d+.\d+.\d+).*").captures.groups[1].value + $NewAssemblyVersion = ‘AssemblyVersion("‘ + $baseVersion + ‘.*")’ + echo "AssemblyVersion = $NewAssemblyVersion" + $NewAssemblyInformationalVersion = ‘AssemblyInformationalVersion("‘ + $Version + ‘")’ + echo "AssemblyInformationalVersion = $NewAssemblyInformationalVersion" + foreach ($o in $input) - { + { Write-output $o.FullName $TmpFile = $o.FullName + “.tmp” get-content $o.FullName | - %{$_ -replace ‘AssemblyVersion\("(\d+\.\d+\.\d+)\.\*"\)’, $NewVersion } > $TmpFile + %{ + $_ -replace ‘AssemblyVersion\(".*"\)’, $NewAssemblyVersion} | + %{ + $_ -replace ‘AssemblyInformationalVersion\(".*"\)’, $NewAssemblyInformationalVersion + } > $TmpFile move-item $TmpFile $o.FullName -force } } @@ -21,10 +31,10 @@ function Update-AllAssemblyInfoFiles ( $version ) } # validate arguments -$r= [System.Text.RegularExpressions.Regex]::Match($args[0], "^\d+\.\d+\.\d+$"); +$r= [System.Text.RegularExpressions.Regex]::Match($args[0], "\d+\.\d+\.\d+.*"); if ($r.Success) { - echo "Updating Assembly Version..."; + echo "Updating Assembly Version to $args ..."; Update-AllAssemblyInfoFiles $args[0]; } else