Other questions (MSBUILD Splitting text file into lines) mention implementation-specific alternatives, but none seem to directly address how to split a simple string property into an item group based on endlines.
How can you do this? Attempts that didn't work:
<ItemGroup> <SplitLines Include="$(SourceString.Split('\r\n'))" /> </ItemGroup>: (splits on'r'or'n')<ItemGroup> <SplitLines Include="$(SourceString.Split('%0A%0D'))" /> </ItemGroup>: (doesn't split at all)
In case you're curious: SourceString is the output of an Exec command that needs splitting, so ReadLinesFromFile isn't an option. It can't output to an intermediary file because file systems are slow and this needs to be used by build processes that care about file operations.