Cosmos/source/Cosmos.Build.Builder/BuildTasks/MSBuildTargetBuildTaskBase.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

47 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using Cosmos.Build.Builder.Services;
namespace Cosmos.Build.Builder.BuildTasks
{
internal abstract class MSBuildTargetBuildTaskBase : ProcessBuildTaskBase
{
public abstract string ProjectFilePath { get; }
public abstract IEnumerable<string> Targets { get; }
protected abstract IReadOnlyDictionary<string, string> Properties { get; }
private IMSBuildService _msBuildService;
protected MSBuildTargetBuildTaskBase(IMSBuildService msBuildService)
: base(true, false)
{
_msBuildService = msBuildService;
}
protected override string GetExePath() => _msBuildService.GetMSBuildExePath();
protected override string GetArguments()
{
if (ProjectFilePath == null)
{
throw new InvalidOperationException("ProjectFilePath is null!");
}
var args = $"\"{ProjectFilePath}\" /nologo /maxcpucount /nodeReuse:False /verbosity:minimal /t:\"{String.Join(";", Targets)}\"";
if (Properties != null)
{
foreach (var property in Properties)
{
args += $" /p:\"{property.Key}={property.Value}\"";
}
}
args += " /p:DeployExtension=False";
return args;
}
}
}