AssemblyInfo Class | MSBuild Extension Pack Help 4.0.12.0 |
This task is based on the AssemblyInfo task written by Neil Enns (http://code.msdn.microsoft.com/AssemblyInfoTaskvers). It is used here with permission.
MSBuild.ExtensionPack.FrameworkAssemblyInfo
Namespace: MSBuild.ExtensionPack.Framework
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 4.0.0.0
The AssemblyInfo type exposes the following members.
Name | Description | |
---|---|---|
AssemblyInfo |
Name | Description | |
---|---|---|
Execute |
Executes the AssemblyInfo task.
(Overrides TaskExecute.) |
Name | Description | |
---|---|---|
AssemblyBuildNumber |
The build number of the assembly.
| |
AssemblyBuildNumberFormat |
The format string to apply when converting the build number to a text string.
| |
AssemblyBuildNumberType |
The type of update to use when setting the AssemblyBuildNumber property.
| |
AssemblyCompany | The company that created the assembly. | |
AssemblyConfiguration | The configuration of the assembly. | |
AssemblyCopyright | The copyright information for the assembly. | |
AssemblyCulture | The culture information for the assembly. | |
AssemblyDelaySign | Controls delay signing of the assembly. | |
AssemblyDescription | The description of the assembly. | |
AssemblyFileBuildNumber |
The build number of the assembly file.
| |
AssemblyFileBuildNumberFormat |
The format string to apply when converting the file build number to a text string.
| |
AssemblyFileBuildNumberType |
The type of update to use when setting the AssemblyFileBuildNumber property.
| |
AssemblyFileMajorVersion |
The major version of the assembly file.
| |
AssemblyFileMinorVersion |
The minor version of the assembly file.
| |
AssemblyFileRevision |
The revision of the assembly file.
| |
AssemblyFileRevisionFormat |
The format string to apply when converting the file revision to a text string.
| |
AssemblyFileRevisionReset |
Whether the AssemblyFileRevisionNumber will be reset to 0 when a DateString or Julian BuildNumberType is used in conjunction with an AutoIncrement AssemblyRevisionType.
| |
AssemblyFileRevisionType |
The type of update to use when setting the AssemblyFileRevision property.
| |
AssemblyFileVersion |
The complete version of the assembly file.
| |
AssemblyIncludeSigningInformation | Controls whether assembly signing information is replaced in the AssemblyInfo files. | |
AssemblyInfoFiles |
Specifies the list of AssemblyInfo files the task should update.
| |
AssemblyInformationalVersion | The AssemblyInformationalVersion for the assembly. | |
AssemblyKeyFile | Specifies the key file used to sign the assembly. | |
AssemblyKeyName | Specifies the name of a key container within the CSP containing the key pair used to generate a strong name. | |
AssemblyMajorVersion |
The major version of the assembly.
| |
AssemblyMinorVersion |
The minor version of the assembly.
| |
AssemblyProduct | The product name of the assembly. | |
AssemblyRevision |
The revision of the assembly.
| |
AssemblyRevisionFormat |
The format string to apply when converting the revision to a text string.
| |
AssemblyRevisionReset |
Whether the AssemblyRevisionNumber will be reset to 0 when a DateString or Julian BuildNumberType is used in conjunction with an AutoIncrement AssemblyRevisionType.
| |
AssemblyRevisionType |
The type of update to use when setting the AssemblyRevision property.
| |
AssemblyTitle | The title of the assembly. | |
AssemblyTrademark | The trademark information for the assembly. | |
AssemblyVersion |
The complete version of the assembly.
| |
ComVisible | Specifies whether the assembly is visible to COM. | |
FirstDayOfWeek |
Set the first day of the week for IncrementMethod.YearWeekDay. Defaults to Monday
| |
Guid | The GUID for the assembly. | |
MaxAssemblyFileVersion | Returns the largest assembly file version set by the task. | |
MaxAssemblyVersion | Returns the largest assembly version set by the task. | |
PaddingCount |
Sets the number of padding digits to use, e.g. 4
| |
PaddingDigit |
Sets the padding digit to use, e.g. 0
| |
SkipVersioning |
Set to true to skip setting version information. Default is false.
| |
StartDate |
Sets the start date to use when using IncrementMethod.ElapsedDays
| |
TextEncoding |
The encoding to write the new file in. The default is UTF8
| |
UpdateAssemblyInformationalVersion | Set to true to update the AssemblyInformationalVersion. | |
UseUtc |
Set to true to use UTC Date / Time in calculations. Default is false.
|
The primary use of the AssemblyInfo task is to set assembly version numbers at build time. The typical way to use it is to add the MSBuild.ExtensionPack.VersionNumber.Targets file to your project file, and to then specify properties in your project file to control the assembly version numbers.
Version numbers are of the form A.B.C.D, where:
- A is the major version
- B is the minor version
- C is the build number
- D is the revision
Typically the major and minor versions are fixed and do not change over the course of multiple daily builds. The build number is frequently set to increment on a daily basis, either starting at 1 and continuing from there, or as some representation of the date of the build. The revision is typically used to differentiate between multiple builds on the same day, usually starting at 1 and incrementing for each build.
To get the standard Visual Studio-style version simply add the MSBuild.ExtensionPack.VersionNumber.Targets file to your project. To override the default version numbers, such as the major and minor version, you can set the appropriate properties. For more information see the AssemblyMajorVersion and AssemblyMinorVersion items.
For use with Team Foundation Server, see this blog post: Team Build and the AssemblyInfo Task
How To: Auto-Increment Version Numbers for a Project The most common way to use the AssemblyInfo task is to add a reference to the MSBuild.ExtensionPack.VersionNumber.targets file to any project file whose AssemblyInfo you want to manage.
For standard .csproj, .vbproj, and .vjsproj files do the following:
Open the project in Visual Studio 2005 Right-click on the project in Solution Explorer and select Unload Project Right-click on the project in Solution Explorer and select Edit [project file] If the AssemblyInfoTask was installed into the Global Assembly Cache add the following line at the end of the project file after the last <Import> tag:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\ExtensionPack\MSBuild.ExtensionPack.VersionNumber.targets"/>
If the AssemblyInfoTask was installed into the user's Application Data folder add the following line at the end of the project file after the last <Import> tag:
<Import Project="$(APPDATA)\Microsoft\MSBuild\ExtensionPack\MSBuild.ExtensionPack.VersionNumber.targets"/> Save and close the project file Right-click on the project in Solution Explorer and select Reload Project With these project file modifications all builds will have auto-incrementing assembly and file versions of the following format:
1.0.date.revision
For example, the first build on November 10th, 2005 will have a version number of:
1.0.51110.00
Subsequent builds on the same day will have version numbers 1.0.51110.01, 1.0.51110.02, and so on.
Note: All AssemblyInfo.* files must have have entries with a starting value of "1.0.0.0" for AssemblyVersion and AssemblyFileVersion so the AssemblyInfoTask will work correctly. If these entries are missing from the files a build error will be generated.
Overriding the Default Version Number Behaviour In some situations the desired version number behaviour may be different than the defaults offered by the MSBuild.ExtensionPack.VersionNumber.targets file.
To set the assembly and file versions to specific numbers add the appropriate property to your project file. For example, to set the major version to 8, add the following two properties:
<AssemblyMajorVersion>8</AssemblyMajorVersion>
<AssemblyFileMajorVersion>8</AssemblyFileMajorVersion>
For more information see the assembly version properties reference.
<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath> <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath> </PropertyGroup> <Import Project="$(TPath)"/> <Target Name="Default"> <ItemGroup> <AssemblyInfoFiles Include="C:\a\CommonAssemblyInfo.cs"/> <AssemblyInfoFiles1 Include="C:\a\CommonAssemblyInfo1.cs"/> <AssemblyInfoFiles2 Include="C:\a\CommonAssemblyInfo2.cs"/> </ItemGroup> <!-- Update an attribute and don't do any versioning --> <MSBuild.ExtensionPack.Framework.AssemblyInfo ComVisible="true" AssemblyInfoFiles="@(AssemblyInfoFiles)" SkipVersioning="true"/> <!-- Version using YearWeekDay and set the start of the week as a Sunday --> <MSBuild.ExtensionPack.Framework.AssemblyInfo AssemblyInfoFiles="@(AssemblyInfoFiles1)" AssemblyBuildNumberType="YearWeekDay" FirstDayOfWeek="Sunday"/> <!-- Version using the number of days elapsed since a given start date--> <MSBuild.ExtensionPack.Framework.AssemblyInfo AssemblyInfoFiles="@(AssemblyInfoFiles2)" StartDate="1 Jan 1976" AssemblyBuildNumberType="ElapsedDays"/> </Target> </Project>