如何使用AssemblyInfoTask更改程序集版本号? [英] How to change Assembly Version Number using AssemblyInfoTask?

查看:73
本文介绍了如何使用AssemblyInfoTask更改程序集版本号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

花了一段时间后,我开始尝试为所有DLL设置版本的过程自动化.

I am trying to automate the process for setting the Version for all DLL's, after spending some time I came to know the AssemblyInfo Task with which it can most likely be achieved.

所以我继续安装它,特别是版本 1.0.51130.0 .

So I went ahead and installed it, specifically version 1.0.51130.0.

安装后,我在.cspoj文件(解决方案中有35个以上的proj文件)中手动添加了AssemblyInfoTaskImport标记(通过卸载每个项目).

After Installing, I manually added the Import Tag (by unloading the each project) of AssemblyInfoTask in .cspoj files (the solution has more than 35 proj files).

<Import Project="$(MSBuildExtensionsPath)\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.Targets"/>

接下来,我修改了将安装在路径C:\Program Files\MSBuild\Microsoft\AssemblyInfoTask中的Microsoft.VersionNUmber.Target文件,并修改了以下部分:

Next I modified the Microsoft.VersionNUmber.Target file which will be installed in path: C:\Program Files\MSBuild\Microsoft\AssemblyInfoTask, and I modified the following section:

<!-- Properties for controlling the Assembly Version -->
<PropertyGroup>
    <AssemblyMajorVersion>4</AssemblyMajorVersion>
    <AssemblyMinorVersion>0</AssemblyMinorVersion>
    <AssemblyBuildNumber></AssemblyBuildNumber>
    <AssemblyRevision></AssemblyRevision>
    <AssemblyBuildNumberType>DateString</AssemblyBuildNumberType>
    <AssemblyBuildNumberFormat>01MMdd</AssemblyBuildNumberFormat>
    <AssemblyRevisionType>AutoIncrement</AssemblyRevisionType>
    <AssemblyRevisionFormat>00</AssemblyRevisionFormat>
</PropertyGroup>

<!-- Properties for controlling the Assembly File Version -->  
<PropertyGroup>
    <AssemblyFileMajorVersion>4</AssemblyFileMajorVersion>
    <AssemblyFileMinorVersion>0</AssemblyFileMinorVersion>
    <AssemblyFileBuildNumber></AssemblyFileBuildNumber>
    <AssemblyFileRevision></AssemblyFileRevision>
    <AssemblyFileBuildNumberType>DateString</AssemblyFileBuildNumberType>
    <AssemblyFileBuildNumberFormat>01MMdd</AssemblyFileBuildNumberFormat>
    <AssemblyFileRevisionType>AutoIncrement</AssemblyFileRevisionType>
    <AssemblyFileRevisionFormat>00</AssemblyFileRevisionFormat>
</PropertyGroup>

接下来,在每个项目中,将assemblyInfo.cs文件的版本设置为1.0.0.0.最后,我保存并关闭了它,重新打开了解决方案,并进行了构建.它像冠军一样!

Next I set the assemblyInfo.cs file's version to 1.0.0.0 in every project. Finally I saved and close it, reopened solution, and built. It works like a champ!

现在想要的是将版本自定义为4.0.1053.1,其中10是年份指标的一部分,即2010,53表示星期号,最后1表示修订号.

Now what want is to customize the Version to 4.0.1053.1 where 10 is the part of year indicator which is 2010 and 53 denotes the week number, at last 1 denotes revision number.

如何使用AssemblyInfo任务实现这一目标?我碰到过几篇文章,称构建扩展包中提供了新版本的AssemblyInfo任务.

How to achieve this using the AssemblyInfo Task? I came across several posts that a new version of AssemblyInfo Task is available in Build Extension Pack.

我已经安装了 MSBuild Extension Pack 2010年12月,其版本是 MSBuild Extension Pack 4.0.2.0安装程序

I have installed the MSBuild Extension Pack December 2010 and its version is MSBuild Extension Pack 4.0.2.0 Installer

推荐答案

首先..使用从每个项目链接的globalassemblyinfo.cs. 将其作为链接文件添加到每个项目. 这意味着您更新一个文件,而不是30个以上的assemblyinfo文件...然后:

First.. use a globalassemblyinfo.cs that is linked from each project. Add its as linked file to each project. This means you update one file, not 30+ assemblyinfo files...then:

使用 MSBuild.Community.Tasks ....

然后拨打电话

<AssemblyInfo CodeLanguage="CS"
         OutputFile="$(VersionFile)"
         AssemblyCompany="Company"
         AssemblyProduct="Product"
         AssemblyCopyright="Copyright © Company 2011"
         ComVisible="false"
         AssemblyVersion="$(BUILD_NUMBER)"
         AssemblyFileVersion="$(BUILD_NUMBER)" />

假设您有类似的东西:

<Import Project=".\tasks\MSBuild.Community.Tasks.Targets"/>

这篇关于如何使用AssemblyInfoTask更改程序集版本号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆