{"id":21885721,"url":"https://github.com/dwcullop/buildinfo","last_synced_at":"2025-04-15T07:45:09.538Z","repository":{"id":198100282,"uuid":"145753347","full_name":"dwcullop/BuildInfo","owner":"dwcullop","description":"A quick and easy way to automate programmatic access to import build information such as build date in your DotNet / C# projects","archived":false,"fork":false,"pushed_at":"2018-11-15T20:27:46.000Z","size":12,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T17:57:31.460Z","etag":null,"topics":["build","build-automation","build-date","build-tool","build-tools","csharp","git-branch","t4","texttemplate","versioning"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dwcullop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-08-22T19:26:51.000Z","updated_at":"2022-08-15T14:47:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"f17546a5-8962-484e-9320-15f57a716d57","html_url":"https://github.com/dwcullop/BuildInfo","commit_stats":null,"previous_names":["dwcullop/buildinfo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwcullop%2FBuildInfo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwcullop%2FBuildInfo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwcullop%2FBuildInfo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwcullop%2FBuildInfo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dwcullop","download_url":"https://codeload.github.com/dwcullop/BuildInfo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249031502,"owners_count":21201353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build","build-automation","build-date","build-tool","build-tools","csharp","git-branch","t4","texttemplate","versioning"],"created_at":"2024-11-28T10:29:06.086Z","updated_at":"2025-04-15T07:45:09.515Z","avatar_url":"https://github.com/dwcullop.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Easy and Automated Extended Build Info for Dot Net / C#\n## Introduction\n\nIf you've ever wanted a way to programmatically have access to Build Information (build date, branch, etc.) but needed it to be easy to maintain, flexible, and best of all, automated, then this is your lucky day.\n\n## What You Get\n\nIt's always been trivial to get the version number of any Dot Net Assembly.  But what if you wanted more detailed information, such as the build date, git branch or hash, or whatever else?  So you may write something like this:\n\n```csharp\n// SomeProject v0.9.0.0 (Build Date: August 9, 2018 7:57:21 PM UTC)\nConsole.WriteLine( BuildInfo.DisplayText ); \n```\n\n## How It Works\n\nThis amazingly easy to use code leverages the power of T4, a vastly underused part of DotNet development, which allows one to write C# code that emits C# code when it's built.  This code captures the current date/time and other information about the build and generates a static C# class that exposes this information as properties.\n\n## How To Use It\n\nAll you really need to do is copy the `BuildInfo.tt` file to your project and tweak it as necessary.  When you build the project, it will emit a `BuildInfo.cs` file that will be compiled with the rest of your code.\n\nHowever, you may prefer to harness the power of Git by adding my simple repo as a submodule of your repo, which will allow you to easily get any updates and improvements that may come up.  To do that, use these steps:\n\n 1) Add this project as a submodule to your project with this command:\n\n     `git submodule add -f https://github.com/dwcullop/BuildInfo BuildInfo`\n     \n 2) Add the `BuildInfo\\BuildInfo.tt`  file to your C# project\n 3) Enjoy the automated buildinfo goodness\n\n[More information on Git Submodules](https://git-scm.com/docs/git-submodule)\n\nIf you want to include the Git Hash of the current checked out branch in the information that is available via the static class, use the `feature/githash` branch, like this:\n\n    git submodule add -b feature/githash -f https://github.com/dwcullop/BuildInfo BuildInfo\n    \n**NOTICE**: If you do not use the submodule option, make sure you specify the `BuildInfo.cs` in your `.gitignore` file.  It is usually considered bad-form to check generated files into source control.\n\n### :bulb: Pro Tip\n\nTo ensure that the Build Timestamp is updated on every single build, I recommend using one of the Visual Studio extensions that forces all T4 code to re-execute on every build, [such as this one](https://marketplace.visualstudio.com/items?itemName=BennorMcCarthy.AutoT4).\n\n## Warranties\n\nThis works for me using Visual Studio 2015 and 2017.  I hope it works for you, but I can't make any promises.  Your mileage may vary.  Offer void where prohibited.  If you're not here, you're probably someplace else.  Do not taunt happy fun ball.  If at first you DO succeed, try not to look surprised.\n\nIf you make any useful changes, please submit a PR so everyone can enjoy the benefits.\n\n\n## Example\n\nHere is actual output from the code (from the branch that adds the Git information):\n```csharp\n/////////////////////////////////////////////////////////////////////////////////////////////////////////////\n// NOTICE: DO NOT EDIT THIS FILE!\n// \n// This file is autogenerated and your changes will be OVERWRITTEN! \n// Edit the corresponding .tt file instead.\n//\n// Or, better yet, make a lasting contribution by submitting a Pull Request:  \n//      https://github.com/dwcullop/BuildInfo\n/////////////////////////////////////////////////////////////////////////////////////////////////////////////\nusing System;\nusing System.Reflection;\n\nnamespace DareWare.SWGoH.ModMaster\n{\n    public static class BuildInfo\n    {\n        private const long              BUILD_DATE_BINARY_UTC       = 0x48d60eb549dbbe85;    // August 30, 2018 8:15:11.051123 PM UTC\n\n        private static AssemblyName     BuildAssemblyName { get; }  = Assembly.GetExecutingAssembly().GetName();\n        public static DateTimeOffset    BuildDateUtc { get; }       = DateTime.FromBinary(BUILD_DATE_BINARY_UTC);\n        public static string            ModuleText { get; }         = BuildAssemblyName.Name;\n        public static string            CommitHash { get; }         = \"d76760b57ceb7b3b3e7cdfa9b0427cdf1bac901a\";\n        public static string            CommitHashAbbrev { get; }   = \"d76760b\";\n        public static string            VersionText { get; }        = \"v\" + BuildAssemblyName.Version.ToString()\n                                                                                + \".\" + CommitHashAbbrev\n#if DEBUG\n                                                                                + \" [DEBUG]\"\n#endif\n                                                                                ;\n\n        public static string            BuildDateText { get; }      = \"Thursday, August 30, 2018 8:15:11 PM UTC\";\n        public static string            DisplayText { get; }        = $\"{ModuleText} {VersionText} (Build Date: {BuildDateText})\";\n    }\n}\n```\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwcullop%2Fbuildinfo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwcullop%2Fbuildinfo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwcullop%2Fbuildinfo/lists"}