如何使用 MSBuild Community Task 库正确设置 .NET dll 上的 SVN 版本号

发布于 2024-11-30 17:15:57 字数 1033 浏览 7 评论 0原文

我正在使用 MSBuild 社区任务库 来获取当前的 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);" />

I'm using the MSBuild Community Task library to get the current SVN version an set that in my AssemblyInfo files to get the revision in the final compiled dll.

As you know SVN version can then be like "28" or "28M" - if there are modifications. If i do a MSBuild message and output the Revision property I see I get a 28M after modification but when updating the AsseblyInfo I keep getting only 28 in the version number ..?

I'd like to have the 28M in the version number to indicate the dll is built using a non-check in modification. How can I get that working?

<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);" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷月断魂刀 2024-12-07 17:15:57

.Net 程序集版本号是严格键入的。它们不仅仅是任何字符串,而是 ushorts,这意味着它们的最大值为 65535(请参阅文档 http://msdn.microsoft.com/en-us/library/cbf1574z.aspx)。如果您使用 svn 修订版(就像我在某一时刻所做的那样),一旦超过该神奇数字,您的构建就会中断。

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

.Net assemblies version numbers are sternly typed. They are not just any string but ushorts which means they have a max of 65535 (see docs http://msdn.microsoft.com/en-us/library/cbf1574z.aspx). If you use the svn revision (as I did at one point) your build will break once it exceeds that magic number.

A scheme I also used that indicated developer builds vs. CI builds was to use versions in the form of {year}.{month}.{day}.{build} where the build number was specified with an extra build parameter. This gave us the date of the build, as well as indicating if it was a developer build (i.e. last component was zero)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文