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

GitInfo.txt per project leaves GitSemVerPatch at zero #76

Closed
lightbroker opened this issue Aug 16, 2018 · 6 comments
Closed

GitInfo.txt per project leaves GitSemVerPatch at zero #76

lightbroker opened this issue Aug 16, 2018 · 6 comments

Comments

@lightbroker
Copy link

lightbroker commented Aug 16, 2018

First off, this library has been very helpful in getting our team up and running with package versioning. Thank you!

We have a single .sln with two (2) .NET Standard 2.0 class libraries. Both reference GitInfo 2.0.15. Placing a GitInfo.txt file in the repo root works as expected. Example, if that file includes the text "1.2.0", and there are 4 commits, we get the Sample.Library.1.2.4, and Another.Library.1.2.4.

The problem comes when we try to have independent version numbers per project, via individual GitInfo.txt file per project (as mentioned here):

  • GitInfo.txt for Sample.Library contents: "3.1.0"
  • GitInfo.txt for Another.Library contents: "2.7.0"

No matter how many times we commit, the "patch" number (which is based on $(GitSemVerPatch)) stays at "0". For example, we expect something like "Sample.Library.3.1.4.nupkg", but get "Sample.Library.3.1.0.nupkg".

Sample.Library.csproj:

<Project Sdk="Microsoft.NET.Sdk" InitialTargets="SetVersion">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <IncludeSymbols Condition=" '$(Configuration)' == 'Debug' ">true</IncludeSymbols>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="GitInfo" Version="2.0.15">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <!-- Generate semantic versioning for packages -->
  <Target Name="SetVersion" BeforeTargets="Build;GetPackageVersion;_IntrospectProjectProperties" DependsOnTargets="GitInfo" Condition="'$(ExcludeRestorePackageImports)' != 'true'">
    <PropertyGroup>
      <!-- Packages for feature branches are marked as "alpha" (ex., 2.1.0-alpha426e8bcf) -->
      <GitSemVerDashLabel Condition="$(GitBranch.Contains('features'))">alpha$(GitCommit)</GitSemVerDashLabel>

      <!-- Packages for release branches are marked as "rc", release candidates (ex., 2.1.0-rc426e8bcf) -->
      <GitSemVerDashLabel Condition="$(GitBranch.Contains('releases'))">rc$(GitCommit)</GitSemVerDashLabel>

      <!-- Packages for the master branch have no suffix (ex., 2.1.0) -->
      <GitSemVerDashLabel Condition="$(GitBranch.Contains('master'))"></GitSemVerDashLabel>

      <PackageVersion Condition="'$(GitSemVerDashLabel)' != ''">$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)-$(GitSemVerDashLabel)</PackageVersion>
      <PackageVersion Condition="'$(GitSemVerDashLabel)' == ''">$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)</PackageVersion>
      <InformationalVersion>$(PackageVersion)</InformationalVersion>
    </PropertyGroup>
  </Target>

</Project>

Any insight into what I'm missing here would be helpful.

@kzu
Copy link
Member

kzu commented Aug 16, 2018 via email

@lightbroker
Copy link
Author

Thanks for the suggestion. Using DependsOnTargets="GitVersion" yields the same results. With a shared GitInfo.txt in the repo root, major and minor versions come from GitInfo.txt, and patch number increments based on commits. And with individual GitInfo.txt files per project, it uses value from the GitInfo.txt without modifying the last (patch) digit.

I've been scouring GitInfo.targets, but I have yet to pinpoint what's causing the variation in behavior.

@kzu
Copy link
Member

kzu commented Aug 17, 2018 via email

@lightbroker
Copy link
Author

Added sample solution source here.

Build output attached:
build-output.txt

@kzu kzu closed this as completed in 3353ac4 Sep 10, 2018
@kzu
Copy link
Member

kzu commented Sep 10, 2018

Thanks a lot for the repro solution, I could diagnose that and push a fix. The updated nuget should be up very soon.

Thanks!

@lightbroker
Copy link
Author

Great news. Thank you very much.

@devlooped devlooped locked and limited conversation to collaborators Sep 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants