MSBuild.Version.Target

A build target that increments AssemblyInfo version as a SemVer pattern.


Keywords
MSBuild, auto, automatic, automaticly, build, target, targets, version, auto-increment, dotnet, dotnetframework, nuget, package, semver, version-manager
License
MIT
Install
Install-Package MSBuild.Version.Target -Version 1.1.30

Documentation

MSBuild.Version.Target

Wakatime Build Status NuGet Version NuGet Downloads CodeFactor

πŸŽ―βš™οΈ MSBuild.Version.Target is a NuGet package that automates versioning by auto-incrementing the build version for non-release configuration builds.

It integrates seamlessly with your project by:

  • Generating and maintaining a Version.txt file for versioning in Semantic Versioning (SemVer) format.
  • Automatically updating AssemblyInfo.cs and Version.txt with the incremented version during each build (except for the Release configuration).

πŸš€ Features

  • Semantic Versioning (SemVer) support:
    • Major and minor versions are manually maintained.
    • Build (patch) version is automatically incremented during the build process.
  • Configurable via MSBuild.
  • Works in CI/CD pipelines or local builds.

πŸ“¦ Installation

To install the NuGet package, use the following command:

Install-Package MSBuild.Version.Target

Or visit the NuGet package page for more details.


πŸ› οΈ Usage Instructions

  1. Post-installation Setup:
    After installing the package, locate the Version.txt file in the Properties folder of your project. Update the file with your current project version in the SemVer format:

    Major.Minor.Patch
    
    • Major and Minor: Managed manually.
    • Patch: Automatically incremented for non-Release builds.
  2. Configuration Management:
    The versioning logic activates during any build configuration other than Release. Ensure the appropriate configuration is selected:

    • In Visual Studio, adjust this under Build > Configuration Manager.
    • In CI pipelines or manual builds, specify the configuration explicitly using:
      MSBuild /p:Configuration=Debug
  3. Build Process:
    During the build, the following updates occur automatically:

    • AssemblyInfo.cs: The assembly version is updated to reflect the new version.
    • Version.txt: The build version is incremented.

πŸ“‹ Example

Here’s a quick example of how the versioning would work:

  • Initial Version.txt:
    1.0.0
    
  • After a build with configuration Debug:
    1.0.1
    
  • After another Debug build:
    1.0.2
    
  • Build with configuration Release:
    • Version remains unchanged.

🧩 Contributing

Contributions are welcome!
Feel free to open issues, submit pull requests, or suggest features.


πŸ“„ License

This project is licensed under the MIT License.