0

Note that I have already went through:

Is there a way to print a new-line when using <Message...>?

Read text file and split every line in MSBuild

But for some strange reason I can't make it work.

I have:

        <ReadLinesFromFile File="$(OutputPath)myfile.log">
            <Output PropertyName="FileOutput" TaskParameter="Lines" />
        </ReadLinesFromFile>

        <Message Text="$(FileOutput)"/>

-- This works, entire file content is shown on the screen.

Now I would like for each line in that file to report a warning/error.

    <ItemGroup>
        <SplitVersion Include="$(FileOutput.Split('%0A%0D'))"/>
    </ItemGroup>

    <Warning Text="%(SplitVersion.Identity)" /> 

Whatever combination I try in Split (e.g. \n, \r\n, %0A etc.) I get only one warning instead of getting one warning per line.

Community
  • 1
  • 1
Klark
  • 8,162
  • 3
  • 37
  • 61

1 Answers1

0

You are storing the lines in a property (typo maybe? Anyway I didn't even know was possible until now - it is also not mentioned in the documentation), store them in an item list instead and you'll get the lines, split already by ReadLinesFromFile so you don't have to bother with it, and after all that's the main way it is supposed to be used. Note the ItemName where you had PropertyName:

<ReadLinesFromFile File="$(OutputPath)myfile.log">
  <Output ItemName="FileOutput" TaskParameter="Lines" />
</ReadLinesFromFile>
<Message Text="%(FileOutput.Identity)"/>
stijn
  • 34,664
  • 13
  • 111
  • 163