dotnet pack fails from feature branch as version variables are set incorrectly / {BranchName} is not unescaped #4737
-
Prerequisites
GitVersion packageGitVersion.Tool GitVersion version6.4.0 Operating systemWindows What are you seeing?In my pipeline, which has been migrated from 5.2.0 to 6.4.0, the creation of the NuGet Package fails with this error D:\AzureAgent-03\_work\_tool\dotnet\sdk\9.0.306\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(110,5): error MSB4018: The "GetPackOutputItemsTask" task failed unexpectedly. [D:\AzureAgent-03\_work\25\s\Source\Product\Product.Helper\Product.Helper.csproj]
D:\AzureAgent-03\_work\_tool\dotnet\sdk\9.0.306\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(110,5): error MSB4018: System.ArgumentException: PackageVersion string specified '6.9.0-{BranchName}.1+54' is invalid. [D:\AzureAgent-03\_work\25\s\Source\Product\Product.Helper\Product.Helper.csproj]
D:\AzureAgent-03\_work\_tool\dotnet\sdk\9.0.306\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(110,5): error MSB4018: at NuGet.Build.Tasks.Pack.GetPackOutputItemsTask.Execute() [D:\AzureAgent-03\_work\25\s\Source\Product\Product.Helper\Product.Helper.csproj]
D:\AzureAgent-03\_work\_tool\dotnet\sdk\9.0.306\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(110,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Execute() [D:\AzureAgent-03\_work\25\s\Source\Product\Product.Helper\Product.Helper.csproj]
D:\AzureAgent-03\_work\_tool\dotnet\sdk\9.0.306\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(110,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [D:\AzureAgent-03\_work\25\s\Source\Product\Product.Helper\Product.Helper.csproj]Generated output: Command: git -C D:\AzureAgent-03\_work\25\s rev-parse --is-shallow-repository
Command: D:\AzureAgent-03\_work\_tool\GitVersion.Tool\6.4.0\dotnet-gitversion.exe --roll-forward Major D:\AzureAgent-03\_work\25\s /output json
dotnet-gitversion Output:
-------------------
{
"AssemblySemFileVer": "6.
[gitversion.log](https://github.com/user-attachments/files/23368957/gitversion.log)
9.0.30001",
"AssemblySemVer": "6.9.0.0",
"BranchName": "feature/15357-Launcher-Refactoring",
"BuildMetaData": 54,
"CommitDate": "2025-11-05",
"CommitsSinceVersionSource": 54,
"EscapedBranchName": "feature-15357-Launcher-Refactoring",
"FullBuildMetaData": "54.Branch.feature-15357-Launcher-Refactoring.Sha.7f7bf893d521126a7abde30763351d5f5a1edf04",
"FullSemVer": "6.9.0-{BranchName}.1+54",
"InformationalVersion": "6.9.0--BranchName-.1+54",
"Major": 6,
"MajorMinorPatch": "6.9.0",
"Minor": 9,
"Patch": 0,
"PreReleaseLabel": "{BranchName}",
"PreReleaseLabelWithDash": "-{BranchName}",
"PreReleaseNumber": 1,
"PreReleaseTag": "{BranchName}.1",
"PreReleaseTagWithDash": "-{BranchName}.1",
"SemVer": "6.9.0-{BranchName}.1",
"Sha": "7f7bf893d521126a7abde30763351d5f5a1edf04",
"ShortSha": "7f7bf89",
"UncommittedChanges": 0,
"VersionSourceSha": "0ea87b12521f1da626e5acf69401c59e97bf934e",
"WeightedPreReleaseNumber": 30001
}After I removed the Command: git -C D:\AzureAgent-03\_work\25\s rev-parse --is-shallow-repository
Command: D:\AzureAgent-03\_work\_tool\GitVersion.Tool\6.4.0\dotnet-gitversion.exe --roll-forward Major D:\AzureAgent-03\_work\25\s /output json
dotnet-gitversion Output:
-------------------
{
"AssemblySemFileVer": "6.9.0.1",
"AssemblySemVer": "6.9.0.0",
"BranchName": "15357-Launcher-Refactoring",
"BuildMetaData": 54,
"CommitDate": "2025-11-05",
"CommitsSinceVersionSource": 54,
"EscapedBranchName": "15357-Launcher-Refactoring",
"FullBuildMetaData": "54.Branch.15357-Launcher-Refactoring.Sha.7f7bf893d521126a7abde30763351d5f5a1edf04",
"FullSemVer": "6.9.0-15357-Launcher-Refactoring.1+54",
"InformationalVersion": "6.9.0-15357-Launcher-Refactoring.1+54",
"Major": 6,
"MajorMinorPatch": "6.9.0",
"Minor": 9,
"Patch": 0,
"PreReleaseLabel": "15357-Launcher-Refactoring",
"PreReleaseLabelWithDash": "-15357-Launcher-Refactoring",
"PreReleaseNumber": 1,
"PreReleaseTag": "15357-Launcher-Refactoring.1",
"PreReleaseTagWithDash": "-15357-Launcher-Refactoring.1",
"SemVer": "6.9.0-15357-Launcher-Refactoring.1",
"Sha": "7f7bf893d521126a7abde30763351d5f5a1edf04",
"ShortSha": "7f7bf89",
"UncommittedChanges": 0,
"VersionSourceSha": "0ea87b12521f1da626e5acf69401c59e97bf934e",
"WeightedPreReleaseNumber": 1
}My config: What is expected?A valid NuGetPackage and correctly set variables for branch Steps to ReproduceI believe the behavior is due to the branch name RepositoryFixture TestNo response Output log or link to your CI build (if appropriate). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
I think the missing puzzle here is the change of using capturing groupes: In the breaking change document the following is written:
In the docs/reference/configuration document the following is written:
and
Link[1]: https://github.com/GitTools/GitVersion/blob/main/BREAKING_CHANGES.md |
Beta Was this translation helpful? Give feedback.



I think the missing puzzle here is the change of using capturing groupes:
In the breaking change document the following is written:
In the docs/reference/configuration document the following is written:
and
Link[1]: https://github.com/GitTools/GitVersion/blob/main/BREAKING_CHANGES.md
Link[2]: https://gitversion.net/docs/reference/configuration