Using WriteCodeFragment MSBuild Task

2019-01-29 05:12发布

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条回答
迷人小祖宗
2楼-- · 2019-01-29 06:07

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>
查看更多
登录 后发表回答