BuildTaskVersionControl 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package BuildTaskVersionControl --version 1.1.0
                    
NuGet\Install-Package BuildTaskVersionControl -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BuildTaskVersionControl" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BuildTaskVersionControl" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="BuildTaskVersionControl" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BuildTaskVersionControl --version 1.1.0
                    
#r "nuget: BuildTaskVersionControl, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BuildTaskVersionControl@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BuildTaskVersionControl&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=BuildTaskVersionControl&version=1.1.0
                    
Install as a Cake Tool

BuildTaskVersionControl

MSBuild Task to automate assembly versioning. Extracts a version string from one file and update it in other files.

Settings

  • InputFile: Legacy value. Value is added to InputFiles. Default: null
  • InputFiles: Path to files to extract version string. Only the greatest value is used. Use RegexInput to customize logic. Default: changelog.md and either Properties\AssemblyInfo.cs or all csproj in ProjectDir
  • UpdateFiles: Path to files to inject with new version string. Use RegexOutput to customize logic. Default: null
  • MaxMatch: Maximum number of lines to match and replace. Matches at least once. Default: 1
  • AutoIncrease: If true, will increase revision by one before updating files. Default: false
  • TouchFiles: Update write-date when updating output files. Default: false
  • DropRevision: Whenever to drop revision before updating files. (never, always, keep) Default: keep
  • Silent: Suppress all log output. Default: false
  • RegexInput: Regex string for the input files. Uses capture group 'version' (or the first capture) and 'suffix' (optional). Default: "(?'version'\d+(?:\.\d+){2,3})(?'suffix'[0-9A-Za-z-]*)"
  • RegexOutput: Regex string for output files. Is used in conjunction with RegexReplace. Default: "(?'version'\d+(?:\.\d+){2,3})(?'suffix'[0-9A-Za-z-]*)"
  • RegexReplace: Replacement string for output files. {version} is replaced by new version and {suffix} is replaced by suffix. Default: "{version}{suffix}"
  • VersionFull: [Output] Extracted version string with suffix.
  • Version: [Output] Extracted version string without suffix.
  • VersionShort: [Output] Extracted version string without revision.
  • Major: [Output] Extracted major version only.
  • Minor: [Output] Extracted minor version only.
  • Build: [Output] Extracted build version only.
  • Revision: [Output] Extracted revision version only.
  • Suffix: [Output] Extracted version suffix

Item Metadata

Files can have metadata defined, which overwrite the global setting.

  • Max: Maximum number of matches for this file only.
  • Regex: Regex used for this file only.
  • Replacement: UpdateFiles only. Replacement string for this file only.
  • DropRevision: UpdateFiles only. Whenever to drop revision before updating files. (never, always, keep)
  • Touch: UpdateFiles only. Update write-date when updating output files.

Minimal Example

Set this as the first entry in your csproj file. Add or remove in- and out-files as you like.

  <PropertyGroup>
    <Version>1.0.0.0</Version>
    <AutoVersion>true</AutoVersion>
  </PropertyGroup>
  <ItemGroup>
    <BuildTaskVersionControl_In Include="$(MSBuildProjectName).csproj" />
    <BuildTaskVersionControl_In Include="changelog.md" />
    <BuildTaskVersionControl_Out Include="$(MSBuildProjectName).csproj" />
    <BuildTaskVersionControl_Out Include="changelog.md" />
  </ItemGroup>

Example

<Target Name="Versioning" BeforeTargets="PreBuildEvent">
  <Message Text="Start version control" Importance="High" />
  <ItemGroup>
    <_In Include="$(MSBuildProjectName).csproj" />
    <_In Include="changelog.md" />
    <_Out Include="$(MSBuildProjectName).csproj" />
    <_Out Include="changelog.md" />
  </ItemGroup>
  <VersioningTask InputFiles="@(_In)" UpdateFiles="@(_Out)" AutoIncrease="true">
    <Output TaskParameter="VersionFull" PropertyName="Version" />
    <Output TaskParameter="Version" ItemName="OutputVersionText" />
  </VersioningTask>
  <Message Text="Finish version control @(OutputVersionText)" Importance="High" />
</Target>

Tips

  • Setting the property 'AutoVersion' to true, will run the default target. It will use the items 'BuildTaskVersionControl_In' and 'BuildTaskVersionControl_Out' as InputFiles and UpdateFiles respectively.
  • Consider using AssemblyInfo.cs to set your project's version. Link
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.1 87 8/7/2025
1.3.0 131 7/6/2025
1.2.1 362 4/8/2023
1.2.0 297 4/1/2023
1.1.0 287 3/11/2023
1.0.4 475 9/28/2022
1.0.3 458 9/27/2022
1.0.1 463 9/15/2022