diff --git a/build/build.ps1 b/build/build.ps1 index 8548cbb1ac..1066c62876 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -43,14 +43,6 @@ $release = "" + $semver.Major + "." + $semver.Minor + "." + $semver.Patch - Write-Host "Update UmbracoVersion.cs" - $this.ReplaceFileText("$($this.SolutionRoot)\src\Umbraco.Core\Configuration\UmbracoVersion.cs", ` - "(\d+)\.(\d+)\.(\d+)(.(\d+))?", ` - "$release") - $this.ReplaceFileText("$($this.SolutionRoot)\src\Umbraco.Core\Configuration\UmbracoVersion.cs", ` - "CurrentComment => `"(.+)`"", ` - "CurrentComment => `"$($semver.PreRelease)`"") - Write-Host "Update IIS Express port in csproj" $updater = New-Object "Umbraco.Build.ExpressPortUpdater" $csproj = "$($this.SolutionRoot)\src\Umbraco.Web.UI\Umbraco.Web.UI.csproj" @@ -69,7 +61,7 @@ $global:node_nodepath = $this.ClearEnvVar("NODEPATH") $global:node_npmcache = $this.ClearEnvVar("NPM_CONFIG_CACHE") $global:node_npmprefix = $this.ClearEnvVar("NPM_CONFIG_PREFIX") - + # https://github.com/gruntjs/grunt-contrib-connect/issues/235 $this.SetEnvVar("NODE_NO_HTTP2", "1") }) @@ -81,7 +73,7 @@ $this.SetEnvVar("NODEPATH", $node_nodepath) $this.SetEnvVar("NPM_CONFIG_CACHE", $node_npmcache) $this.SetEnvVar("NPM_CONFIG_PREFIX", $node_npmprefix) - + $ignore = $this.ClearEnvVar("NODE_NO_HTTP2") }) @@ -434,7 +426,7 @@ Write-Host "Prepare Azure Gallery" $this.CopyFile("$($this.SolutionRoot)\build\Azure\azuregalleryrelease.ps1", $this.BuildOutput) }) - + $ubuild.DefineMethod("Build", { $error.Clear() diff --git a/src/Umbraco.Core/Configuration/UmbracoVersion.cs b/src/Umbraco.Core/Configuration/UmbracoVersion.cs index 46ad221837..73df566a0f 100644 --- a/src/Umbraco.Core/Configuration/UmbracoVersion.cs +++ b/src/Umbraco.Core/Configuration/UmbracoVersion.cs @@ -10,37 +10,61 @@ namespace Umbraco.Core.Configuration /// public static class UmbracoVersion { - // BEWARE! - // This class is parsed and updated by the build scripts. - // Do NOT modify it unless you understand what you are doing. + static UmbracoVersion() + { + var umbracoCoreAssembly = typeof(UmbracoVersion).Assembly; + + // gets the value indicated by the AssemblyVersion attribute + AssemblyVersion = umbracoCoreAssembly.GetName().Version; + + // gets the value indicated by the AssemblyFileVersion attribute + AssemblyFileVersion = System.Version.Parse(umbracoCoreAssembly.GetCustomAttribute().Version); + + // gets the value indicated by the AssemblyInformationalVersion attribute + // this is the true semantic version of the Umbraco Cms + SemanticVersion = SemVersion.Parse(umbracoCoreAssembly.GetCustomAttribute().InformationalVersion); + + // gets the non-semantic version + Current = SemanticVersion.GetVersion(3); + } /// - /// Gets the version of the executing code. + /// Gets the non-semantic version of the Umbraco code. /// - public static Version Current { get; } = new Version("8.0.0"); + // TODO rename to Version + public static Version Current { get; } /// - /// Gets the version comment of the executing code (eg "beta"). + /// Gets the semantic version comments of the Umbraco code. /// - public static string CurrentComment => "alpha.52"; + public static string Comment => SemanticVersion.Prerelease; /// - /// Gets the assembly version of Umbraco.Code.dll. + /// Gets the assembly version of the Umbraco code. /// - /// Get it by looking at a class in that dll, due to medium trust issues, - /// see http://haacked.com/archive/2010/11/04/assembly-location-and-medium-trust.aspx, - /// however fixme we don't support medium trust anymore? - public static string AssemblyVersion => new AssemblyName(typeof(UmbracoVersion).Assembly.FullName).Version.ToString(); + /// + /// The assembly version is the value of the . + /// Is is the one that the CLR checks for compatibility. Therefore, it changes only on + /// hard-breaking changes (for instance, on new major versions). + /// + public static Version AssemblyVersion {get; } /// - /// Gets the semantic version of the executing code. + /// Gets the assembly file version of the Umbraco code. /// - public static SemVersion SemanticVersion { get; } = new SemVersion( - Current.Major, - Current.Minor, - Current.Build, - CurrentComment.IsNullOrWhiteSpace() ? null : CurrentComment, - Current.Revision > 0 ? Current.Revision.ToInvariantString() : null); + /// + /// The assembly version is the value of the . + /// + public static Version AssemblyFileVersion { get; } + + /// + /// Gets the semantic version of the Umbraco code. + /// + /// + /// The semantic version is the value of the . + /// It is the full version of Umbraco, including comments. + /// + public static SemVersion SemanticVersion { get; } /// /// Gets the "local" version of the site. @@ -51,7 +75,7 @@ namespace Umbraco.Core.Configuration /// and changes during an upgrade. The executing code version changes when new code is /// deployed. The site/files version changes during an upgrade. /// - public static SemVersion Local + public static SemVersion LocalVersion { get { diff --git a/src/Umbraco.Core/Runtime/CoreRuntime.cs b/src/Umbraco.Core/Runtime/CoreRuntime.cs index 04eaba3f9a..a8cf18cd23 100644 --- a/src/Umbraco.Core/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Core/Runtime/CoreRuntime.cs @@ -246,7 +246,7 @@ namespace Umbraco.Core.Runtime private void SetRuntimeStateLevel(IUmbracoDatabaseFactory databaseFactory, ILogger logger) { - var localVersion = UmbracoVersion.Local; // the local, files, version + var localVersion = UmbracoVersion.LocalVersion; // the local, files, version var codeVersion = _state.SemanticVersion; // the executing code version var connect = false; diff --git a/src/Umbraco.Core/RuntimeState.cs b/src/Umbraco.Core/RuntimeState.cs index 0177619a68..4f6f56531b 100644 --- a/src/Umbraco.Core/RuntimeState.cs +++ b/src/Umbraco.Core/RuntimeState.cs @@ -55,7 +55,7 @@ namespace Umbraco.Core /// /// Gets the version comment of the executing code. /// - public string VersionComment => UmbracoVersion.CurrentComment; + public string VersionComment => UmbracoVersion.Comment; /// /// Gets the semantic version of the executing code. diff --git a/src/Umbraco.Core/Services/Implement/KeyValueService.cs b/src/Umbraco.Core/Services/Implement/KeyValueService.cs index e0d78b0258..b30543ed48 100644 --- a/src/Umbraco.Core/Services/Implement/KeyValueService.cs +++ b/src/Umbraco.Core/Services/Implement/KeyValueService.cs @@ -40,7 +40,7 @@ namespace Umbraco.Core.Services.Implement // if already running 8, either following an upgrade or an install, // then everything should be ok (the table should exist, etc) - if (UmbracoVersion.Local.Major >= 8) + if (UmbracoVersion.LocalVersion.Major >= 8) return; // else we are upgrading from 7, we can assume that the locks table @@ -197,7 +197,7 @@ namespace Umbraco.Core.Services.Implement internal static string GetValue(IUmbracoDatabase database, string key) { // not 8 yet = no key/value table, no value - if (UmbracoVersion.Local.Major < 8) + if (UmbracoVersion.LocalVersion.Major < 8) return null; var sql = database.SqlContext.Sql() diff --git a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs index 98114f0664..23d8e2cc4e 100644 --- a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs +++ b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs @@ -423,7 +423,13 @@ namespace Umbraco.Web.Editors { var app = new Dictionary { - {"assemblyVersion", UmbracoVersion.AssemblyVersion} + // add versions - see UmbracoVersion for details & differences + + // the complete application version (eg "8.1.2-alpha.25") + { "version", _runtimeState.SemanticVersion.ToSemanticString() }, // fixme that's UmbracoVersion.Version! + + // the assembly version (eg "8.0.0") + { "assemblyVersion", UmbracoVersion.AssemblyVersion.ToString() } }; var version = _runtimeState.SemanticVersion.ToSemanticString(); @@ -431,8 +437,6 @@ namespace Umbraco.Web.Editors //the value is the hash of the version, cdf version and the configured state app.Add("cacheBuster", $"{version}.{_runtimeState.Level}.{ClientDependencySettings.Instance.Version}".GenerateHash()); - app.Add("version", version); - //useful for dealing with virtual paths on the client side when hosted in virtual directories especially app.Add("applicationPath", _httpContext.Request.ApplicationPath.EnsureEndsWith('/')); diff --git a/src/Umbraco.Web/Editors/UpdateCheckController.cs b/src/Umbraco.Web/Editors/UpdateCheckController.cs index 6096c6988e..8960d2ab89 100644 --- a/src/Umbraco.Web/Editors/UpdateCheckController.cs +++ b/src/Umbraco.Web/Editors/UpdateCheckController.cs @@ -26,7 +26,7 @@ namespace Umbraco.Web.Editors var result = check.CheckUpgrade(UmbracoVersion.Current.Major, UmbracoVersion.Current.Minor, UmbracoVersion.Current.Build, - UmbracoVersion.CurrentComment); + UmbracoVersion.Comment); return new UpgradeCheckResponse(result.UpgradeType.ToString(), result.Comment, result.UpgradeUrl); } diff --git a/src/Umbraco.Web/Install/InstallHelper.cs b/src/Umbraco.Web/Install/InstallHelper.cs index 476f23ea8e..22087861d1 100644 --- a/src/Umbraco.Web/Install/InstallHelper.cs +++ b/src/Umbraco.Web/Install/InstallHelper.cs @@ -110,7 +110,7 @@ namespace Umbraco.Web.Install UmbracoVersion.Current.Major, UmbracoVersion.Current.Minor, UmbracoVersion.Current.Build, - UmbracoVersion.CurrentComment, + UmbracoVersion.Comment, errorMsg, userAgent, dbProvider); diff --git a/src/Umbraco.Web/Install/InstallSteps/UpgradeStep.cs b/src/Umbraco.Web/Install/InstallSteps/UpgradeStep.cs index 7d47139721..7ed3de6471 100644 --- a/src/Umbraco.Web/Install/InstallSteps/UpgradeStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/UpgradeStep.cs @@ -24,7 +24,7 @@ namespace Umbraco.Web.Install.InstallSteps // that was a "normal" way to force the upgrader to execute, and we would detect the current // version via the DB like DatabaseSchemaResult.DetermineInstalledVersion - magic, do we really // need this now? - var currentVersion = (UmbracoVersion.Local ?? new Semver.SemVersion(0)).ToString(); + var currentVersion = (UmbracoVersion.LocalVersion ?? new Semver.SemVersion(0)).ToString(); var newVersion = UmbracoVersion.SemanticVersion.ToString();