-
-
Notifications
You must be signed in to change notification settings - Fork 59
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 get Sha of Git? #334
Comments
Hi @beachwalker, what do you want to do with the hash? |
Put as info into version. More easy to follow then. Maybe to be used in assemblyinformationalversion for last value. |
@beachwalker I do this for my packages using Source Link. By default, Source Link puts the hash into Would that be an option for you? |
@adamralph thanks I had the same question for ages. I added SourceLink as you suggested and it worked perfectly. This might be one for the faq. I think what @beachwalker was wondering is because the information is already available to minver, would it be possible to add it without having to also include SourceLink? e.g. I'd also prefer
Thanks Again! |
@acblksun I guess SourceLink does a lot more than give you the commit hash, since it augments your debug info, etc. so I agree that it may not be desirable to use it just to get the commit hash. Another option for getting the commit hash is GitInfo, which is explicitly designed to expose Git information. It sets a property named <Target Name="MyTarget" AfterTargets="MinVer">
<PropertyGroup>
<AssemblyInformationalVersion Condition="'$(GitSha)' != ''">$(MinVerVersion)+$(GitSha)</AssemblyInformationalVersion>
</PropertyGroup>
</Target> Although it would be trivial to expose the commit hash in a new MinVer property, the reasons I am reluctant to do that are:
|
Assuming either SourceLink or GitVersion solve this requirement, I'm closing this. If there are any further questions, please feel free to chime in again or raise a new issue. |
Where do I put this. I tried SourceLink but don't like the log sha. GitInfo does have the Git.Commit (short sha) but your above lines, where do they go. Not in the csproj, |
@summer600 you should put those lines in the csproj which references MinVer. |
Yep did that bottom of my csproj... But the InformationFileVersion still only shows upto height
but my console app displaying the informationalverersion field shows: |
dnspy says:
|
@summer600 I guess |
See this https://gist.github.com/ElanHasson/30384431651534b215e754a554b5b6ae Which accomplishes this. |
It is nice in GitVersion that the Hash of the git commit (version that will be created) can be attached. I prefer the more lightweight way of minver but I need that feature and don't know how to access that using minver.
The text was updated successfully, but these errors were encountered: