diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs
index fc72ea5674..aae174106e 100644
--- a/src/Umbraco.Core/ApplicationContext.cs
+++ b/src/Umbraco.Core/ApplicationContext.cs
@@ -243,7 +243,7 @@ namespace Umbraco.Core
try
{
var configStatus = ConfigurationStatus;
- var currentVersion = UmbracoVersion.Current.ToString(3);
+ var currentVersion = UmbracoVersion.GetSemanticVersion();
var ok = configStatus == currentVersion;
if (ok)
@@ -252,7 +252,7 @@ namespace Umbraco.Core
// if we have a db context available, if we don't then we are not installed anyways
if (DatabaseContext.IsDatabaseConfigured && DatabaseContext.CanConnect)
{
- var found = Services.MigrationEntryService.FindEntry(GlobalSettings.UmbracoMigrationName, UmbracoVersion.Current);
+ var found = Services.MigrationEntryService.FindEntry(GlobalSettings.UmbracoMigrationName, UmbracoVersion.GetSemanticVersion());
if (found == null)
{
//we haven't executed this migration in this environment, so even though the config versions match,
diff --git a/src/Umbraco.Core/Configuration/GlobalSettings.cs b/src/Umbraco.Core/Configuration/GlobalSettings.cs
index 0df43b67c7..329fa598c1 100644
--- a/src/Umbraco.Core/Configuration/GlobalSettings.cs
+++ b/src/Umbraco.Core/Configuration/GlobalSettings.cs
@@ -421,14 +421,15 @@ namespace Umbraco.Core.Configuration
/// Gets a value indicating whether the current version of umbraco is configured.
///
/// true if configured; otherwise, false.
- public static bool Configured
+ [Obsolete("Do not use this, it is no longer in use and will be removed from the codebase in future versions")]
+ internal static bool Configured
{
get
{
try
{
string configStatus = ConfigurationStatus;
- string currentVersion = UmbracoVersion.Current.ToString(3);
+ string currentVersion = UmbracoVersion.GetSemanticVersion().ToString();
if (currentVersion != configStatus)
@@ -595,10 +596,7 @@ namespace Umbraco.Core.Configuration
[Obsolete("Use Umbraco.Core.Configuration.UmbracoVersion.Current instead", false)]
public static string CurrentVersion
{
- get
- {
- return UmbracoVersion.Current.ToString(3);
- }
+ get { return UmbracoVersion.GetSemanticVersion().ToString(); }
}
///
diff --git a/src/Umbraco.Core/Configuration/UmbracoVersion.cs b/src/Umbraco.Core/Configuration/UmbracoVersion.cs
index c4b31b8a7f..de1fcd02bf 100644
--- a/src/Umbraco.Core/Configuration/UmbracoVersion.cs
+++ b/src/Umbraco.Core/Configuration/UmbracoVersion.cs
@@ -1,5 +1,6 @@
using System;
using System.Reflection;
+using Semver;
namespace Umbraco.Core.Configuration
{
@@ -28,5 +29,15 @@ namespace Umbraco.Core.Configuration
// Get the version of the umbraco.dll by looking at a class in that dll
// Had to do it like this due to medium trust issues, see: http://haacked.com/archive/2010/11/04/assembly-location-and-medium-trust.aspx
public static string AssemblyVersion { get { return new AssemblyName(typeof(ActionsResolver).Assembly.FullName).Version.ToString(); } }
+
+ public static SemVersion GetSemanticVersion()
+ {
+ return new SemVersion(
+ Current.Major,
+ Current.Minor,
+ Current.Build,
+ CurrentComment.IsNullOrWhiteSpace() ? null : CurrentComment,
+ Current.Revision > 0 ? Current.Revision.ToInvariantString() : null);
+ }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/DatabaseContext.cs b/src/Umbraco.Core/DatabaseContext.cs
index 4186eb0d73..a1513ad4fb 100644
--- a/src/Umbraco.Core/DatabaseContext.cs
+++ b/src/Umbraco.Core/DatabaseContext.cs
@@ -6,6 +6,7 @@ using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Xml.Linq;
+using Semver;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
@@ -636,7 +637,7 @@ namespace Umbraco.Core
var schemaResult = ValidateDatabaseSchema();
- var installedSchemaVersion = schemaResult.DetermineInstalledVersion();
+ var installedSchemaVersion = new SemVersion(schemaResult.DetermineInstalledVersion());
var installedMigrationVersion = schemaResult.DetermineInstalledVersionByMigrations(migrationEntryService);
var targetVersion = UmbracoVersion.Current;
@@ -644,10 +645,10 @@ namespace Umbraco.Core
//In some cases - like upgrading from 7.2.6 -> 7.3, there will be no migration information in the database and therefore it will
// return a version of 0.0.0 and we don't necessarily want to run all migrations from 0 -> 7.3, so we'll just ensure that the
// migrations are run for the target version
- if (installedMigrationVersion == new Version(0, 0, 0) && installedSchemaVersion > new Version(0, 0, 0))
+ if (installedMigrationVersion == new SemVersion(new Version(0, 0, 0)) && installedSchemaVersion > new SemVersion(new Version(0, 0, 0)))
{
//set the installedMigrationVersion to be one less than the target so the latest migrations are guaranteed to execute
- installedMigrationVersion = targetVersion.SubtractRevision();
+ installedMigrationVersion = new SemVersion(targetVersion.SubtractRevision());
}
//DO the upgrade!
@@ -656,10 +657,11 @@ namespace Umbraco.Core
//Take the minimum version between the detected schema version and the installed migration version
? new[] {installedSchemaVersion, installedMigrationVersion}.Min()
//Take the minimum version between the installed migration version and the version specified in the config
- : new[] { new Version(GlobalSettings.ConfigurationStatus), installedMigrationVersion }.Min();
+ : new[] { SemVersion.Parse(GlobalSettings.ConfigurationStatus), installedMigrationVersion }.Min();
+
+
+ var runner = new MigrationRunner(migrationEntryService, _logger, currentVersion, UmbracoVersion.GetSemanticVersion(), GlobalSettings.UmbracoMigrationName);
-
- var runner = new MigrationRunner(migrationEntryService, _logger, currentVersion, targetVersion, GlobalSettings.UmbracoMigrationName);
var upgraded = runner.Execute(database, true);
message = message + "Upgrade completed!
";
diff --git a/src/Umbraco.Core/Events/MigrationEventArgs.cs b/src/Umbraco.Core/Events/MigrationEventArgs.cs
index c6da480999..61fa016332 100644
--- a/src/Umbraco.Core/Events/MigrationEventArgs.cs
+++ b/src/Umbraco.Core/Events/MigrationEventArgs.cs
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
+using Semver;
using Umbraco.Core.Persistence.Migrations;
namespace Umbraco.Core.Events
@@ -13,11 +15,20 @@ namespace Umbraco.Core.Events
///
///
///
+ public MigrationEventArgs(IList eventObject, SemVersion configuredVersion, SemVersion targetVersion, bool canCancel)
+ : base(eventObject, canCancel)
+ {
+ ConfiguredSemVersion = configuredVersion;
+ TargetSemVersion = targetVersion;
+ }
+
+ [Obsolete("Use constructor accepting UmbracoVersion instances instead")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
public MigrationEventArgs(IList eventObject, Version configuredVersion, Version targetVersion, bool canCancel)
: base(eventObject, canCancel)
{
- ConfiguredVersion = configuredVersion;
- TargetVersion = targetVersion;
+ ConfiguredSemVersion = new SemVersion(configuredVersion);
+ TargetSemVersion = new SemVersion(targetVersion);
}
///
@@ -28,12 +39,12 @@ namespace Umbraco.Core.Events
///
///
///
- internal MigrationEventArgs(IList eventObject, MigrationContext migrationContext, Version configuredVersion, Version targetVersion, bool canCancel)
+ internal MigrationEventArgs(IList eventObject, MigrationContext migrationContext, SemVersion configuredVersion, SemVersion targetVersion, bool canCancel)
: base(eventObject, canCancel)
{
MigrationContext = migrationContext;
- ConfiguredVersion = configuredVersion;
- TargetVersion = targetVersion;
+ ConfiguredSemVersion = configuredVersion;
+ TargetSemVersion = targetVersion;
}
///
@@ -42,11 +53,20 @@ namespace Umbraco.Core.Events
///
///
///
+ public MigrationEventArgs(IList eventObject, SemVersion configuredVersion, SemVersion targetVersion)
+ : base(eventObject)
+ {
+ ConfiguredSemVersion = configuredVersion;
+ TargetSemVersion = targetVersion;
+ }
+
+ [Obsolete("Use constructor accepting UmbracoVersion instances instead")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
public MigrationEventArgs(IList eventObject, Version configuredVersion, Version targetVersion)
: base(eventObject)
{
- ConfiguredVersion = configuredVersion;
- TargetVersion = targetVersion;
+ ConfiguredSemVersion = new SemVersion(configuredVersion);
+ TargetSemVersion = new SemVersion(targetVersion);
}
///
@@ -57,9 +77,23 @@ namespace Umbraco.Core.Events
get { return EventObject; }
}
- public Version ConfiguredVersion { get; private set; }
+ [Obsolete("Use ConfiguredUmbracoVersion instead")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Version ConfiguredVersion
+ {
+ get { return ConfiguredSemVersion.GetVersion(); }
+ }
- public Version TargetVersion { get; private set; }
+ [Obsolete("Use TargetUmbracoVersion instead")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Version TargetVersion
+ {
+ get { return TargetSemVersion.GetVersion(); }
+ }
+
+ public SemVersion ConfiguredSemVersion { get; private set; }
+
+ public SemVersion TargetSemVersion { get; private set; }
internal MigrationContext MigrationContext { get; private set; }
}
diff --git a/src/Umbraco.Core/Models/IMigrationEntry.cs b/src/Umbraco.Core/Models/IMigrationEntry.cs
index 0eb45394c4..65bb7bc1f3 100644
--- a/src/Umbraco.Core/Models/IMigrationEntry.cs
+++ b/src/Umbraco.Core/Models/IMigrationEntry.cs
@@ -1,4 +1,5 @@
using System;
+using Semver;
using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models
@@ -6,6 +7,6 @@ namespace Umbraco.Core.Models
public interface IMigrationEntry : IAggregateRoot, IRememberBeingDirty
{
string MigrationName { get; set; }
- Version Version { get; set; }
+ SemVersion Version { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Models/MigrationEntry.cs b/src/Umbraco.Core/Models/MigrationEntry.cs
index fa41346b86..e756e92629 100644
--- a/src/Umbraco.Core/Models/MigrationEntry.cs
+++ b/src/Umbraco.Core/Models/MigrationEntry.cs
@@ -1,5 +1,6 @@
using System;
using System.Reflection;
+using Semver;
using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models
@@ -10,7 +11,7 @@ namespace Umbraco.Core.Models
{
}
- public MigrationEntry(int id, DateTime createDate, string migrationName, Version version)
+ public MigrationEntry(int id, DateTime createDate, string migrationName, SemVersion version)
{
Id = id;
CreateDate = createDate;
@@ -19,9 +20,9 @@ namespace Umbraco.Core.Models
}
private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo(x => x.MigrationName);
- private static readonly PropertyInfo VersionSelector = ExpressionHelper.GetPropertyInfo(x => x.Version);
+ private static readonly PropertyInfo VersionSelector = ExpressionHelper.GetPropertyInfo(x => x.Version);
private string _migrationName;
- private Version _version;
+ private SemVersion _version;
public string MigrationName
{
@@ -36,7 +37,7 @@ namespace Umbraco.Core.Models
}
}
- public Version Version
+ public SemVersion Version
{
get { return _version; }
set
diff --git a/src/Umbraco.Core/Persistence/DatabaseSchemaHelper.cs b/src/Umbraco.Core/Persistence/DatabaseSchemaHelper.cs
index fbc5285767..ca64775880 100644
--- a/src/Umbraco.Core/Persistence/DatabaseSchemaHelper.cs
+++ b/src/Umbraco.Core/Persistence/DatabaseSchemaHelper.cs
@@ -81,7 +81,7 @@ namespace Umbraco.Core.Persistence
creation.InitializeDatabaseSchema();
//Now ensure to cretae the tag in the db for the current migration version
- migrationEntryService.CreateEntry(GlobalSettings.UmbracoMigrationName, UmbracoVersion.Current);
+ migrationEntryService.CreateEntry(GlobalSettings.UmbracoMigrationName, UmbracoVersion.GetSemanticVersion());
_logger.Info("Finalized database schema creation");
}
diff --git a/src/Umbraco.Core/Persistence/Factories/MigrationEntryFactory.cs b/src/Umbraco.Core/Persistence/Factories/MigrationEntryFactory.cs
index 712acdfabe..1cb7000293 100644
--- a/src/Umbraco.Core/Persistence/Factories/MigrationEntryFactory.cs
+++ b/src/Umbraco.Core/Persistence/Factories/MigrationEntryFactory.cs
@@ -1,4 +1,5 @@
using System;
+using Semver;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Rdbms;
@@ -8,10 +9,10 @@ namespace Umbraco.Core.Persistence.Factories
{
public MigrationEntry BuildEntity(MigrationDto dto)
{
- Version parsed;
- if (Version.TryParse(dto.Version, out parsed) == false)
+ SemVersion parsed;
+ if (SemVersion.TryParse(dto.Version, out parsed) == false)
{
- throw new FormatException("Cannot parse the version string in the database to a real Version object: " + dto.Version);
+ throw new FormatException("Cannot parse the version string in the database to a SemVersion object: " + dto.Version);
}
var model = new MigrationEntry(dto.Id, dto.CreateDate, dto.Name, parsed);
diff --git a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaResult.cs b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaResult.cs
index bd99799e11..04d6598d4b 100644
--- a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaResult.cs
+++ b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaResult.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using Semver;
using Umbraco.Core.Configuration;
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
using Umbraco.Core.Persistence.SqlSyntax;
@@ -40,12 +41,12 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
///
///
///
- public Version DetermineInstalledVersionByMigrations(IMigrationEntryService migrationEntryService)
+ public SemVersion DetermineInstalledVersionByMigrations(IMigrationEntryService migrationEntryService)
{
var allMigrations = migrationEntryService.GetAll(GlobalSettings.UmbracoMigrationName);
var mostrecent = allMigrations.OrderByDescending(x => x.Version).Select(x => x.Version).FirstOrDefault();
- return mostrecent ?? new Version(0, 0, 0);
+ return mostrecent ?? new SemVersion(new Version(0, 0, 0));
}
///
diff --git a/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs b/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs
index 412d97617c..5a379e061b 100644
--- a/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs
+++ b/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Semver;
using Umbraco.Core.Events;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence.Migrations.Syntax.IfDatabase;
@@ -16,8 +17,8 @@ namespace Umbraco.Core.Persistence.Migrations
{
private readonly IMigrationEntryService _migrationEntryService;
private readonly ILogger _logger;
- private readonly Version _currentVersion;
- private readonly Version _targetVersion;
+ private readonly SemVersion _currentVersion;
+ private readonly SemVersion _targetVersion;
private readonly string _productName;
private readonly IMigration[] _migrations;
@@ -35,12 +36,12 @@ namespace Umbraco.Core.Persistence.Migrations
[Obsolete("Use the ctor that specifies all dependencies instead")]
public MigrationRunner(ILogger logger, Version currentVersion, Version targetVersion, string productName, params IMigration[] migrations)
- : this(ApplicationContext.Current.Services.MigrationEntryService, logger, currentVersion, targetVersion, productName, migrations)
+ : this(ApplicationContext.Current.Services.MigrationEntryService, logger, new SemVersion(currentVersion), new SemVersion(targetVersion), productName, migrations)
{
}
- public MigrationRunner(IMigrationEntryService migrationEntryService, ILogger logger, Version currentVersion, Version targetVersion, string productName, params IMigration[] migrations)
+ public MigrationRunner(IMigrationEntryService migrationEntryService, ILogger logger, SemVersion currentVersion, SemVersion targetVersion, string productName, params IMigration[] migrations)
{
if (migrationEntryService == null) throw new ArgumentNullException("migrationEntryService");
if (logger == null) throw new ArgumentNullException("logger");
@@ -127,16 +128,22 @@ namespace Umbraco.Core.Persistence.Migrations
public IEnumerable OrderedUpgradeMigrations(IEnumerable foundMigrations)
{
var migrations = (from migration in foundMigrations
- let migrationAttributes = migration.GetType().GetCustomAttributes(false)
- from migrationAttribute in migrationAttributes
- where migrationAttribute != null
- where migrationAttribute.TargetVersion > _currentVersion &&
- migrationAttribute.TargetVersion <= _targetVersion &&
- migrationAttribute.ProductName == _productName &&
- //filter if the migration specifies a minimum current version for which to execute
- (migrationAttribute.MinimumCurrentVersion == null || _currentVersion >= migrationAttribute.MinimumCurrentVersion)
- orderby migrationAttribute.TargetVersion, migrationAttribute.SortOrder ascending
- select migration).Distinct();
+ let migrationAttributes = migration.GetType().GetCustomAttributes(false)
+ from migrationAttribute in migrationAttributes
+ where migrationAttribute != null
+ let migrationInfo = new
+ {
+ attribute = migrationAttribute,
+ targetVersion = new SemVersion(migrationAttribute.TargetVersion),
+ minVersion = new SemVersion(migrationAttribute.MinimumCurrentVersion)
+ }
+ where migrationInfo.targetVersion > _currentVersion &&
+ migrationInfo.targetVersion <= _targetVersion &&
+ migrationAttribute.ProductName == _productName &&
+ //filter if the migration specifies a minimum current version for which to execute
+ (migrationAttribute.MinimumCurrentVersion == null || _currentVersion >= migrationInfo.minVersion)
+ orderby migrationAttribute.TargetVersion, migrationAttribute.SortOrder ascending
+ select migration).Distinct();
return migrations;
}
@@ -148,17 +155,23 @@ namespace Umbraco.Core.Persistence.Migrations
public IEnumerable OrderedDowngradeMigrations(IEnumerable foundMigrations)
{
var migrations = (from migration in foundMigrations
- let migrationAttributes = migration.GetType().GetCustomAttributes(false)
- from migrationAttribute in migrationAttributes
- where migrationAttribute != null
- where
- migrationAttribute.TargetVersion > _currentVersion &&
- migrationAttribute.TargetVersion <= _targetVersion &&
+ let migrationAttributes = migration.GetType().GetCustomAttributes(false)
+ from migrationAttribute in migrationAttributes
+ where migrationAttribute != null
+ let migrationInfo = new
+ {
+ attribute = migrationAttribute,
+ targetVersion = new SemVersion(migrationAttribute.TargetVersion),
+ minVersion = new SemVersion(migrationAttribute.MinimumCurrentVersion)
+ }
+ where
+ migrationInfo.targetVersion > _currentVersion &&
+ migrationInfo.targetVersion <= _targetVersion &&
migrationAttribute.ProductName == _productName &&
//filter if the migration specifies a minimum current version for which to execute
- (migrationAttribute.MinimumCurrentVersion == null || _currentVersion >= migrationAttribute.MinimumCurrentVersion)
- orderby migrationAttribute.TargetVersion, migrationAttribute.SortOrder descending
- select migration).Distinct();
+ (migrationAttribute.MinimumCurrentVersion == null || _currentVersion >= migrationInfo.minVersion)
+ orderby migrationAttribute.TargetVersion, migrationAttribute.SortOrder descending
+ select migration).Distinct();
return migrations;
}
diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/AddMigrationTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/AddMigrationTable.cs
new file mode 100644
index 0000000000..21540afb14
--- /dev/null
+++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/AddMigrationTable.cs
@@ -0,0 +1,43 @@
+using System.Linq;
+using Umbraco.Core.Configuration;
+using Umbraco.Core.Logging;
+using Umbraco.Core.Persistence.DatabaseModelDefinitions;
+using Umbraco.Core.Persistence.SqlSyntax;
+
+namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZero
+{
+ [Migration("7.3.0", 11, GlobalSettings.UmbracoMigrationName)]
+ public class AddMigrationTable : MigrationBase
+ {
+ public AddMigrationTable(ISqlSyntaxProvider sqlSyntax, ILogger logger)
+ : base(sqlSyntax, logger)
+ {
+ }
+
+ public override void Up()
+ {
+ //Don't exeucte if the table is already there
+ var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray();
+ if (tables.InvariantContains("umbracoMigration")) return;
+
+ Create.Table("umbracoMigration")
+ .WithColumn("id").AsInt32().NotNullable().PrimaryKey("PK_umbracoMigrations")
+ .WithColumn("name").AsString(255).NotNullable()
+ .WithColumn("version").AsString(50).NotNullable()
+ .WithColumn("createDate").AsDateTime().NotNullable().WithDefault(SystemMethods.CurrentDateTime);
+
+ //unique constraint on name + version
+ Create.Index("IX_umbracoMigration").OnTable("umbracoMigration")
+ .OnColumn("name").Ascending()
+ .OnColumn("version").Ascending()
+ .WithOptions()
+ .NonClustered()
+ .WithOptions()
+ .Unique();
+ }
+
+ public override void Down()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMigrationEntryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMigrationEntryRepository.cs
index 3128a0f9e4..0189923e21 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMigrationEntryRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMigrationEntryRepository.cs
@@ -1,10 +1,11 @@
using System;
+using Semver;
using Umbraco.Core.Models;
namespace Umbraco.Core.Persistence.Repositories
{
public interface IMigrationEntryRepository : IRepositoryQueryable
{
- IMigrationEntry FindEntry(string migrationName, Version version);
+ IMigrationEntry FindEntry(string migrationName, SemVersion version);
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Persistence/Repositories/MigrationEntryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MigrationEntryRepository.cs
index 9952155757..19df777666 100644
--- a/src/Umbraco.Core/Persistence/Repositories/MigrationEntryRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/MigrationEntryRepository.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Semver;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Rdbms;
@@ -113,7 +114,7 @@ namespace Umbraco.Core.Persistence.Repositories
entity.ResetDirtyProperties();
}
- public IMigrationEntry FindEntry(string migrationName, Version version)
+ public IMigrationEntry FindEntry(string migrationName, SemVersion version)
{
var versionString = version.ToString();
diff --git a/src/Umbraco.Core/Services/IMigrationEntryService.cs b/src/Umbraco.Core/Services/IMigrationEntryService.cs
index 29984cf1c5..2ba3fec157 100644
--- a/src/Umbraco.Core/Services/IMigrationEntryService.cs
+++ b/src/Umbraco.Core/Services/IMigrationEntryService.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using Semver;
using Umbraco.Core.Models;
namespace Umbraco.Core.Services
@@ -12,7 +13,7 @@ namespace Umbraco.Core.Services
///
///
///
- IMigrationEntry CreateEntry(string migrationName, Version version);
+ IMigrationEntry CreateEntry(string migrationName, SemVersion version);
///
/// Finds a migration by name and version, returns null if not found
@@ -20,7 +21,7 @@ namespace Umbraco.Core.Services
///
///
///
- IMigrationEntry FindEntry(string migrationName, Version version);
+ IMigrationEntry FindEntry(string migrationName, SemVersion version);
///
/// Gets all entries for a given migration name
diff --git a/src/Umbraco.Core/Services/MigrationEntryService.cs b/src/Umbraco.Core/Services/MigrationEntryService.cs
index 32e5e408cb..6d441b5271 100644
--- a/src/Umbraco.Core/Services/MigrationEntryService.cs
+++ b/src/Umbraco.Core/Services/MigrationEntryService.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Semver;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence;
@@ -25,7 +26,7 @@ namespace Umbraco.Core.Services
///
///
///
- public IMigrationEntry CreateEntry(string migrationName, Version version)
+ public IMigrationEntry CreateEntry(string migrationName, SemVersion version)
{
var entry = new MigrationEntry
{
@@ -49,7 +50,7 @@ namespace Umbraco.Core.Services
///
///
///
- public IMigrationEntry FindEntry(string migrationName, Version version)
+ public IMigrationEntry FindEntry(string migrationName, SemVersion version)
{
var uow = UowProvider.GetUnitOfWork();
using (var repo = RepositoryFactory.CreateMigrationEntryRepository(uow))
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index c3cc462faf..efcf4b6144 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -95,6 +95,9 @@
..\packages\Owin.1.0\lib\net40\Owin.dll
+
+ ..\packages\semver.1.1.2\lib\net45\Semver.dll
+
@@ -374,6 +377,7 @@
+
diff --git a/src/Umbraco.Core/VersionExtensions.cs b/src/Umbraco.Core/VersionExtensions.cs
index 9d60c308cf..e49fbb9c19 100644
--- a/src/Umbraco.Core/VersionExtensions.cs
+++ b/src/Umbraco.Core/VersionExtensions.cs
@@ -1,11 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Semver;
namespace Umbraco.Core
{
internal static class VersionExtensions
{
+ public static Version GetVersion(this SemVersion semVersion)
+ {
+ int build = 0;
+ int.TryParse(semVersion.Build, out build);
+
+ return new Version(semVersion.Major, semVersion.Minor, semVersion.Patch, build);
+ }
+
public static Version SubtractRevision(this Version version)
{
var parts = new List(new[] {version.Major, version.Minor, version.Build, version.Revision});
diff --git a/src/Umbraco.Core/packages.config b/src/Umbraco.Core/packages.config
index 845e979242..6ffcf860e6 100644
--- a/src/Umbraco.Core/packages.config
+++ b/src/Umbraco.Core/packages.config
@@ -17,6 +17,7 @@
+
\ No newline at end of file
diff --git a/src/Umbraco.Tests/ApplicationContextTests.cs b/src/Umbraco.Tests/ApplicationContextTests.cs
index 66f48d1d28..60eecce81d 100644
--- a/src/Umbraco.Tests/ApplicationContextTests.cs
+++ b/src/Umbraco.Tests/ApplicationContextTests.cs
@@ -2,6 +2,7 @@ using System;
using System.Configuration;
using Moq;
using NUnit.Framework;
+using Semver;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
@@ -19,10 +20,10 @@ namespace Umbraco.Tests
[Test]
public void Is_Configured()
{
- ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", UmbracoVersion.Current.ToString(3));
+ ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", UmbracoVersion.GetSemanticVersion().ToString());
var migrationEntryService = new Mock();
- migrationEntryService.Setup(x => x.FindEntry(It.IsAny(), It.IsAny()))
+ migrationEntryService.Setup(x => x.FindEntry(It.IsAny(), It.IsAny()))
.Returns(Mock.Of());
var dbCtx = new Mock(Mock.Of(), Mock.Of(), new SqlCeSyntaxProvider(), "test");
@@ -41,10 +42,10 @@ namespace Umbraco.Tests
[Test]
public void Is_Not_Configured_By_Migration_Not_Found()
{
- ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", UmbracoVersion.Current.ToString(3));
+ ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", UmbracoVersion.GetSemanticVersion().ToString());
var migrationEntryService = new Mock();
- migrationEntryService.Setup(x => x.FindEntry(It.IsAny(), It.IsAny()))
+ migrationEntryService.Setup(x => x.FindEntry(It.IsAny(), It.IsAny()))
.Returns((IMigrationEntry)null);
var dbCtx = new Mock(Mock.Of(), Mock.Of(), new SqlCeSyntaxProvider(), "test");
@@ -63,7 +64,7 @@ namespace Umbraco.Tests
[Test]
public void Is_Not_Configured_By_Configuration()
{
- ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", new Version(UmbracoVersion.Current.Major - 1, 0, 0).ToString());
+ ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", new SemVersion(UmbracoVersion.Current.Major - 1, 0, 0).ToString());
var migrationEntryService = new Mock();
@@ -83,7 +84,7 @@ namespace Umbraco.Tests
[Test]
public void Is_Not_Configured_By_Database_Not_Configured()
{
- ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", new Version(UmbracoVersion.Current.Major - 1, 0, 0).ToString());
+ ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", new SemVersion(UmbracoVersion.Current.Major - 1, 0, 0).ToString());
var migrationEntryService = new Mock();
@@ -103,7 +104,7 @@ namespace Umbraco.Tests
[Test]
public void Is_Not_Configured_By_Database_Cannot_Connect()
{
- ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", new Version(UmbracoVersion.Current.Major - 1, 0, 0).ToString());
+ ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", new SemVersion(UmbracoVersion.Current.Major - 1, 0, 0).ToString());
var migrationEntryService = new Mock();
diff --git a/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs b/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs
index b320c979ef..8b6b80979e 100644
--- a/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs
+++ b/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs
@@ -37,7 +37,7 @@ namespace Umbraco.Tests.Configurations
[Test]
public void Is_Version_From_Assembly_Correct()
{
- Assert.That(UmbracoVersion.Current.ToString(3), Is.EqualTo("6.0.0"));
+ Assert.That(UmbracoVersion.GetSemanticVersion(), Is.EqualTo("6.0.0"));
}
[TestCase("~/umbraco", "/", "umbraco")]
diff --git a/src/Umbraco.Tests/Migrations/MigrationRunnerTests.cs b/src/Umbraco.Tests/Migrations/MigrationRunnerTests.cs
index 3a41a849c2..4cc50a671a 100644
--- a/src/Umbraco.Tests/Migrations/MigrationRunnerTests.cs
+++ b/src/Umbraco.Tests/Migrations/MigrationRunnerTests.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Moq;
using NUnit.Framework;
+using Semver;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Migrations;
@@ -20,7 +21,7 @@ namespace Umbraco.Tests.Migrations
{
var runner = new MigrationRunner(
Mock.Of(),
- Mock.Of(), new Version(4, 0, 0), new Version(6, 0, 0), "Test");
+ Mock.Of(), new SemVersion(4, 0, 0), new SemVersion(6, 0, 0), "Test");
var migrations = runner.OrderedUpgradeMigrations(new List { new MultiMigration(new SqlCeSyntaxProvider(), Mock.Of()) });
@@ -38,7 +39,7 @@ namespace Umbraco.Tests.Migrations
{
var runner = new MigrationRunner(
Mock.Of(),
- Mock.Of(), new Version(4, 0, 0), new Version(5, 0, 0), "Test");
+ Mock.Of(), new SemVersion(4, 0, 0), new SemVersion(5, 0, 0), "Test");
var migrations = runner.OrderedUpgradeMigrations(new List { new MultiMigration(new SqlCeSyntaxProvider(), Mock.Of()) });
@@ -55,8 +56,8 @@ namespace Umbraco.Tests.Migrations
public void Executes_Migration_For_Spanning_One_Target_2()
{
var runner = new MigrationRunner(
- Mock.Of(),
- Mock.Of(), new Version(5, 0, 1), new Version(6, 0, 0), "Test");
+ Mock.Of(),
+ Mock.Of(), new SemVersion(5, 0, 1), new SemVersion(6, 0, 0), "Test");
var migrations = runner.OrderedUpgradeMigrations(new List { new MultiMigration(new SqlCeSyntaxProvider(), Mock.Of()) });
diff --git a/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs b/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs
index 440a69b9fc..8d8682ecc5 100644
--- a/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs
+++ b/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Text.RegularExpressions;
using Moq;
using NUnit.Framework;
+using Semver;
using SQLCE4Umbraco;
using Umbraco.Core;
using Umbraco.Core.Logging;
@@ -69,8 +70,8 @@ namespace Umbraco.Tests.Migrations
db.Execute(new Sql(rawStatement));
}
- var configuredVersion = new Version("4.8.0");
- var targetVersion = new Version("6.0.0");
+ var configuredVersion = new SemVersion(4, 8, 0);
+ var targetVersion = new SemVersion(6, 0, 0);
var foundMigrations = MigrationResolver.Current.Migrations;
var migrationRunner = new MigrationRunner(
diff --git a/src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs b/src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs
index b5aa33580f..3a3bbe7aa7 100644
--- a/src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs
+++ b/src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text.RegularExpressions;
using Moq;
using NUnit.Framework;
+using Semver;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
@@ -29,15 +30,15 @@ namespace Umbraco.Tests.Migrations.Upgrades
TestHelper.InitializeContentDirectories();
Path = TestHelper.CurrentAssemblyDirectory;
- AppDomain.CurrentDomain.SetData("DataDirectory", Path);
+ AppDomain.CurrentDomain.SetData("DataDirectory", Path);
DatabaseSpecificSetUp();
}
[Test]
public virtual void Can_Upgrade_From_470_To_600()
{
- var configuredVersion = new Version("4.7.0");
- var targetVersion = new Version("6.0.0");
+ var configuredVersion = new SemVersion(4, 7, 0);
+ var targetVersion = new SemVersion(6, 0, 0);
var provider = GetDatabaseProvider();
var db = GetConfiguredDatabase();
@@ -95,7 +96,7 @@ namespace Umbraco.Tests.Migrations.Upgrades
{
PluginManager.Current = null;
SqlSyntaxContext.SqlSyntaxProvider = null;
- MigrationResolver.Reset();
+ MigrationResolver.Reset();
LoggerResolver.Reset();
TestHelper.CleanContentDirectories();
diff --git a/src/Umbraco.Tests/Migrations/Upgrades/SqlCeDataUpgradeTest.cs b/src/Umbraco.Tests/Migrations/Upgrades/SqlCeDataUpgradeTest.cs
index 0d377749c3..39ff745e0c 100644
--- a/src/Umbraco.Tests/Migrations/Upgrades/SqlCeDataUpgradeTest.cs
+++ b/src/Umbraco.Tests/Migrations/Upgrades/SqlCeDataUpgradeTest.cs
@@ -1,6 +1,7 @@
using System;
using Moq;
using NUnit.Framework;
+using Semver;
using SQLCE4Umbraco;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
@@ -19,8 +20,8 @@ namespace Umbraco.Tests.Migrations.Upgrades
[Test, NUnit.Framework.Ignore]
public override void Can_Upgrade_From_470_To_600()
{
- var configuredVersion = new Version("4.11.0");
- var targetVersion = new Version("6.0.0");
+ var configuredVersion = new SemVersion(4, 11, 0);
+ var targetVersion = new SemVersion(6, 0, 0);
var provider = GetDatabaseProvider();
var db = GetConfiguredDatabase();
diff --git a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs
index 22eab68bc7..2eb59aba64 100644
--- a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs
+++ b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs
@@ -28,7 +28,7 @@ namespace Umbraco.Tests.Routing
//create the module
_module = new UmbracoModule();
- SettingsForTests.ConfigurationStatus = UmbracoVersion.Current.ToString(3);
+ SettingsForTests.ConfigurationStatus = UmbracoVersion.GetSemanticVersion().ToString();
//SettingsForTests.ReservedPaths = "~/umbraco,~/install/";
//SettingsForTests.ReservedUrls = "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd";
diff --git a/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs b/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs
index 7bd7e40e42..4c64c5eaf2 100644
--- a/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs
+++ b/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs
@@ -97,7 +97,7 @@ namespace Umbraco.Tests.TestHelpers
InitializeDatabase();
//ensure the configuration matches the current version for tests
- SettingsForTests.ConfigurationStatus = UmbracoVersion.Current.ToString(3);
+ SettingsForTests.ConfigurationStatus = UmbracoVersion.GetSemanticVersion().ToString();
}
}
diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj
index b8954e98f0..8ac904f175 100644
--- a/src/Umbraco.Tests/Umbraco.Tests.csproj
+++ b/src/Umbraco.Tests/Umbraco.Tests.csproj
@@ -97,6 +97,9 @@
False
..\packages\NUnit.2.6.2\lib\nunit.framework.dll
+
+ ..\packages\semver.1.1.2\lib\net45\Semver.dll
+
diff --git a/src/Umbraco.Tests/packages.config b/src/Umbraco.Tests/packages.config
index ed02cad2be..15de2204f7 100644
--- a/src/Umbraco.Tests/packages.config
+++ b/src/Umbraco.Tests/packages.config
@@ -20,6 +20,7 @@
+
\ No newline at end of file
diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs
index 8e3e05d100..d8ec9bc603 100644
--- a/src/Umbraco.Web/Editors/BackOfficeController.cs
+++ b/src/Umbraco.Web/Editors/BackOfficeController.cs
@@ -526,9 +526,7 @@ namespace Umbraco.Web.Editors
{"assemblyVersion", UmbracoVersion.AssemblyVersion}
};
- var version = string.IsNullOrEmpty(UmbracoVersion.CurrentComment)
- ? UmbracoVersion.Current.ToString(3)
- : string.Format("{0}-{1}", UmbracoVersion.Current.ToString(3), UmbracoVersion.CurrentComment);
+ var version = UmbracoVersion.GetSemanticVersion();
app.Add("version", version);
app.Add("cdf", ClientDependency.Core.Config.ClientDependencySettings.Instance.Version);
diff --git a/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs b/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs
index e4f18fdcab..d52579772c 100644
--- a/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs
+++ b/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs
@@ -34,7 +34,7 @@ namespace Umbraco.Web.Install.InstallSteps
DistributedCache.Instance.RefreshAllPageCache();
// Update configurationStatus
- GlobalSettings.ConfigurationStatus = UmbracoVersion.Current.ToString(3);
+ GlobalSettings.ConfigurationStatus = UmbracoVersion.GetSemanticVersion().ToString();
// Update ClientDependency version
var clientDependencyConfig = new ClientDependencyConfiguration(_applicationContext.ProfilingLogger.Logger);
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 0f1cf90ed6..110c8d017e 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -181,6 +181,10 @@
False
..\packages\Owin.1.0\lib\net40\Owin.dll
+
+ False
+ ..\packages\semver.1.1.2\lib\net45\Semver.dll
+
System
diff --git a/src/Umbraco.Web/packages.config b/src/Umbraco.Web/packages.config
index bd7a2322f7..33c259c885 100644
--- a/src/Umbraco.Web/packages.config
+++ b/src/Umbraco.Web/packages.config
@@ -25,6 +25,7 @@
+
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/about.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/about.aspx.cs
index 463361a635..37e1f6eca9 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/about.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/about.aspx.cs
@@ -14,9 +14,7 @@ namespace umbraco.dialogs
{
// Put user code to initialize the page here
thisYear.Text = DateTime.Now.Year.ToString(CultureInfo.InvariantCulture);
- version.Text = string.IsNullOrEmpty(UmbracoVersion.CurrentComment)
- ? string.Format("{0} (Assembly version: {1})", UmbracoVersion.Current.ToString(3), UmbracoVersion.AssemblyVersion)
- : string.Format("{0}-{1} (Assembly version: {2})", UmbracoVersion.Current.ToString(3), UmbracoVersion.CurrentComment, UmbracoVersion.AssemblyVersion);
+ version.Text = UmbracoVersion.GetSemanticVersion().ToString();
}
#region Web Form Designer generated code
diff --git a/src/umbraco.businesslogic/GlobalSettings.cs b/src/umbraco.businesslogic/GlobalSettings.cs
index 5084be1d0b..3d3721f783 100644
--- a/src/umbraco.businesslogic/GlobalSettings.cs
+++ b/src/umbraco.businesslogic/GlobalSettings.cs
@@ -133,6 +133,7 @@ namespace umbraco
/// Gets a value indicating whether the current version of umbraco is configured.
///
/// true if configured; otherwise, false.
+ [Obsolete("Do not use this, it is no longer in use and will be removed from the codebase in future versions")]
public static bool Configured
{
get { return Umbraco.Core.Configuration.GlobalSettings.Configured; }
@@ -316,7 +317,7 @@ namespace umbraco
[Obsolete("Use Umbraco.Core.Configuration.UmbracoVersion.Current instead", false)]
public static string VersionComment
{
- get { return Umbraco.Core.Configuration.UmbracoVersion.CurrentComment; }
+ get { return UmbracoVersion.CurrentComment; }
}