Skip to content

Commit 3f00c32

Browse files
author
Jason Zhai
committed
Merge branch 'release/6.0.4xx' into release/7.0.1xx
2 parents 7405d55 + fdcbd8b commit 3f00c32

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildPropertyParser.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@ void ParseUnquotedValue() {
6565
while(TryConsume(out char? c) && c != ';') {
6666
currentValue.Append(c);
6767
}
68+
// we're either at the end or
69+
if (AtEnd()) return;
70+
// we're just past a semicolon
71+
// if semicolon, we need to check if there are any other = in the string (signifying property pairs)
72+
if (input.IndexOf('=', currentPos) != -1) {
73+
// there are more = in the string, so eject and let a new key/value pair be parsed
74+
return;
75+
} else {
76+
currentValue.Append(';');
77+
// there are no more = in the string, so consume the remainder of the string
78+
while(TryConsume(out char? c))
79+
{
80+
currentValue.Append(c);
81+
}
82+
}
6883
}
6984

7085
void ParseValue() {

src/Cli/dotnet/OptionForwardingExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public static ForwardedOption<string[]> ForwardAsProperty(this ForwardedOption<s
2222
.SetForwardingFunction((optionVals) =>
2323
optionVals
2424
.SelectMany(Microsoft.DotNet.Cli.Utils.MSBuildPropertyParser.ParseProperties)
25-
// must escape semicolon-delimited property values when forwarding them to MSBuild
26-
.Select(keyValue => $"{option.Aliases.FirstOrDefault()}:{keyValue.key}={keyValue.value.Replace(";", "%3B")}")
25+
.Select(keyValue => $"{option.Aliases.FirstOrDefault()}:{keyValue.key}={keyValue.value}")
2726
);
2827

2928
public static Option<T> ForwardAsMany<T>(this ForwardedOption<T> option, Func<T, IEnumerable<string>> format) => option.SetForwardingFunction(format);

src/Tests/dotnet.Tests/ParserTests/MSBuildArgumentCommandLineParserTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ public void MSBuildArgumentsAreForwardedCorrectly(string[] arguments, bool build
4848
[Theory]
4949
[InlineData(new string[] { "-p:teamcity_buildConfName=\"Build, Test and Publish\"" }, new string[] { "--property:teamcity_buildConfName=\"Build, Test and Publish\"" })]
5050
[InlineData(new string[] { "-p:prop1=true", "-p:prop2=false" }, new string[] { "--property:prop1=true", "--property:prop2=false" })]
51-
[InlineData(new string[] { "-p:prop1=\".;/opt/usr\"" }, new string[] { "--property:prop1=\".%3B/opt/usr\"" })]
52-
[InlineData(new string[] { "-p:prop1=true;prop2=false;prop3=\"wut\";prop4=\"1;2;3\"" }, new string[]{ "--property:prop1=true", "--property:prop2=false", "--property:prop3=\"wut\"", "--property:prop4=\"1%3B2%3B3\""})]
53-
[InlineData(new string[] { "-p:prop4=\"1;2;3\"" }, new string[]{ "--property:prop4=\"1%3B2%3B3\""})]
54-
[InlineData(new string[] { "-p:prop4=\"1 ;2 ;3 \"" }, new string[]{ "--property:prop4=\"1 %3B2 %3B3 \""})]
51+
[InlineData(new string[] { "-p:prop1=\".;/opt/usr\"" }, new string[] { "--property:prop1=\".;/opt/usr\"" })]
52+
[InlineData(new string[] { "-p:prop1=true;prop2=false;prop3=\"wut\";prop4=\"1;2;3\"" }, new string[]{ "--property:prop1=true", "--property:prop2=false", "--property:prop3=\"wut\"", "--property:prop4=\"1;2;3\""})]
53+
[InlineData(new string[] { "-p:prop4=\"1;2;3\"" }, new string[]{ "--property:prop4=\"1;2;3\""})]
54+
[InlineData(new string[] { "-p:prop4=\"1 ;2 ;3 \"" }, new string[]{ "--property:prop4=\"1 ;2 ;3 \""})]
55+
[InlineData(new string[] { "-p:RuntimeIdentifiers=linux-x64;linux-arm64" }, new string[]{ "--property:RuntimeIdentifiers=linux-x64;linux-arm64"})]
5556
public void Can_pass_msbuild_properties_safely(string[] tokens, string[] forwardedTokens) {
5657
var forwardingFunction = (CommonOptions.PropertiesOption as ForwardedOption<string[]>).GetForwardingFunction();
5758
var result = CommonOptions.PropertiesOption.Parse(tokens);

0 commit comments

Comments
 (0)