Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch Names with '/' generate invalid versions #244

Closed
cimnine opened this issue Feb 20, 2023 · 1 comment · Fixed by #248
Closed

Branch Names with '/' generate invalid versions #244

cimnine opened this issue Feb 20, 2023 · 1 comment · Fixed by #248
Assignees
Labels

Comments

@cimnine
Copy link

cimnine commented Feb 20, 2023

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

@cimnine cimnine added the bug label Feb 20, 2023
@digitalsigi
Copy link

Same here. Downgraded to 2.3.0

@kzu kzu self-assigned this Feb 21, 2023
kzu added a commit that referenced this issue Feb 21, 2023
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.
@kzu kzu closed this as completed in #248 Feb 21, 2023
kzu added a commit that referenced this issue Feb 21, 2023
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.
@devlooped devlooped locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants