【问题标题】:How to set the SVN version number on .NET dll using MSBuild Community Task library correctly如何正确使用 MSBuild 社区任务库在 .NET dll 上设置 SVN 版本号
【发布时间】:2011-08-23 10:44:03
【问题描述】:

我正在使用MSBuild Community Task library 获取当前 SVN 版本的集合,该集合在我的 AssemblyInfo 文件中以获取最终编译的 dll 中的修订。

如您所知,SVN 版本可能类似于“28”或“28M”——如果有修改的话。如果我执行 MSBuild 消息并输出 Revision 属性,我看到修改后我得到了 28M,但是在更新 AsseblyInfo 时,我一直在版本号中只得到 28 ..?

我想在版本号中有 28M 以表明 dll 是使用非签入修改构建的。我怎样才能让它发挥作用?

<Target Name="Compile">
<SvnVersion LocalPath="$(MSBuildProjectDirectory)" ToolPath="$(SvnTool)">
  <Output TaskParameter="Revision" PropertyName="Revision" />
</SvnVersion>

<ItemGroup>
  <AssemblyInfoFiles Include="x.a\Properties\AssemblyInfo.cs" />
  <AssemblyInfoFiles Include="x.b\Properties\AssemblyInfo.cs" />
</ItemGroup>

<FileUpdate Files="@(AssemblyInfoFiles)"
            Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
            ReplacementText="$(MajorVersion).$(MinorVersion).$(Revision).0" />

<MSBuild  Projects="$(MSBuildProjectDirectory)\ConfigExplorer.sln" Targets="Rebuild" Properties="Configuration=$(BuildType);" />

【问题讨论】:

  • 您不能将 28M 作为修订号,因为修订在版本类中声明为 intpublic int Revision { get; }。但是您可以使用例如 AssemblyInformationalVersionAttribute 属性来存储您喜欢的任何文本。

标签: .net svn msbuild


【解决方案1】:

.Net 程序集版本号是严格输入的。它们不仅仅是任何字符串,而是 ushorts,这意味着它们最多有 65535 个(参见文档http://msdn.microsoft.com/en-us/library/cbf1574z.aspx)。如果您使用 svn 修订版(就像我曾经做过的那样),一旦超过该幻数,您的构建就会中断。

我还使用的一种方案表明开发人员构建与 CI 构建是使用{year}.{month}.{day}.{build} 形式的版本,其中构建号是使用额外的构建参数指定的。这为我们提供了构建日期,并指出它是否是开发人员构建(即最后一个组件为零)

【讨论】:

猜你喜欢
  • 2012-01-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-22
  • 1970-01-01
  • 2011-01-09
  • 2011-10-03
相关资源
最近更新 更多