且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MSBUILD将文本文件分成几行

更新时间:2023-08-28 15:31:10

您正在将行存储在属性中(可能是打字错误?无论如何,直到现在我什至都不知道有可能-文档),而是将其存储在项目列表中, ,已经由ReadLinesFromFile进行了拆分,因此您不必理会它,毕竟这是应该使用它的主要方式.注意您在PropertyName所在的ItemName:

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)"/>