devlooped / GitInfo

Git and SemVer Info from MSBuild, C# and VB

Home Page:https://clarius.org/GitInfo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Branch Names with '/' generate invalid versions

cimnine opened this issue · comments

Describe the Bug

When doing a build with dotnet build, an error appears when I build a branch who's name that contains a /.

error NETSDK1018: Invalid NuGet version string: '0.0.294+domain/orders.d71f59f'.

Steps to Reproduce

using System.Reflection;
using SomeNs;

[assembly: AssemblyVersion(AssemblyInfo.Version)]
[assembly: AssemblyFileVersion(AssemblyInfo.SimpleVersion)]
[assembly: AssemblyInformationalVersion(AssemblyInfo.InformationalVersion)]

namespace SomeNs;

/// <summary>
///     A class that contains information about this assembly, such as the version number.
/// </summary>
// ReSharper disable MemberCanBePrivate.Global
internal static class AssemblyInfo
{
    /// <summary>
    ///     Simple release-like version number, like 4.0.1.
    /// </summary>
    public const string SimpleVersion =
        ThisAssembly.Git.BaseVersion.Major
        + "."
        + ThisAssembly.Git.BaseVersion.Minor
        + "."
        + ThisAssembly.Git.BaseVersion.Patch;

    /// <summary>
    ///     Full version, including commits since base version file, like 4.0.1.598.
    /// </summary>
    public const string Version = SimpleVersion + "." + ThisAssembly.Git.Commits;

    /// <summary>
    ///     Full version, including commits since base version file and commit id, like 4.0.1.598-39cf84e.
    /// </summary>
    public const string InformationalVersion = Version + "-" + ThisAssembly.Git.Commit;
}

This works fine, unless you switch to a branch with slashes:

git switch -c branch/with/slash
dotnet build

Expected Behavior

Acts like version 2.3.0 or upgrade instructions what to change for 3.0.0.

Exception with Stack Trace

n/a

Version Info

Bug since version 3.0.0

Additional Info

n/a

Same here. Downgraded to 2.3.0