views:

32

answers:

2

Windows PE (portable executable) files contain metadata that appear in the file's Properties dialog under the Details tab. It appears that arbitrary metadata can appear there.

What I'd like to do is add a piece of metadata to a C# class library that I build whose value is the commit id from the git repo HEAD the project was built from. I can't just use the CLR AssemblyVersionAttribute to set the git commit id because the CLR requires that that show up in the standard a.b.c.d version format. Besides, I'd ideally like to keep the user-meaningful version number there, but always have a way to look up, given the actual PE file, the commit id that could recreate it.

If there's a managed API to do it, so much the better, but I'm willing to P/Invoke to get this done.

+1  A: 

The information in the Details tab comes from a VERSIONINFO resource but I'm not sure how you would access that from the .NET world...

Ken Keenan
Interesting. If that's true, I guess arbitrary data can't be added to this tab. :(
Andrew Arnott
You can add arbitrary data to exe's string version info fields, but can't always let them appear on explorer property page. In fact, what the property page diplayed depends on Windows Explorer version. You can get extra fields on Windows XP, but not on Vista or Win7.
Francis
+1  A: 

Ah! I just discovered the AssemblyInformationalVersionAttribute, which allows for an arbitrary string to be given that appears as the "Product version" value in the Details tab of said dialog. This looks like it might be just the thing I need.

Andrew Arnott

related questions