I'm trying to read a version number from a file in MSBuild:
<ItemGroup>
<VersionFile Include="Properties\VERSION" />
</ItemGroup>
<Target Name="BeforeBuild">
<ReadLinesFromFile File="@(VersionFile)">
<Output TaskParameter="Lines" ItemName="VersionNumber" />
</ReadLinesFromFile>
</Target>
I only need the first line of this file. How can I concatenate that value with another string in WriteLinesToFile
? This does not work:
<WriteLinesToFile
File="$(AssemblyVersionFile)"
Lines="[assembly: AssemblyVersion("@(VersionNumber)")]" />
I get an error:
error MSB4012: The expression "[assembly: AssemblyVersion("@(VersionNumber)")]" cannot be used in this context. Item lists cannot be concatenated with other strings where an item list is expected. Use a semicolon to separate multiple item lists.`