Simplify version management, SolutionInfo is only the source now

This commit is contained in:
Stephan
2018-11-15 08:47:47 +01:00
parent bd9a67f5a9
commit 42857ebc2a
9 changed files with 61 additions and 41 deletions

View File

@@ -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()

View File

@@ -10,37 +10,61 @@ namespace Umbraco.Core.Configuration
/// </summary>
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<AssemblyFileVersionAttribute>().Version);
// gets the value indicated by the AssemblyInformationalVersion attribute
// this is the true semantic version of the Umbraco Cms
SemanticVersion = SemVersion.Parse(umbracoCoreAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion);
// gets the non-semantic version
Current = SemanticVersion.GetVersion(3);
}
/// <summary>
/// Gets the version of the executing code.
/// Gets the non-semantic version of the Umbraco code.
/// </summary>
public static Version Current { get; } = new Version("8.0.0");
// TODO rename to Version
public static Version Current { get; }
/// <summary>
/// Gets the version comment of the executing code (eg "beta").
/// Gets the semantic version comments of the Umbraco code.
/// </summary>
public static string CurrentComment => "alpha.52";
public static string Comment => SemanticVersion.Prerelease;
/// <summary>
/// Gets the assembly version of Umbraco.Code.dll.
/// Gets the assembly version of the Umbraco code.
/// </summary>
/// <remarks>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?</remarks>
public static string AssemblyVersion => new AssemblyName(typeof(UmbracoVersion).Assembly.FullName).Version.ToString();
/// <remarks>
/// <para>The assembly version is the value of the <see cref="AssemblyVersionAttribute"/>.</para>
/// <para>Is is the one that the CLR checks for compatibility. Therefore, it changes only on
/// hard-breaking changes (for instance, on new major versions).</para>
/// </remarks>
public static Version AssemblyVersion {get; }
/// <summary>
/// Gets the semantic version of the executing code.
/// Gets the assembly file version of the Umbraco code.
/// </summary>
public static SemVersion SemanticVersion { get; } = new SemVersion(
Current.Major,
Current.Minor,
Current.Build,
CurrentComment.IsNullOrWhiteSpace() ? null : CurrentComment,
Current.Revision > 0 ? Current.Revision.ToInvariantString() : null);
/// <remarks>
/// <para>The assembly version is the value of the <see cref="AssemblyFileVersionAttribute"/>.</para>
/// </remarks>
public static Version AssemblyFileVersion { get; }
/// <summary>
/// Gets the semantic version of the Umbraco code.
/// </summary>
/// <remarks>
/// <para>The semantic version is the value of the <see cref="AssemblyInformationalVersionAttribute"/>.</para>
/// <para>It is the full version of Umbraco, including comments.</para>
/// </remarks>
public static SemVersion SemanticVersion { get; }
/// <summary>
/// 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.</para>
/// </remarks>
public static SemVersion Local
public static SemVersion LocalVersion
{
get
{

View File

@@ -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;

View File

@@ -55,7 +55,7 @@ namespace Umbraco.Core
/// <summary>
/// Gets the version comment of the executing code.
/// </summary>
public string VersionComment => UmbracoVersion.CurrentComment;
public string VersionComment => UmbracoVersion.Comment;
/// <summary>
/// Gets the semantic version of the executing code.

View File

@@ -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()

View File

@@ -423,7 +423,13 @@ namespace Umbraco.Web.Editors
{
var app = new Dictionary<string, object>
{
{"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('/'));

View File

@@ -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);
}

View File

@@ -110,7 +110,7 @@ namespace Umbraco.Web.Install
UmbracoVersion.Current.Major,
UmbracoVersion.Current.Minor,
UmbracoVersion.Current.Build,
UmbracoVersion.CurrentComment,
UmbracoVersion.Comment,
errorMsg,
userAgent,
dbProvider);

View File

@@ -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();