|
15 | 15 | <Nullable>enable</Nullable> |
16 | 16 | <WarningsAsErrors>Nullable</WarningsAsErrors> |
17 | 17 | </PropertyGroup> |
| 18 | + <!-- Dev only: Add hash and if dirty to InformationalVersion. --> |
| 19 | + <Target Name="AppendGitShaToDevInformationalVersion" |
| 20 | + BeforeTargets="GetAssemblyVersion;GenerateAssemblyInfo;CoreCompile" |
| 21 | + Condition="'$(InformationalVersion)' == 'dev'"> |
| 22 | + <Exec Command="git rev-parse --short=8 HEAD" |
| 23 | + ConsoleToMSBuild="true" |
| 24 | + IgnoreExitCode="true" |
| 25 | + IgnoreStandardErrorWarningFormat="true" |
| 26 | + StandardOutputImportance="Low" |
| 27 | + StandardErrorImportance="Low" |
| 28 | + WorkingDirectory="$(MSBuildThisFileDirectory)"> |
| 29 | + <Output TaskParameter="ConsoleOutput" PropertyName="_GitShortSha" /> |
| 30 | + <Output TaskParameter="ExitCode" PropertyName="_GitShortShaExitCode" /> |
| 31 | + </Exec> |
| 32 | + <Exec Command="git status --porcelain" |
| 33 | + ConsoleToMSBuild="true" |
| 34 | + IgnoreExitCode="true" |
| 35 | + IgnoreStandardErrorWarningFormat="true" |
| 36 | + StandardOutputImportance="Low" |
| 37 | + StandardErrorImportance="Low" |
| 38 | + WorkingDirectory="$(MSBuildThisFileDirectory)" |
| 39 | + Condition="'$(_GitShortShaExitCode)' == '0'"> |
| 40 | + <Output TaskParameter="ConsoleOutput" PropertyName="_GitStatus" /> |
| 41 | + <Output TaskParameter="ExitCode" PropertyName="_GitStatusExitCode" /> |
| 42 | + </Exec> |
| 43 | + <PropertyGroup Condition="'$(_GitShortShaExitCode)' == '0' And '$(_GitShortSha)' != ''"> |
| 44 | + <InformationalVersion>dev-$(_GitShortSha)</InformationalVersion> |
| 45 | + <InformationalVersion Condition="'$(_GitStatusExitCode)' == '0' And '$(_GitStatus)' != ''">dev-$(_GitShortSha)-dirty</InformationalVersion> |
| 46 | + </PropertyGroup> |
| 47 | + </Target> |
18 | 48 | </Project> |
0 commit comments