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

How to specify CLI version? #152

Open
mt-akar opened this issue Aug 2, 2024 · 2 comments
Open

How to specify CLI version? #152

mt-akar opened this issue Aug 2, 2024 · 2 comments

Comments

@mt-akar
Copy link

mt-akar commented Aug 2, 2024

A --version flag is added by default to all CLIs. It prints [ExecutableName] 1.0.0

How does one specify the version of CLI?

@Translucent504
Copy link

TLDR:

var builder = CoconaApp.CreateBuilder();
builder.Services.AddSingleton<ICoconaApplicationMetadataProvider, ApplicationMetadataProvider>();
var app = builder.Build();
using Cocona.Application;

class ApplicationMetadataProvider : ICoconaApplicationMetadataProvider
{

    public string GetDescription() => "Eru CLI";

    public string GetExecutableName() => "EruCLI";

    public string GetProductName() => "Eru Cli";

    public string GetVersion() => "1.0.0.0";
}

I had the same question, this is what i found:

Idk if there is a cleaner api exposed or if you can just set the assembly attributes elsewhere, but I simply implemented the ICoconaApplicationMetadataProvider myself and provided the name / versions over there.

@DanteDeRuwe
Copy link

While you can provide a new implementation for the ICoconaApplicationMetadataProvider, the default (CoconaApplicationMetadataProvider) gets the version from the assembly version.

This means, you can also version your assembly by putting it in the .sln file:

<PropertyGroup>
    <Version>1.2.3</Version>
</PropertyGroup>

For use in CI/CD, you can provide -p:Version=1.2.3 to MSBuild :)

Also, since .NET 8, the commit hash is included in the version by default. To disable this, simply add this to .sln:

<PropertyGroup>
  <IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>

(learned this from https://anthonysimmon.com/remove-git-hash-from-assembly-informational-version-dotnet-8/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants