Is it possible to pass a delegate to a method called via MSBuild, and if so how? #10109
-
I have the following C# code to convert a kebab case string (all lowercase, words separated via dashes) to camel case (first character of every word starts with uppercase), which I do with the following code that calls string input = "kebab-case";
var camelCased = Regex.Replace(input, "-.", m => m.Value.ToUpper().Substring(1)); // passing an anonymous delegate
Console.WriteLine(camelCased); // "kebabCase" I need to convert this code to a format that MSBuild understands so that I can execute it in an [System.Text.RegularExpressions.Regex]::Replace($input, "-.", { param($m) $m.Value.ToUpper().Substring(1) }) but the above doesn't work in MSBuild (it treats the delegate as a literal string), nor does any other variation I've tried (outputs "The expression ... cannot be evaluated"). Is this something that MSBuild even supports and if so, what's the correct syntax to use? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
No, MSBuild doesn't support any mechanism to express a method/delegate/lambda in a property function. You should probably consider putting this in an inline task. |
Beta Was this translation helpful? Give feedback.
No, MSBuild doesn't support any mechanism to express a method/delegate/lambda in a property function.
You should probably consider putting this in an inline task.