CLI to increment and git-tag the version of .NET, C(++) and npm projects. Geared towards Visual Studio projects.
> dotnet-bump minor --dry-run - Would stage Foo\Foo.csproj - Would stage Bar\version.h - Would commit and tag v1.1.0
> dotnet-bump minor - Stage Foo\Foo.csproj - Stage Bar\version.h - Commit and tag v1.1.0
dotnet-bump <target> [options] [file..]
target version, one of:
- A release type:
majortype bumps the major version (for example
2.4.1 => 3.0.0);
patchwork the same way.
premajortype bumps the version up to the next major version and down to a prerelease of that major version;
prepatchwork the same way.
prereleasetype works the same as
prepatchif the input version is a non-prerelease. If the input is already a prerelease then it's simply incremented (for example
4.0.0-rc.2 => 4.0.0-rc.3).
- A specific version like 2.4.0 (must be semver).
Files can be glob patterns or paths to a:
*.slnVisual Studio solution (parsed to find projects)
*.fsprojproject (parsed to find a
*.fsfile (containing assembly attributes, see below)
*.nuspecfile (containing a
*.vcxprojproject (used to discover
version.hfiles in the same directory)
version.hfile (see below)
*.json5file (containing a
- Directory containing any of the above.
Default is the current working directory. Files must reside in a git working tree (or multiple working trees).
Glob patterns must use forward slashes (
/) even on Windows, because the backward slash (
\) is an escape character. This means
dotnet-bump patch example\*.h should be
dotnet-bump patch example/*.h. Backward slashes do work if the given argument is not a glob pattern, because
dotnet-bump will interpret it as a file path:
dotnet-bump patch example\version.h.
--dry-run -d Print changes but don't make them --force -f Continue if git working tree(s) are dirty --no-commit Don't commit and tag --no-glob Disable globbing --verbose Verbose output --version -v Print version and exit --help -h Print usage and exit
Both legacy-style projects (that use assembly attributes) and SDK-style projects (that commonly use a
Version element) are supported. For example,
dotnet-bump would replace the
1.2.3 string here:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <Version>1.2.3</Version> </PropertyGroup> </Project>
If the project is published as a NuGet package, the project version can usually serve as the source of truth. Other times a custom
*.nuspec file may be necessary. For example:
<package xmlns=".."> <metadata> <id>Example</id> <version>1.2.3</version> </metadata> <files> <file src="Example.dll" target="build\native\x64\bin" /> <file src="Example.targets" target="build\Example.targets" /> </files> </package>
Assembly attributes (C# / F#)
AssemblyInfo.cs file is found then
dotnet-bump will replace the following attribute and leave other attributes as-is. If a version has four numeric components (
220.127.116.11) then the last component (
.0) will be stripped.
AssemblyFileVersion and / or
AssemblyInformationalVersion attributes are present they will be updated as well, but only if
AssemblyVersion is present because it is used to determine the current version.
[assembly: AssemblyFileVersion("1.2.3")] [assembly: AssemblyInformationalVersion("1.2.3")]
version.h (C / C++)
One of the following combination of constants can be used, and must be written exactly as below with optional added whitespace (though
dotnet-bump will strip such whitespace). Other lines in the
version.h file will be left alone.
#define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_PATCH 3
#define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_PATCH 3 #define VERSION_BUILD 0
#define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_BUILD 3 #define VERSION_REVISION 0
If the combination has four constants, the last constant will be ignored (on read) and set to
0 (on write).
Download a portable binary or install with npm:
npm install dotnet-bump --save-dev
MIT © Vincent Weevers