Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a7284ce
build(app): add System.CommandLine v2 package dependency
arturcic Mar 2, 2026
442a8f8
refactor(app): rename ArgumentParser to LegacyArgumentParser
arturcic Mar 2, 2026
8bfb482
feat(app): add POSIX-style argument parser using System.CommandLine
arturcic Mar 2, 2026
6bf3537
refactor(app): wire new parser via DI with env-var toggle
arturcic Mar 2, 2026
ea49c76
test(app): update ArgumentParserTests for POSIX-style syntax
arturcic Mar 2, 2026
c2f50c1
test(app): add LegacyArgumentParserTests and isolate with TestEnviron…
arturcic Mar 2, 2026
b22670c
test(app): update integration tests to use POSIX CLI syntax
arturcic Mar 2, 2026
3eebf4c
docs(cli): update all documentation to POSIX --long-name syntax
arturcic Mar 2, 2026
3a14f94
refactor(parser): Rename SystemCommandLineArgumentParser
arturcic Mar 2, 2026
8997061
perf(parser): Optimize command-line argument parser initialization
arturcic Mar 2, 2026
80e7a8a
refactor(gitversion): Adopt POSIX-style long arguments
arturcic Mar 2, 2026
bf91dae
feat(cli): Add toggle for legacy argument parser
arturcic Mar 3, 2026
96d1a99
docs(breaking-changes): Document CLI and logging refactors
arturcic Mar 3, 2026
bca042c
fix(parser): Clarify -c and --commit argument mapping
arturcic Mar 3, 2026
358aaf2
feat(cli): Introduce POSIX-style argument parsing and documentation
arturcic Mar 3, 2026
dd8f3f0
test(arguments): Update help writer test for legacy parser
arturcic Mar 3, 2026
6f1a626
feat(cli): enhance argument descriptions and add help wrapping
arturcic Mar 3, 2026
0576040
refactor(cli): Rename legacy argument help file
arturcic Mar 4, 2026
2072fb8
refactor(cli): Delegate help and version handling to System.CommandLine
arturcic Mar 4, 2026
19c724b
refactor(cli): Extract argument validation and reorganize parsing logic
arturcic Mar 4, 2026
c3e04fe
refactor(arguments): standardize working directory to absolute path
arturcic Mar 4, 2026
3ab6e1e
docs(migration): Add v6 to v7 migration guide for CLI arguments
arturcic Mar 5, 2026
4f39d5a
docs(cli): Recommend long-form arguments for scripts and documentation
arturcic Mar 6, 2026
5cdc574
refactor(arguments): Use extension method for boolean string parsing
arturcic Mar 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"MD026": false,
"MD041": false
"MD041": false,
"MD013": false
}
42 changes: 42 additions & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
## Unreleased

### CLI Arguments — POSIX-style Syntax

The command-line interface has been migrated from Windows-style (`/switch` and single-dash `-switch`) arguments to POSIX-style `--long-name` arguments using [System.CommandLine](https://github.com/dotnet/command-line-api).

**Old-style arguments are no longer accepted by default.** Update any scripts, CI pipelines, or tooling accordingly.

As a temporary migration aid, set the environment variable `GITVERSION_USE_V6_ARGUMENT_PARSER=true` to restore the legacy `/switch` and `-switch` argument handling. This escape hatch will be removed in a future release.

#### Full argument mapping

| Old argument | New argument | Short alias | Env var alternative |
| ----------------------------- | -------------------------------- | ------------------------------ | ---------------------------- |
| `/targetpath <path>` | `--target-path <path>` | _(positional `path` argument)_ | |
| `/output <type>` | `--output <type>` | `-o` | |
| `/outputfile <path>` | `--output-file <path>` | | |
| `/showvariable <var>` | `--show-variable <var>` | `-v` | |
| `/format <format>` | `--format <format>` | `-f` | |
| `/config <path>` | `--config <path>` | `-c` | |
| `/showconfig` | `--show-config` | | |
| `/overrideconfig <k=v>` | `--override-config <k=v>` | | |
| `/nocache` | `--no-cache` | | |
| `/nofetch` | `--no-fetch` | | |
| `/nonormalize` | `--no-normalize` | | |
| `/allowshallow` | `--allow-shallow` | | |
| `/verbosity <level>` | `--verbosity <level>` | | |
| `/l <path>` | `--log-file <path>` | `-l` | |
| `/diag` | `--diagnose` | `-d` | |
| `/updateassemblyinfo [files]` | `--update-assembly-info [files]` | | |
| `/updateprojectfiles [files]` | `--update-project-files [files]` | | |
| `/ensureassemblyinfo` | `--ensure-assembly-info` | | |
| `/updatewixversionfile` | `--update-wix-version-file` | | |
| `/url <url>` | `--url <url>` | | |
| `/b <branch>` | `--branch <branch>` | `-b` | |
| `/u <username>` | `--username <username>` | `-u` | `GITVERSION_REMOTE_USERNAME` |
| `/p <password>` | `--password <password>` | `-p` | `GITVERSION_REMOTE_PASSWORD` |
| `/c <commit>` | `--commit <commit>` | _(no short alias)_ | |
| `/dynamicRepoLocation <path>` | `--dynamic-repo-location <path>` | | |

> **Critical**: `-c` previously referred to the commit id. It is now aliased to `--config` (config file path). Any usage of `-c <commit-id>` must be changed to `--commit <commit-id>`.

The `GITVERSION_REMOTE_USERNAME` and `GITVERSION_REMOTE_PASSWORD` environment variables can be used as alternatives to `--username` and `--password`. Environment variables take lower precedence than explicit CLI arguments.

### Logging System Replacement

* The custom `ILog` logging abstraction has been replaced with the industry-standard `Microsoft.Extensions.Logging` (M.E.L.) infrastructure using Serilog as the underlying provider.
Expand Down
2 changes: 1 addition & 1 deletion build/build/Tasks/Package/PackagePrepare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private static void PackPrepareNative(BuildContext context)
{
context.Information("Validating native lib:");
var nativeExe = outputPath.CombineWithFilePath(context.IsOnWindows ? "gitversion.exe" : "gitversion");
context.ValidateOutput(nativeExe.FullPath, "/showvariable FullSemver", context.Version?.GitVersion?.FullSemVer);
context.ValidateOutput(nativeExe.FullPath, "--show-variable FullSemver", context.Version?.GitVersion?.FullSemVer);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion build/build/Tasks/ValidateVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public override void Run(BuildContext context)
{
ArgumentNullException.ThrowIfNull(context.Version);
var gitVersionTool = context.GetGitVersionToolLocation();
context.ValidateOutput("dotnet", $"\"{gitVersionTool}\" -version", context.Version.GitVersion.InformationalVersion);
context.ValidateOutput("dotnet", $"\"{gitVersionTool}\" --version", context.Version.GitVersion.InformationalVersion);
}
}
20 changes: 10 additions & 10 deletions build/common/Addins/GitVersion/GitVersionRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ private ProcessArgumentBuilder GetArguments(GitVersionSettings settings)

if (settings.OutputTypes.Contains(GitVersionOutput.Json))
{
builder.Append("-output");
builder.Append("--output");
builder.Append("json");
}

if (settings.OutputTypes.Contains(GitVersionOutput.BuildServer))
{
builder.Append("-output");
builder.Append("--output");
builder.Append("buildserver");
}

if (!string.IsNullOrWhiteSpace(settings.ShowVariable))
{
builder.Append("-showvariable");
builder.Append("--show-variable");
builder.Append(settings.ShowVariable);
}

Expand All @@ -91,7 +91,7 @@ private ProcessArgumentBuilder GetArguments(GitVersionSettings settings)

if (settings.UpdateAssemblyInfo)
{
builder.Append("-updateassemblyinfo");
builder.Append("--update-assembly-info");

if (settings.UpdateAssemblyInfoFilePath != null)
{
Expand All @@ -101,12 +101,12 @@ private ProcessArgumentBuilder GetArguments(GitVersionSettings settings)

if (settings.RepositoryPath != null)
{
builder.Append("-targetpath");
builder.Append("--target-path");
builder.AppendQuoted(settings.RepositoryPath.FullPath);
}
else if (!string.IsNullOrWhiteSpace(settings.Url))
{
builder.Append("-url");
builder.Append("--url");
builder.AppendQuoted(settings.Url);

if (!string.IsNullOrWhiteSpace(settings.Branch))
Expand All @@ -122,13 +122,13 @@ private ProcessArgumentBuilder GetArguments(GitVersionSettings settings)

if (!string.IsNullOrWhiteSpace(settings.Commit))
{
builder.Append("-c");
builder.Append("--commit");
builder.AppendQuoted(settings.Commit);
}

if (settings.DynamicRepositoryPath != null)
{
builder.Append("-dynamicRepoLocation");
builder.Append("--dynamic-repo-location");
builder.AppendQuoted(settings.DynamicRepositoryPath.FullPath);
}
}
Expand All @@ -141,14 +141,14 @@ private ProcessArgumentBuilder GetArguments(GitVersionSettings settings)

if (settings.NoFetch)
{
builder.Append("-nofetch");
builder.Append("--no-fetch");
}

var verbosity = settings.Verbosity ?? this._log.Verbosity;

if (verbosity != Verbosity.Normal)
{
builder.Append("-verbosity");
builder.Append("--verbosity");
builder.Append(verbosity.ToString());
}

Expand Down
2 changes: 1 addition & 1 deletion build/common/Utilities/DockerContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void DockerTestImage(DockerImage dockerImage)
var tags = context.GetDockerTags(dockerImage, dockerImage.Architecture);
foreach (var tag in tags)
{
context.DockerTestRun(tag, dockerImage.Architecture, "/repo", ["/showvariable", "FullSemver", "/nocache"]);
context.DockerTestRun(tag, dockerImage.Architecture, "/repo", ["--show-variable", "FullSemver", "--no-cache"]);
}
}

Expand Down
16 changes: 9 additions & 7 deletions docs/input/docs/learn/dynamic-repositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ will assume there is already a ".git" folder present, and it will use it.
To tell GitVersion.exe to obtain the repository on the fly, you need to call
`GitVersion.exe` with the following arguments:

* `/url [the url of your git repo]`
* `/u [authentication username]`
* `/p [authentication password]`
* `/b [branch name]`
* `/c [commit id]`
* `--url [the url of your git repo]`
* `--username [authentication username]` (short alias: `-u`)
* `--password [authentication password]` (short alias: `-p`)
* `--branch [branch name]` (short alias: `-b`)
* `--commit [commit id]`

Please note that these arguments are described when calling `GitVersion.exe /?`.
Long-form arguments are recommended for scripts and documentation.

Also, be aware that if you don't specify the `/b` argument (branch name) then
Please note that these arguments are described when calling `GitVersion.exe --help`.

Also, be aware that if you don't specify the `--branch` argument (branch name) then
GitVersion will currently fallback to targeting whatever the default branch name
happens to be for the repo. This could lead to incorrect results, so for that
reason it's recommended to always explicitly specify the branch name.
Expand Down
8 changes: 8 additions & 0 deletions docs/input/docs/migration/index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
Title: Migration
Description: Technical reference documentation.
Order: 100
---
<p>@Html.Raw(Model.String(DocsKeys.Description))</p>

@Html.Partial("_ChildPages")
80 changes: 80 additions & 0 deletions docs/input/docs/migration/v6-to-v7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
Order: 10
Title: Migration v6 to v7
Description: Migration guidance for upgrading from GitVersion v6 to GitVersion v7.
---

This document summarizes the relevant breaking changes when migrating from GitVersion v6 to v7.

## CLI Arguments - POSIX-style syntax

GitVersion now uses POSIX-style command-line arguments powered by System.CommandLine.

:::{.alert .alert-warning}
**Breaking change:** Legacy Windows-style (`/switch`) and legacy single-dash long-form (`-switch`) arguments are no longer accepted by default.

As a temporary migration aid, set `GITVERSION_USE_V6_ARGUMENT_PARSER=true` to restore legacy argument handling. This compatibility mode is temporary and will be removed in a future release.
:::

### What you need to change

1. Replace old argument names with POSIX-style `--long-name` arguments.
2. Prefer `--long-name` arguments for readability and maintainability. Supported short aliases (`-o`, `-v`, `-f`, `-c`, `-l`, `-d`, `-b`, `-u`, `-p`) remain available for interactive use.
3. Update scripts that used `-c <commit>` to `--commit <commit>`.
4. Optionally use `GITVERSION_REMOTE_USERNAME` and `GITVERSION_REMOTE_PASSWORD` instead of passing credentials on the command line.

### Full argument mapping

| Old argument | New argument | Short alias | Env var alternative |
| ----------------------------- | -------------------------------- | ------------------------------ | ---------------------------- |
| `/targetpath <path>` | `--target-path <path>` | _(positional `path` argument)_ | |
| `/output <type>` | `--output <type>` | `-o` | |
| `/outputfile <path>` | `--output-file <path>` | | |
| `/showvariable <var>` | `--show-variable <var>` | `-v` | |
| `/format <format>` | `--format <format>` | `-f` | |
| `/config <path>` | `--config <path>` | `-c` | |
| `/showconfig` | `--show-config` | | |
| `/overrideconfig <k=v>` | `--override-config <k=v>` | | |
| `/nocache` | `--no-cache` | | |
| `/nofetch` | `--no-fetch` | | |
| `/nonormalize` | `--no-normalize` | | |
| `/allowshallow` | `--allow-shallow` | | |
| `/verbosity <level>` | `--verbosity <level>` | | |
| `/l <path>` | `--log-file <path>` | `-l` | |
| `/diag` | `--diagnose` | `-d` | |
| `/updateassemblyinfo [files]` | `--update-assembly-info [files]` | | |
| `/updateprojectfiles [files]` | `--update-project-files [files]` | | |
| `/ensureassemblyinfo` | `--ensure-assembly-info` | | |
| `/updatewixversionfile` | `--update-wix-version-file` | | |
| `/url <url>` | `--url <url>` | | |
| `/b <branch>` | `--branch <branch>` | `-b` | |
| `/u <username>` | `--username <username>` | `-u` | `GITVERSION_REMOTE_USERNAME` |
| `/p <password>` | `--password <password>` | `-p` | `GITVERSION_REMOTE_PASSWORD` |
| `/c <commit>` | `--commit <commit>` | _(no short alias)_ | |
| `/dynamicRepoLocation <path>` | `--dynamic-repo-location <path>` | | |

:::{.alert .alert-danger}
**Important:** `-c` now maps to `--config`.

If you previously used `-c <commit-id>`, you must replace it with `--commit <commit-id>`.
:::

### Example updates

```bash
# Before
gitversion /output json /showvariable SemVer /config GitVersion.yml

# After
gitversion --output json --show-variable SemVer --config GitVersion.yml
```

```bash
# Before
gitversion /url https://github.com/org/repo.git /b main /u user /p pass /c a1b2c3

# After
gitversion --url https://github.com/org/repo.git --branch main --username user --password pass --commit a1b2c3
```

For current command details and examples, see [CLI Arguments](/docs/usage/cli/arguments).
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pipelines:
script:
- export PATH="$PATH:/root/.dotnet/tools"
- dotnet tool install --global GitVersion.Tool
- dotnet-gitversion /output buildserver
- dotnet-gitversion --output buildserver
- source gitversion.properties
- echo Building with semver $GITVERSION_FULLSEMVER
- dotnet build
Expand All @@ -41,7 +41,7 @@ You must set the `clone:depth` setting as shown above; without it, BitBucket Pip
cause GitVersion to display an error message.
:::

When the action `dotnet-gitversion /output buildserver` is executed, it will detect that it is running in BitBucket Pipelines by the presence of
When the action `dotnet-gitversion --output buildserver` is executed, it will detect that it is running in BitBucket Pipelines by the presence of
the `BITBUCKET_WORKSPACE` environment variable, which is set by the BitBucket Pipelines engine. It will generate a text file named `gitversion.properties`
which contains all the output of the GitVersion tool, exported as individual environment variables prefixed with `GITVERSION_`.
These environment variables can then be imported back into the build step using the `source gitversion.properties` action.
Expand All @@ -62,7 +62,7 @@ pipelines:
script:
- export PATH="$PATH:/root/.dotnet/tools"
- dotnet tool install --global GitVersion.Tool
- dotnet-gitversion /output buildserver
- dotnet-gitversion --output buildserver
artifacts:
- gitversion.properties
- step:
Expand Down
2 changes: 1 addition & 1 deletion docs/input/docs/reference/build-servers/continua.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ follow the steps below:
* Executable path: $Agent.GitVersion.Path$
* Working directory: %RepositoryPath%
* In the `Arguments` tab, set the following values:
* Arguments: /url %RepositoryUrl% /b %RepositoryBranchName% /c %RepositoryCommitId% /output buildserver
* Arguments: --url %RepositoryUrl% --branch %RepositoryBranchName% --commit %RepositoryCommitId% --output buildserver
* In the `Options` tab, set the following values:
* Wait for completion: checked
* Log output: checked
Expand Down
4 changes: 2 additions & 2 deletions docs/input/docs/reference/build-servers/index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ RedirectFrom:

<p>
When the <code>gitVersion</code> executable is run with the
<code>/output buildserver</code> flag instead of outputting JSON, it will
<code>--output buildserver</code> flag instead of outputting JSON, it will
export its <a href="/docs/reference/variables">version variables</a> to the
current build server as build-server native variables. For instance if you
are running in TeamCity after you run
<code>gitversion /output buildserver</code> you will have the
<code>gitversion --output buildserver</code> you will have the
<code>%system.GitVersion.SemVer%</code> variable available for you to use
in the rest of the build configuration.
</p>
Expand Down
4 changes: 2 additions & 2 deletions docs/input/docs/reference/build-servers/jenkins.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ To inject the GitVersion variables as environment variables for a build job
using [EnvInject][env-inject], do the following:

1. Add an **Execute Windows batch command** build step with _Command_:
`gitversion /output buildserver`
`gitversion --output buildserver`
2. Add an **Inject environment variables** build step and use value
'gitversion.properties' for the _Properties File Path_ parameter

Expand All @@ -58,7 +58,7 @@ In a pipeline stage:
1. Run GitVersion with the flag for _buildserver_ output (this only works when run from Jenkins, specifically when the `JENKINS_URL` environment variable is defined):

```groovy
sh 'gitversion /output buildserver'`
sh 'gitversion --output buildserver'`
```

2. Add a script block to read the properties file, assign environment variables as needed:
Expand Down
Loading
Loading