Skip to content

Commit

Permalink
Replace / and \ in branches with dashes
Browse files Browse the repository at this point in the history
Do this only when setting a default Version since otherwise the build fails. But we don't want to change the determined GitBranch so it remains accurate.

Closes #244.
  • Loading branch information
kzu committed Feb 21, 2023
1 parent dffafc7 commit 1a92d60
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/GitInfo/build/GitInfo.targets
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@

<Target Name="GitSetVersion" DependsOnTargets="GitVersion" Condition="'$(GitVersion)' != 'false'">
<PropertyGroup>
<Version>$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)$(GitSemVerDashLabel)+$(GitBranch).$(GitCommit)</Version>
<Version>$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)$(GitSemVerDashLabel)+$(GitBranch.Replace('/', '-').Replace('\', '-')).$(GitCommit)</Version>

This comment has been minimized.

Copy link
@tobsil

tobsil Mar 29, 2023

I think '_' needs to be replaced as well.

edit:
after reading a bit more on SemVer.org it looks like everything but [0-9A-Za-z-] has to be replaced:

  <Version>$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)$(GitSemVerDashLabel) +$([System.Text.RegularExpressions.Regex]::Replace($(GitBranch), "[^0-9A-Za-z-]", "-")).$(GitCommit)</Version>
<PackageVersion>$(Version)</PackageVersion>
</PropertyGroup>
</Target>
Expand Down

0 comments on commit 1a92d60

Please sign in to comment.