C
C#ā€¢11mo 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ā€¢11mo 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ā€¢11mo 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ā€¢11mo ago
Message Not Public
Sign In & Join Server To View
Becquerel
Becquerelā€¢11mo ago
interesting... i'll try out both of these šŸ™‚
cap5lut
cap5lutā€¢11mo 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ā€¢11mo ago
Message Not Public
Sign In & Join Server To View
cap5lut
cap5lutā€¢11mo 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ā€¢11mo ago
Message Not Public
Sign In & Join Server To View
cap5lut
cap5lutā€¢11mo 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ā€¢11mo ago
Message Not Public
Sign In & Join Server To View
cap5lut
cap5lutā€¢11mo ago
thats basically the core solution ;p
Unknown User
Unknown Userā€¢11mo ago
Message Not Public
Sign In & Join Server To View
cap5lut
cap5lutā€¢11mo ago
enjoy ur meal, im still struck by hang over from yesterday šŸ˜‚
Accord
Accordā€¢11mo 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
More Posts
ā” Is it possible to run integration tests with typescript as client and .net api as server?My hope is to test a client written in typescript which calls a .net api in the same solution.āœ… .csproj ā€“ how to generate nodes dynamically by iterating over a string array ?how can i generate xml code in the .csproj file? i dont want to repeat my actions 10000 times... so ā” AWS multiple file upload Using API in Razor PageI am trying to send the API request from the razor page. The Endpoint is not hitting the API Controlāœ… Override (abstract) getter-only property with a setterHello! I was wondering if there is anyway to add a setter to an overridden getter-only property? Cuā” Proper way to do something in C# (migrating an old Visual Basic library)So I'm rewriting an ancient library and used an automatic transpiler to convert it all from VB.NET tā” Getting information from web apiSo I created my own web api and am creating a console application that can consume the api. I'm currā” Runtime Endianness for Reading Structured Binary DataIs there a standard way to deal with reading structured binary data in from a stream where the endiaā” comples object creationHi people, Can someone give me some ideas on how to handle a complex object creation, meaning some ā” Get list of indices from a ListI have a result set called "result". I want to use Linq to get a list of distinct items by name and ā” I am having trouble with visual studio code, would be glad if someone could help me out.I write a code but then the .exe file doesn't open up when I run the code.