如何使用的MSBuild社区任务库中正确设置.NET的DLL的SVN版本号如何使用、版本号、库中、正确

2023-09-03 16:47:05 作者:山山而川

我使用的是的MSBuild社区任务库,以获得当前SVN版本的集合,在我的程序集信息文件中得到修正在最后的编译的DLL。

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.

正如你所知道那么SVN版本能像28或28M - 如果有修改。如果我做一个MSBuild的消息和输出修订属性我看,我拿到修改后28M,但更新AsseblyInfo时,我只保留28中的版本号得到..?

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 ..?

我想有28M的版本号,表示使用非检查在修改建的DLL。我怎样才能得到这工作?

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

推荐答案

.NET程序集的版本号是严厉类型。他们不是任何字符串,但ushorts,这意味着他们有一个最大的65535(见文档 http://msdn.microsoft.com/en-us/library/cbf1574z.aspx )。如果您使用SVN版本(像我一样在一个点),您的构建将打破,一旦超过了神奇的数字。

.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.

一个方案我也用这表明开发人员构建与CI构建是使用版本 {}年{月} {}天{建立} 其中,内部版本号指定一个额外的编译参数。这给了我们构建的日期,以及表示如果它是一个开发版本(即最后一个组成部分是零)

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)