Skip to content

Commit

Permalink
Merge pull request #200 from StevenLiekens/taskRecoveryModes
Browse files Browse the repository at this point in the history
Improve MSBuild error handling for 'RecoveryMode'
  • Loading branch information
ferventcoder committed Jul 14, 2015
2 parents 3705b95 + 5341a90 commit a55a790
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
32 changes: 25 additions & 7 deletions product/roundhouse.tasks/Roundhouse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,28 @@
using infrastructure.app.logging;
using infrastructure.containers;
using infrastructure.filesystem;
using infrastructure.logging;

using Microsoft.Build.Framework;
using migrators;

using Microsoft.Build.Utilities;

using resolvers;
using runners;
using Environment = environments.Environment;
using Logger = roundhouse.infrastructure.logging.Logger;

public sealed class Roundhouse : ITask, ConfigurationPropertyHolder
{
private RecoveryMode recoveryMode;

private readonly TaskLoggingHelper loggingHelper;

public Roundhouse()
{
this.loggingHelper = new TaskLoggingHelper(this);
}

#region MSBuild

public IBuildEngine BuildEngine { get; set; }
Expand All @@ -30,7 +41,7 @@ public sealed class Roundhouse : ITask, ConfigurationPropertyHolder
bool ITask.Execute()
{
run_the_task();
return true;
return !this.loggingHelper.HasLoggedErrors;
}

#endregion
Expand Down Expand Up @@ -63,7 +74,7 @@ bool ITask.Execute()

public string RunAfterCreateDatabaseFolderName { get; set; }

public string RunBeforeUpFolderName { get; set; }
public string RunBeforeUpFolderName { get; set; }

public string UpFolderName { get; set; }

Expand Down Expand Up @@ -142,12 +153,14 @@ public string RecoveryMode
set
{
RecoveryMode result;
if (!Enum.TryParse(value, true, out result))
if (Enum.TryParse(value, true, out result))
{
throw new ArgumentOutOfRangeException("value", value, "The value of 'RecoveryMode' must be one of these values: 'NoChange', 'Simple' or 'Full'.");
this.recoveryMode = result;
}
else
{
this.loggingHelper.LogError("The value of 'RecoveryMode' must be one of these values: 'NoChange', 'Simple' or 'Full'. Actual value was '{0}'.", value);
}

this.recoveryMode = result;
}
}

Expand All @@ -174,6 +187,11 @@ public string RecoveryMode

public void run_the_task()
{
if (this.loggingHelper.HasLoggedErrors)
{
return;
}

Log4NetAppender.configure_without_console();
ApplicationConfiguraton.set_defaults_if_properties_are_not_set(this);

Expand Down
1 change: 1 addition & 0 deletions product/roundhouse.tasks/roundhouse.tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<Reference Include="Microsoft.Build.Framework">
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Build.Utilities.v4.0" />
<Reference Include="NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\NHibernate.3.3.2.4000\lib\Net35\NHibernate.dll</HintPath>
Expand Down

0 comments on commit a55a790

Please sign in to comment.