dotnet-setversion
3.0.0
dotnet tool install --global dotnet-setversion --version 3.0.0
dotnet new tool-manifest # if you are setting up this repo dotnet tool install --local dotnet-setversion --version 3.0.0
#tool dotnet:?package=dotnet-setversion&version=3.0.0
nuke :add-package dotnet-setversion --version 3.0.0
dotnet-setversion is a simple .NET Core CLI tool used to update the version information within .NET Core *.csproj
files.
It is based on dotnet-gitversion, but is updated to work for the new *.csproj
format instead of project.json, and relies on the version information being passed to it.
Usage
Install dotnet-setversion as a global tool using the dotnet CLI:
$ dotnet tool install -g dotnet-setversion
If the command completed successfully, you're able to invoke dotnet-setversion in any directory like this:
$ setversion 0.1.2-beta0001
You can also update the version information of a specific project file by invoking like this:
$ setversion 0.1.2-beta0001 MyProject.csproj
Recursive updates
If you happen to have a rather big repo including several project files and you want to update them all at once, you can use the --recursive
option.
This will update any project file in and below the current working directory.
$ setversion -r 0.1.2-beta0001
Extracting the version from a file
As well as passing the version directly, you can specify a file to extract the version number from. This is done by prefixing the version argument with an @
symbol. For example, the following command will make the tool try to extract the version from a file in the working directory called "sem.ver".
$ setversion @sem.ver
The file should represent the version either as a simple string (i.e. in the same format you'd ordinarily provide directly to the tool, such as 0.1.2
) or in JSON format using a schema like this:
{
"Version": {
"Major": 0,
"Minor": 1,
"Patch": 2
}
}
Bear in mind that the JSON format does not support metadata extensions (e.g. -beta0001
).
Further notes
For each example, replace '0.1.2-beta0001' with any valid version string or, when having GitVersion installed, with $(GitVersion -ShowVariable NuGetVersionV2)
to use your current version automatically.
This (or something similar) can of course be done during a continuous integration build, which is the main intention behind developing this project. This tool depends on itself for its own version management during CI builds, so you can use it as a reference.
Migrating from 1.* to 2.*
dotnet-setversion used to be a per-project tool, but has now been reworked as a .NET Core Global Tool.
As a consequence of this, you have to remove the <DotNetCliToolReference>
element referencing dotnet-setversion or you'll get an error when running dotnet restore
.
Depending on your build strategy, you have to install setversion once on your build agent (see Usage) or integrate the install command into your build script.
Finally you have to change the way to invoke the program from dotnet setversion
to setversion
.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
This package has no dependencies.
Version | Downloads | Last updated |
---|---|---|
3.0.0 | 44,724 | 1/8/2024 |
3.0.0-alpha0004 | 187 | 11/21/2023 |
2.6.0 | 37,214 | 2/22/2023 |
2.5.0 | 82,380 | 2/10/2022 |
2.4.0 | 44,255 | 12/2/2021 |
2.3.0 | 6,595 | 9/13/2021 |
2.2.1 | 7,675 | 5/24/2021 |
2.2.0 | 25,312 | 3/5/2020 |
2.1.0 | 3,757 | 11/25/2019 |
2.0.0 | 12,431 | 10/29/2018 |
1.0.3 | 42,136 | 3/29/2018 |
1.0.2 | 126,286 | 8/22/2017 |
1.0.1 | 2,552 | 7/25/2017 |
1.0.0 | 6,143 | 3/15/2017 |
0.1.3 | 1,198 | 3/15/2017 |
0.1.2 | 1,128 | 3/15/2017 |
0.1.1 | 1,149 | 3/15/2017 |
0.1.0 | 1,398 | 3/15/2017 |