Cosmos/source/Cosmos.Build.Builder/BuildTasks/CreateSetupTask.cs
José Pedro f969601a53
Builder improvements.
- Added check for dependencies, which can be installed from the builder.
- Replaced CosmosTask with CosmosBuildDefinition, which is much simpler.
- The builder can be opened without any command line arguments.
- If the VS path is not specified as a command line argument, it can be selected in a dialog.
2018-03-30 19:44:19 +01:00

64 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using Cosmos.Build.Builder.Services;
namespace Cosmos.Build.Builder.BuildTasks
{
internal class CreateSetupTask : ProcessBuildTaskBase
{
public override string Name => "Create Setup";
private IInnoSetupService _innoSetupService;
private string _scriptFilePath;
private Dictionary<string, string> _defines;
public CreateSetupTask(
IInnoSetupService innoSetupService,
string scriptFilePath,
string configuration,
string releaseVersion)
: base(true, false)
{
_innoSetupService = innoSetupService;
_scriptFilePath = scriptFilePath;
_defines = new Dictionary<string, string>();
_defines.Add("BuildConfiguration", configuration);
_defines.Add("ChangeSetVersion", releaseVersion);
}
protected override string GetExePath()
{
var innoSetupInstallationPath = _innoSetupService.GetInnoSetupInstallationPath();
var innoSetupCompilerPath = Path.Combine(innoSetupInstallationPath, "ISCC.exe");
if (!File.Exists(innoSetupCompilerPath))
{
throw new InvalidOperationException("Inno Setup installation detected, but the compiler doesn't exist!");
}
return innoSetupCompilerPath;
}
protected override string GetArguments()
{
var args = $"/Q \"{_scriptFilePath}\"";
if (_defines != null)
{
foreach (var define in _defines)
{
args += $" \"/d{define.Key}={define.Value}\"";
}
}
return args;
}
}
}