diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Run/DotNetCoreRunnerTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Run/DotNetCoreRunnerTests.cs
index be93b54247..7d9cc3da70 100644
--- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Run/DotNetCoreRunnerTests.cs
+++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Run/DotNetCoreRunnerTests.cs
@@ -73,12 +73,12 @@ public void Should_Add_Path_Arguments()
// Given
var fixture = new DotNetCoreRunnerFixture();
fixture.Project = "./tools/tool/";
- fixture.Arguments = "--args";
+ fixture.Arguments = "--args=\"value\"";
// When
var result = fixture.Run();
// Then
- Assert.Equal("run --project \"./tools/tool/\" -- \"--args\"", result.Args);
+ Assert.Equal("run --project \"./tools/tool/\" -- --args=\"value\"", result.Args);
}
[Fact]
diff --git a/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs b/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs
index 83418801c1..f22a7bf9eb 100644
--- a/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs
+++ b/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs
@@ -55,7 +55,7 @@ public static void DotNetCoreExecute(this ICakeContext context, FilePath assembl
[CakeMethodAlias]
[CakeAliasCategory("Execute")]
[CakeNamespaceImport("Cake.Common.Tools.DotNetCore.Execute")]
- public static void DotNetCoreExecute(this ICakeContext context, FilePath assemblyPath, string arguments)
+ public static void DotNetCoreExecute(this ICakeContext context, FilePath assemblyPath, ProcessArgumentBuilder arguments)
{
context.DotNetCoreExecute(assemblyPath, arguments, null);
}
@@ -80,7 +80,7 @@ public static void DotNetCoreExecute(this ICakeContext context, FilePath assembl
[CakeMethodAlias]
[CakeAliasCategory("Execute")]
[CakeNamespaceImport("Cake.Common.Tools.DotNetCore.Execute")]
- public static void DotNetCoreExecute(this ICakeContext context, FilePath assemblyPath, string arguments, DotNetCoreSettings settings)
+ public static void DotNetCoreExecute(this ICakeContext context, FilePath assemblyPath, ProcessArgumentBuilder arguments, DotNetCoreSettings settings)
{
if (context == null)
{
@@ -363,7 +363,7 @@ public static void DotNetCoreRun(this ICakeContext context, string project)
[CakeMethodAlias]
[CakeAliasCategory("Run")]
[CakeNamespaceImport("Cake.Common.Tools.DotNetCore.Run")]
- public static void DotNetCoreRun(this ICakeContext context, string project, string arguments)
+ public static void DotNetCoreRun(this ICakeContext context, string project, ProcessArgumentBuilder arguments)
{
context.DotNetCoreRun(project, arguments, null);
}
@@ -389,7 +389,7 @@ public static void DotNetCoreRun(this ICakeContext context, string project, stri
[CakeMethodAlias]
[CakeAliasCategory("Run")]
[CakeNamespaceImport("Cake.Common.Tools.DotNetCore.Run")]
- public static void DotNetCoreRun(this ICakeContext context, string project, string arguments, DotNetCoreRunSettings settings)
+ public static void DotNetCoreRun(this ICakeContext context, string project, ProcessArgumentBuilder arguments, DotNetCoreRunSettings settings)
{
if (context == null)
{
diff --git a/src/Cake.Common/Tools/DotNetCore/Execute/DotNetCoreExecutor.cs b/src/Cake.Common/Tools/DotNetCore/Execute/DotNetCoreExecutor.cs
index 0f10631814..2e65b154a0 100644
--- a/src/Cake.Common/Tools/DotNetCore/Execute/DotNetCoreExecutor.cs
+++ b/src/Cake.Common/Tools/DotNetCore/Execute/DotNetCoreExecutor.cs
@@ -34,7 +34,7 @@ public DotNetCoreExecutor(
/// The assembly path.
/// The arguments.
/// The settings.
- public void Execute(FilePath assemblyPath, string arguments, DotNetCoreSettings settings)
+ public void Execute(FilePath assemblyPath, ProcessArgumentBuilder arguments, DotNetCoreSettings settings)
{
if (assemblyPath == null)
{
@@ -48,16 +48,16 @@ public void Execute(FilePath assemblyPath, string arguments, DotNetCoreSettings
Run(settings, GetArguments(assemblyPath, arguments, settings));
}
- private ProcessArgumentBuilder GetArguments(FilePath assemblyPath, string arguments, DotNetCoreSettings settings)
+ private ProcessArgumentBuilder GetArguments(FilePath assemblyPath, ProcessArgumentBuilder arguments, DotNetCoreSettings settings)
{
var builder = CreateArgumentBuilder(settings);
assemblyPath = assemblyPath.IsRelative ? assemblyPath.MakeAbsolute(_environment) : assemblyPath;
builder.Append(assemblyPath.FullPath);
- if (!string.IsNullOrEmpty(arguments))
+ if (!arguments.IsNullOrEmpty())
{
- builder.Append(arguments);
+ arguments.CopyTo(builder);
}
return builder;
diff --git a/src/Cake.Common/Tools/DotNetCore/Run/DotNetCoreRunner.cs b/src/Cake.Common/Tools/DotNetCore/Run/DotNetCoreRunner.cs
index 78718d233b..f5a5d30415 100644
--- a/src/Cake.Common/Tools/DotNetCore/Run/DotNetCoreRunner.cs
+++ b/src/Cake.Common/Tools/DotNetCore/Run/DotNetCoreRunner.cs
@@ -31,7 +31,7 @@ public DotNetCoreRunner(
/// The target project path.
/// The arguments.
/// The settings.
- public void Run(string project, string arguments, DotNetCoreRunSettings settings)
+ public void Run(string project, ProcessArgumentBuilder arguments, DotNetCoreRunSettings settings)
{
if (settings == null)
{
@@ -41,7 +41,7 @@ public void Run(string project, string arguments, DotNetCoreRunSettings settings
Run(settings, GetArguments(project, arguments, settings));
}
- private ProcessArgumentBuilder GetArguments(string project, string arguments, DotNetCoreRunSettings settings)
+ private ProcessArgumentBuilder GetArguments(string project, ProcessArgumentBuilder arguments, DotNetCoreRunSettings settings)
{
var builder = CreateArgumentBuilder(settings);
@@ -68,10 +68,11 @@ private ProcessArgumentBuilder GetArguments(string project, string arguments, Do
builder.Append(settings.Configuration);
}
- if (!string.IsNullOrEmpty(arguments))
+ // Arguments
+ if (!arguments.IsNullOrEmpty())
{
builder.Append("--");
- builder.AppendQuoted(arguments);
+ arguments.CopyTo(builder);
}
return builder;
diff --git a/src/Cake.Core/Extensions/ProcessArgumentListExtensions.cs b/src/Cake.Core/Extensions/ProcessArgumentListExtensions.cs
index 0daae556e8..5981f03373 100644
--- a/src/Cake.Core/Extensions/ProcessArgumentListExtensions.cs
+++ b/src/Cake.Core/Extensions/ProcessArgumentListExtensions.cs
@@ -380,5 +380,15 @@ public static ProcessArgumentBuilder AppendQuotedSecret(this ProcessArgumentBuil
}
return builder;
}
+
+ ///
+ /// Indicates whether a is null or renders empty.
+ ///
+ /// The builder.
+ ///
+ public static bool IsNullOrEmpty(this ProcessArgumentBuilder builder)
+ {
+ return builder == null || builder.IsEmpty();
+ }
}
}
diff --git a/src/Cake.Core/IO/ProcessArgumentBuilder.cs b/src/Cake.Core/IO/ProcessArgumentBuilder.cs
index 0143045a89..cf616d1948 100644
--- a/src/Cake.Core/IO/ProcessArgumentBuilder.cs
+++ b/src/Cake.Core/IO/ProcessArgumentBuilder.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cake.Core.IO.Arguments;
@@ -82,6 +83,32 @@ public string FilterUnsafe(string source)
sb => sb.ToString());
}
+ ///
+ /// Copies all the arhuments of the current to target .
+ ///
+ /// The copy target.
+ public void CopyTo(ProcessArgumentBuilder target)
+ {
+ if (target == null)
+ {
+ throw new ArgumentNullException("target");
+ }
+
+ foreach (var token in _tokens)
+ {
+ target.Append(token);
+ }
+ }
+
+ ///
+ /// Indicating whether current renders empty.
+ ///
+ /// A .
+ public bool IsEmpty()
+ {
+ return _tokens.Count == 0 || string.IsNullOrEmpty(Render());
+ }
+
///
/// Performs an implicit conversion from to .
///