我正在尝试从 MSBuild 中的文件中读取版本号:
<ItemGroup>
<VersionFile Include="Properties\VERSION" />
</ItemGroup>
<Target Name="BeforeBuild">
<ReadLinesFromFile File="@(VersionFile)">
<Output TaskParameter="Lines" ItemName="VersionNumber" />
</ReadLinesFromFile>
</Target>
我只需要这个文件的第一行。如何将该值与 中的另一个字符串连接起来WriteLinesToFile
?这不起作用:
<WriteLinesToFile
File="$(AssemblyVersionFile)"
Lines="[assembly: AssemblyVersion("@(VersionNumber)")]" />
我收到一个错误:
错误 MSB4012:无法在此上下文中使用表达式“[assembly: AssemblyVersion("@(VersionNumber)")]”。项目列表不能与需要项目列表的其他字符串连接。使用分号分隔多个项目列表。`