Skip to content

Commit f2a8a27

Browse files
committed
Fixed MSB4016: An item with the same key has already been added
1 parent 4221261 commit f2a8a27

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

CI.MSBuild/Initializer.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,22 +380,24 @@ protected void setCulture(IDictionary<string, string> keys)
380380
}
381381

382382
/// <summary>
383-
/// Extracts arguments by format:
383+
/// Extracts arguments using format:
384384
/// name1=value1;name2=value2;name3=value3
385385
/// http://msdn.microsoft.com/en-us/library/ms164311.aspx
386386
/// </summary>
387387
/// <param name="raw">Multiple properties separated by semicolon</param>
388388
/// <returns></returns>
389389
protected IDictionary<string, string> extractArguments(string raw)
390390
{
391-
if(String.IsNullOrEmpty(raw)) {
391+
if(string.IsNullOrWhiteSpace(raw)) {
392392
return new Dictionary<string, string>();
393393
}
394394

395395
return raw.Split(';')
396396
.Select(p => p.Split('='))
397-
.Select(p => new KeyValuePair<string, string>(p[0], (p.Length < 2)? null : p[1]))
398-
.ToDictionary(k => k.Key, v => v.Value);
397+
.GroupBy(p => p[0].Trim()) // ... /p:nowarn=1701 /p:nowarn=1702
398+
.Select(p => p.Last())
399+
.Where(p => !string.IsNullOrWhiteSpace(p[0]))
400+
.ToDictionary(p => p[0].Trim(), p => (p.Length < 2) ? null : p[1]);
399401
}
400402
}
401403
}

0 commit comments

Comments
 (0)