Stamps an assembly with git data.
The nuget package
PM> Install-Package Stamp.Fody
Add to FodyWeavers.xml
<Stamp/> to FodyWeavers.xml
<?xml version="1.0" encoding="utf-8" ?> <Weavers> <Stamp /> </Weavers>
What it does
Extracts the git information from disk, combines it with the assembly version, and places it in the
So if your assembly version is
22.214.171.124, the working branch is
master and the last commit is
759e9ddb53271dfa9335a3b27e452749a9b22280 then the following attribute will be added to the assembly.
[assembly: AssemblyInformationalVersion("126.96.36.199 Head:'master' Sha:759e9ddb53271dfa9335a3b27e452749a9b22280")]
Templating the version
You can customize the string used in the
AssemblyInformationalVersionAttribute by adding some tokens to the string, which Stamp will replace.
For example, if you add
[assembly: AssemblyInformationalVersion("%version% Branch=%branch%")] then Stamp will change it to
[assembly: AssemblyInformationalVersion("188.8.131.52 Branch=master")]
The tokens are:
%version%is replaced with the version (
%version1%is replaced with the major version only (
%version2%is replaced with the major and minor version (
%version3%is replaced with the major, minor, and revision version (
%version4%is replaced with the major, minor, revision, and build version (
%now%is replaced with the current short date
%utcnow%is replaced with the current utc short date
%githash%is replaced with the SHA1 hash of the branch tip of the repository
%shorthash%is replaced with the first eight characters of
%branch%is replaced with the branch name of the repository
%haschanges%is replaced with the string defined in the ChangeString attribute in the configuration, see below.
%user%is replaced with the current user name
%machinename%is replaced with the current machine name
%lasttag%-is replaced with the last git tag in this branch.
NOTE: if you already have an
AssemblyInformationalVersionattribute and it doesn't use replacement tokens, it will not be modified at all.
All config options are attributes of
<Stamp /> element in FodyWeavers.xml
Define the string used to indicate that the code was built from a non clean repository.
<Stamp ChangeString="New text" />
Define if you want to start Stamp to start searching for the Git repository in the ProjectDir (
true) or the SolutionDir (
<Stamp UseProjectGit='true' />