本文介绍了使用AssemblyInfo自动更新多个AssemblyInfo.cs文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个AssemblyInfo.cs文件作为许多项目的一部分,在我作为TeamCity的一部分自动构建的单个解决方案中。

I've got several AssemblyInfo.cs files as part of many projects in a single solution that I'm building automatically as part of TeamCity.

msbuild脚本更可维护我想能够使用AssemblyInfo社区任务与ItemGroup例如

To make the msbuild script more maintainable I'd like to be able to use the AssemblyInfo community task in conjunction with an ItemGroup e.g.

<ItemGroup>
     <AllAssemblyInfos Include="..\**\AssemblyInfo.cs" />
</ItemGroup>

<AssemblyInfo AssemblyTitle="" AssemblyProduct="$(Product)" AssemblyCompany="$(Company)" AssemblyCopyright="$(Copyright)" 
                  ComVisible="false" CLSCompliant="false" CodeLanguage="CS" AssemblyDescription="$(Revision)$(BranchName)" 
                  AssemblyVersion="$(FullVersion)" AssemblyFileVersion="$(FullVersion)" OutputFile="@(AllAssemblyInfos)" />

因为OutputFile不能是被引用的ItemGroup,所以它无法正常工作。

Which blatently doesn't work because OutputFile cannot be a referenced ItemGroup.

任何人都知道如何使这项工作?

Anyone know how to make this work?

推荐答案

<ItemGroup>
 <AllAssemblyInfos Include="..\**\AssemblyInfo.cs" />
</ItemGroup>

<AssemblyInfo AssemblyTitle="" AssemblyProduct="$(Product)" AssemblyCompany="$(Company)" AssemblyCopyright="$(Copyright)" 
                              ComVisible="false" CLSCompliant="false" CodeLanguage="CS" AssemblyDescription="$(Revision)$(BranchName)" 
                              AssemblyVersion="$(FullVersion)" AssemblyFileVersion="$(FullVersion)" OutputFile="%(AllAssemblyInfos)" />

这会为AllAssemblyInfos中的每个条目创建一个调用。

This creates a call for every entry in AllAssemblyInfos.

也请看看这篇文章。

这篇关于使用AssemblyInfo自动更新多个AssemblyInfo.cs文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 07:16