Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write Git info strings to exe file C#

I need to write git information: Commit name, tags, branch, etc to a binary (exe) file.

It is needed to run strings * | grep git, on that file to simply view latest git info about it. I know that AssemblyInfo is displayed when I run this command (without grep), but I'm facing two possible problems:

  1. I'm not sure if I can write to AssemblyInfo from code, to run 'git log' command and then get its output and write into AssemblyInfo.

  2. If I want to use command 'git log' then it's not going to work on Windows, but it is possible that my App will be built on Windows and not on unix environment.

Maybe you know another way to do that?

like image 596
alexander_va Avatar asked Mar 06 '13 13:03

alexander_va


1 Answers

This is usually done in your build script, filling a templated version of your AssemblyInfo (look at mustache, a templating language).

This build step does the following:

  • get the necessary info with git plumbing commands (e.g. How to programmatically determine the current checked out Git branch)
  • generate the AssemblyInfo file using a template.

Then your software build continues as usual.

like image 102
CharlesB Avatar answered Oct 10 '22 09:10

CharlesB