Last active
February 27, 2020 17:18
-
-
Save dasMulli/6d9580ba52770d8f1abae1fc8fb1a6dd to your computer and use it in GitHub Desktop.
Add Git commit count to version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project> | |
<PropertyGroup> | |
<GenerateNuspecDependsOn>AddGitCommitCountToVersion;$(GenerateNuspecDependsOn)</GenerateNuspecDependsOn> | |
<!-- this is only used in NuGet 4.6.0 --> | |
<GetPackageVersionDependsOn>AddGitCommitCountToVersion;$(GetPackageVersionDependsOn)</GetPackageVersionDependsOn> | |
</PropertyGroup> | |
<Target Name="AddGitCommitCountToVersion" | |
BeforeTargets="PrepareForBuild;_GenerateRestoreProjectSpec" | |
Condition=" '$(DisableGitVersionSuffix)' != 'true' "> | |
<Exec Command="git rev-list --count HEAD" ConsoleToMSBuild="true" StandardOutputImportance="low"> | |
<Output TaskParameter="ConsoleOutput" PropertyName="GitCommitCount" /> | |
</Exec> | |
<PropertyGroup> | |
<PreReleaseLabel Condition=" '$(PreReleaseLabel)' == '' ">beta</PreReleaseLabel> | |
<VersionCommitCountSuffix>$(GitCommitCount.PadLeft(6, '0'))</VersionCommitCountSuffix> | |
<Version>$(Version)-$(PreReleaseLabel)-$(VersionCommitCountSuffix)</Version> | |
<PackageVersion>$(Version)</PackageVersion> | |
</PropertyGroup> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment