๐ฏโ๏ธ 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
andVersion.txt
with the incremented version during each build (except for theRelease
configuration).
- 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.
To install the NuGet package, use the following command:
Install-Package MSBuild.Version.Target
Or visit the NuGet package page for more details.
-
Post-installation Setup:
After installing the package, locate theVersion.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.
-
Configuration Management:
The versioning logic activates during any build configuration other thanRelease
. 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
-
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.
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.
Contributions are welcome!
Feel free to open issues, submit pull requests, or suggest features.
This project is licensed under the MIT License.