我正在尝试使用WriteCodeFragment
MSBuild 任务来创建AssemblyVersion
属性。我在创建属性组以正确传递ITaskItem
处理所需的数组时遇到问题。有人可以举个例子吗?
问问题
2795 次
1 回答
15
这将创建一个名为的文件BuildVersion.cs
,其AssemblyVersion
属性为123.123.123.123
. 如果OutputFile
删除,则将使用随机生成的文件名。项目名称会自动将该Compile
项目添加到编译项目(包括BuildVersion.cs
在构建中)。项目FileWrites
名称允许在清理期间删除文件。
<Target Name="BeforeBuild">
<ItemGroup>
<AssemblyAttributes Include="AssemblyVersion">
<_Parameter1>123.123.123.123</_Parameter1>
</AssemblyAttributes>
</ItemGroup>
<WriteCodeFragment AssemblyAttributes="@(AssemblyAttributes)"
Language="C#"
OutputDirectory="$(IntermediateOutputPath)"
OutputFile="BuildVersion.cs">
<Output TaskParameter="OutputFile" ItemName="Compile" />
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
</WriteCodeFragment>
</Target>
于 2010-11-29T17:11:37.373 回答