C
C#ā€¢16mo ago
Becquerel

ā” 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
cap5lut
cap5lutā€¢16mo ago
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
cap5lut
cap5lutā€¢16mo ago
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
Unknown Userā€¢16mo ago
Message Not Public
Sign In & Join Server To View
Becquerel
BecquerelOPā€¢16mo ago
interesting... i'll try out both of these šŸ™‚
cap5lut
cap5lutā€¢16mo ago
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
Unknown Userā€¢16mo ago
Message Not Public
Sign In & Join Server To View
cap5lut
cap5lutā€¢16mo ago
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
Unknown Userā€¢16mo ago
Message Not Public
Sign In & Join Server To View
cap5lut
cap5lutā€¢16mo ago
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
Unknown Userā€¢16mo ago
Message Not Public
Sign In & Join Server To View
cap5lut
cap5lutā€¢16mo ago
thats basically the core solution ;p
Unknown User
Unknown Userā€¢16mo ago
Message Not Public
Sign In & Join Server To View
cap5lut
cap5lutā€¢16mo ago
enjoy ur meal, im still struck by hang over from yesterday šŸ˜‚
Accord
Accordā€¢16mo ago
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.
Want results from more Discord servers?
Add your server