Skip to content

Command-line GitVersion in a Linux environment #1362

@TAGC

Description

@TAGC

I'm trying to configure a Travis build for one of my C# projects and I'd like to be able to use GitVersion to calculate the version of the project from its git history so I can programatically set my project version during builds.

Command-line versions of GitVersion are only available using brew (OSX-specific) and choco (Windows-specific). How can I use it in a Linux environment like Travis CI builds use? Here's an example of my config where I tried to install the gem and use it that way (just to see what happened):

{
  "language": "csharp",
  "dist": "trusty",
  "mono": "none",
  "dotnet": "2.0.0",
  "install": [
    "gem install gitversion"
  ],
  "script": [
    "cd AsyncBus",
    "dotnet restore",
    "dotnet setversion $(gitversion -showvariable NuGetVersionV2)",
    "dotnet build",
    "dotnet test",
    "dotnet pack -c Release -o artifacts/",
    "dotnet nuget push --source https://www.nuget.org/api/v2/package --api-key $NUGET_APIKEY $(find artifacts -name \"*.nupkg\")"
  ],
  "group": "stable",
  "os": "linux"
}

The build failed with these logs:

2.27s$ dotnet setversion $(gitversion -showvariable NuGetVersionV2)
/home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: 1: /home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: MZ������@������: not found
/home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: 1: /home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: .rsrc����Z@@.reloc��: not found
/home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: 2: /home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: ���: not found
/home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: 15: /home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: rap�o: not found
/home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: 16: /home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: ,�~: not found
/home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: 18: /home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: �/��+��+��+��,�s��%�}����8��s���r]p�o: not found
/home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: 19: /home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: -��rap�o: not found
/home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: 20: /home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: ,�~: not found
/home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: 22: /home/travis/.rvm/gems/ruby-2.4.1/gems/gitversion-3.5.0/bin/GitVersion.exe: Syntax error: "(" unexpected
Missing version string
The command "dotnet setversion $(gitversion -showvariable NuGetVersionV2)" exited with 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions