ā How would you embed a Git commit hash in an assembly?
I want to stamp a commit hash into a binary so I can display it in the UI. I'm fine with pulling stuff from the assembly info via reflection if necessary. I've found a few libraries that promise this, but they all seem janky and ~4-5 years old. What do people use for this nowadays?
14 Replies
i guess u could use a source generator that fetches the commit id and then generates a static class with a property for it or something similar
or have a little program instead that does the same thing and set it up as pre-build event, this would have less performance impact on ur dev env
scratch that, there seems to be a better way: https://stackoverflow.com/questions/15141338/embed-git-commit-hash-in-a-net-dll#answer-45248069
Stack Overflow
Embed git commit hash in a .NET dll
I'm building a C# application, using Git as my version control.
Is there a way to automatically embed the last commit hash in the executable when I build my application?
For example, printing the c...
Unknown Userā¢16mo ago
Message Not Public
Sign In & Join Server To View
interesting... i'll try out both of these
š
i guess its more about wiring the two together depending on ur set up
TeBeClone's is mostly about getting the value into the code by utilizing the project file itself, instead of an sg or similar
the linked stackoverflow answer is about to generate the value utilizing the project file itself (well and the git executable)
Unknown Userā¢16mo ago
Message Not Public
Sign In & Join Server To View
well, yeah, i omitted the SG part already because of that stackoverflow thing and ur answer. so the only thing left is how to get the value.
not everyone has for their project a whole CI/CD setup ;p
Unknown Userā¢16mo ago
Message Not Public
Sign In & Join Server To View
and its also a matter, where they want them the value to end up
nothing good, was just an initial idea i almost instantly threw away ;p
Unknown Userā¢16mo ago
Message Not Public
Sign In & Join Server To View
thats basically the core solution ;p
Unknown Userā¢16mo ago
Message Not Public
Sign In & Join Server To View
enjoy ur meal, im still struck by hang over from yesterday š
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.