Skip to content

Commit 95e2547

Browse files
Markusdevlead
authored andcommitted
changed msbuild's withProperty to forward multiple parameters as a comma separated list
1 parent 850bdce commit 95e2547

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Cake.Common.Tests/Unit/Tools/MSBuild/MSBuildRunnerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ public void Should_Append_Property_With_Multiple_Values_To_Process_Arguments()
713713
var result = fixture.Run();
714714

715715
// Then
716-
Assert.Equal("/v:normal /p:A=B /p:A=E /p:C=D /target:Build " +
716+
Assert.Equal("/v:normal /p:A=\"B,E\" /p:C=D /target:Build " +
717717
"\"C:/Working/src/Solution.sln\"", result.Args);
718718
}
719719

src/Cake.Common/Tools/MSBuild/MSBuildRunner.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,14 @@ private static IEnumerable<string> GetPropertyArguments(IDictionary<string, ILis
275275
{
276276
foreach (var propertyKey in properties.Keys)
277277
{
278-
foreach (var propertyValue in properties[propertyKey])
278+
if (properties[propertyKey].Count > 1)
279279
{
280-
yield return string.Concat("/p:", propertyKey, "=", propertyValue.EscapeMSBuildPropertySpecialCharacters());
280+
var commaSeparatedValues = string.Join(",", properties[propertyKey].Select(x => x.EscapeMSBuildPropertySpecialCharacters()));
281+
yield return string.Concat("/p:", propertyKey, "=", '"', commaSeparatedValues, '"');
282+
}
283+
else if (properties[propertyKey].Count == 1)
284+
{
285+
yield return string.Concat("/p:", propertyKey, "=", properties[propertyKey].First().EscapeMSBuildPropertySpecialCharacters());
281286
}
282287
}
283288
}

0 commit comments

Comments
 (0)