msbuildmsbuild-taskmsbuild-propertygroup

MSbuild, How to access project property value in Inline Task code?


I have inline Task code written in csharp

I wonder if there is anyway to access propect property in inline Task code

For ex. I am trying to replace string match with project property value. is it possible?

<![CDATA[
      MatchCollection matches = Regex.Matches(SourceStr, Pattern);

      for (int i = 0; i < matches.Count; i++)
           // replace the match value with project property... possible?


    ]]>

Solution

  • Pass it as a parameter, like you would with a compiled task?

    <ParameterGroup>
        <Foo ParameterType="System.Bar" Required="true" />
    <ParameterGroup>
    

    Edit: Looks like simple inline tokens work too.

    <![CDATA[
        Console.WriteLine("$(Foo)");
    ]]>