I am trying to use WriteCodeFragment MSBuild task to create AssemblyVersion attribute. I'm having a a problem creating a property group to correctly pass the ITaskItem array required for processing. Can someone help with an example.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
This worked and created a BuildVersion.cs file with correct AssemblyVersion attribute of 123.123.123.123
<Target Name="BeforeBuild">
<ItemGroup>
<AssemblyAttributes Include="AssemblyVersion">
<_Parameter1>123.132.123.123</_Parameter1>
</AssemblyAttributes>
</ItemGroup>
<WriteCodeFragment AssemblyAttributes="@(AssemblyAttributes)"
Language="C#"
OutputDirectory="$(IntermediateOutputPath)">
<Output TaskParameter="OutputFile" ItemName="Compile" />
</WriteCodeFragment>
</Target>