Skip to content

Commit

Permalink
Fixed setup build order.
Browse files Browse the repository at this point in the history
Now executes before the publish is executed. Also replaced throw Ex with Fail. Introduced a check if the setup was really called and Fail the flow if necessary
  • Loading branch information
zarunbal committed Feb 1, 2020
1 parent 28d118f commit e439e1a
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using static Nuke.Common.IO.TextTasks;
using static Nuke.Common.IO.CompressionTasks;
using static Nuke.GitHub.GitHubTasks;
using static Nuke.Common.ControlFlow;

[CheckBuildProjectConfigurations]
[UnsetVisualStudioEnvironmentVariables]
Expand Down Expand Up @@ -328,14 +329,15 @@ protected override void OnBuildInitialized()

Target CreateSetup => _ => _
.DependsOn(CopyFilesForSetup)
.Before(Publish)
.OnlyWhenStatic(() => Configuration == "Release")
.Executes(() =>
{
var publishCombinations =
from framework in new[] {(AbsolutePath) SpecialFolder(SpecialFolders.ProgramFilesX86), (AbsolutePath) SpecialFolder(SpecialFolders.LocalApplicationData) / "Programs"}
from version in new[] {"5", "6"}
select framework / $"Inno Setup {version}" / "iscc.exe";

bool executed = false;
foreach (var setupCombinations in publishCombinations)
{
if (!FileExists(setupCombinations))
Expand All @@ -345,8 +347,13 @@ protected override void OnBuildInitialized()
}

ExecuteInnoSetup(setupCombinations);
executed = true;
break;
}

return;
if (!executed)
{
Fail("Inno setup was not found");
}
});

Expand Down Expand Up @@ -427,14 +434,14 @@ protected override void OnBuildInitialized()
proc.StartInfo = new ProcessStartInfo("appveyor", $"PushArtifact \"{artifact}\"");
if (!proc.Start())
{
throw new Exception("Failed to start appveyor pushartifact");
Fail("Failed to start appveyor pushartifact");
}

proc.WaitForExit();

if (proc.ExitCode != 0)
{
throw new Exception($"Exit code is {proc.ExitCode}");
Fail($"Exit code is {proc.ExitCode}");
}
});
});
Expand Down Expand Up @@ -468,7 +475,7 @@ private void ExecuteInnoSetup(AbsolutePath innoPath)
proc.StartInfo = new ProcessStartInfo(innoPath, $"{SetupCommandLineParameter} \"{InnoSetupScript}\"");
if (!proc.Start())
{
throw new Exception($"Failed to start {innoPath} with \"{SetupCommandLineParameter}\" \"{InnoSetupScript}\"");
Fail($"Failed to start {innoPath} with \"{SetupCommandLineParameter}\" \"{InnoSetupScript}\"");
}

proc.WaitForExit();
Expand All @@ -477,7 +484,7 @@ private void ExecuteInnoSetup(AbsolutePath innoPath)

if (proc.ExitCode != 0)
{
throw new Exception($"Error during execution of {innoPath}, exitcode {proc.ExitCode}");
Fail($"Error during execution of {innoPath}, exitcode {proc.ExitCode}");
}
}

Expand Down

0 comments on commit e439e1a

Please sign in to comment.