SqlVersion Class

MSBuild Extension Pack

SqlVersion Class MSBuild Extension Pack Help 4.0.12.0
The SqlVersion task provides the ability to manage multiple build versions in a simple database table.

Valid TaskActions are:

GetVersion (Required: BuildName, DatabaseName Optional: Delimiter, FieldToIncrement, PaddingCount, PaddingDigit Output: Build, Major, Minor, Revision, Version)

Remote Execution Support: Yes

Inheritance Hierarchy

SystemObject  Microsoft.Build.UtilitiesTask
    MSBuild.ExtensionPackBaseTask
      MSBuild.ExtensionPack.SqlServerSqlVersion

Namespace: MSBuild.ExtensionPack.SqlServer
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 4.0.0.0

The SqlVersion type exposes the following members.

Constructors

  NameDescription
Public methodSqlVersion
Top
Properties

  NameDescription
Public propertyBuild
Build component of build number
Public propertyBuildName
The name of the build number sequence to query
Public propertyDatabaseName
The name of the database whcih contains the BuildNumber table
Public propertyDelimiter
Sets the Delimiter to use in the version number. Default is .
Public propertyFieldToIncrement
Number indicating which field is to be incremented. 0 = none (read out last number generated), 1-4 = Major, Minor, Build, Increment.
Public propertyMajor
Major component of build number
Public propertyMinor
Minor component of build number
Public propertyPaddingCount
Sets the number of padding digits to use, e.g. 4
Public propertyPaddingDigit
Sets the padding digit to use, e.g. 0
Public propertyRevision
Revision component of build number
Public propertyVersion
Gets the full four part Version
Top
Remarks

The following TSql can be used to create the supported table structure:

USE [YOURDATABASENAME]

GO

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[BuildNumbers]') AND type in (N'U'))

DROP TABLE [dbo].[BuildNumbers];

GO

SET ANSI_NULLS ON;

GO

SET QUOTED_IDENTIFIER ON;

GO

SET ANSI_PADDING ON;

GO

CREATE TABLE [dbo].[BuildNumbers](

[SequenceName] [varchar](50) NOT NULL,

[Major] [int] NOT NULL,

[Minor] [int] NOT NULL,

[Build] [int] NOT NULL,

[Increment] [int] NOT NULL,

CONSTRAINT [PK_BuildNumbers_1] PRIMARY KEY CLUSTERED

(

[SequenceName] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

) ON [PRIMARY];

GO

SET ANSI_PADDING OFF;

GO

Valid TaskActions are:

GetVersion (Required: BuildName, DatabaseName Optional: FieldToIncrement, Delimiter, PaddingCount, PaddingDigit Output: Major, Minor, Build, Revision, Version)

Remote Execution Support: NA

Examples

<Target Name="BuildNumberOverrideTarget">
    <PropertyGroup>
        <FieldToIncrement Condition=" '$(IncrementalBuild)'=='true' ">4</FieldToIncrement>
        <FieldToIncrement Condition=" '$(IncrementalBuild)'!='true' ">3</FieldToIncrement>
    </PropertyGroup>
    <!-- Get the latest build number without incrementing it -->
    <MSBuild.ExtensionPack.SqlServer.SqlVersion Taskaction="GetVersion" BuildName="V9 Production Build" DatabaseName="Mike">
        <Output TaskParameter="Version" PropertyName="LatestVersion" />
    </MSBuild.ExtensionPack.SqlServer.SqlVersion>
    <Message Text="LatestVersion is: $(LatestVersion)"/>
    <!-- Get the latest build number and increment as necessary -->
    <MSBuild.ExtensionPack.SqlServer.SqlVersion Taskaction="GetVersion" BuildName="V9 Production Build" FieldToIncrement="$(FieldToIncrement)" DatabaseName="Mike">
        <Output TaskParameter="Major" PropertyName="BuildMajor" />
        <Output TaskParameter="Minor" PropertyName="BuildMinor" />
        <Output TaskParameter="Build" PropertyName="BuildBuild" />
        <Output TaskParameter="Revision" PropertyName="BuildRevision" />
    </MSBuild.ExtensionPack.SqlServer.SqlVersion>
    <!-- Override Team Build BuildNumber property -->
    <PropertyGroup>
        <BuildNumber>$(BuildMajor).$(BuildMinor).$(BuildBuild).$(BuildRevision)</BuildNumber>
    </PropertyGroup>
    <Message Text="BuildNumber is: $(BuildNumber)"/>
    <!-- Export values so they can be seen by targets inside CoreCompile -->
    <PropertyGroup>
        <CustomPropertiesForBuild>$(CustomPropertiesForBuild);BuildMajor=$(BuildMajor);BuildMinor=$(BuildMinor);BuildBuild=$(BuildBuild);BuildRevision=$(BuildRevision)</CustomPropertiesForBuild>
    </PropertyGroup>
    <!-- Get the latest build number without incrementing it -->
    <MSBuild.ExtensionPack.SqlServer.SqlVersion Taskaction="GetVersion" BuildName="V9 Production Build" DatabaseName="Mike">
        <Output TaskParameter="Version" PropertyName="LatestVersion" />
    </MSBuild.ExtensionPack.SqlServer.SqlVersion>
    <Message Text="LatestVersion is: $(LatestVersion)"/>
</Target>
See Also

Reference