|
19 | 19 | <AssemblyOriginatorKeyFile>../signing/visualstudiopublic.snk</AssemblyOriginatorKeyFile>
|
20 | 20 | <SignAssembly>true</SignAssembly>
|
21 | 21 | </PropertyGroup>
|
| 22 | + |
| 23 | + <Target Name="GetPS6VersionFromGit" |
| 24 | + BeforeTargets="BeforeBuild"> |
| 25 | + |
| 26 | + <PropertyGroup> |
| 27 | + <GitExe>git</GitExe> |
| 28 | + </PropertyGroup> |
| 29 | + |
| 30 | + <Exec Command='$(GitExe) rev-parse --show-cdup' ConsoleToMSBuild="true"> |
| 31 | + <Output TaskParameter="ConsoleOutput" PropertyName="GitCDUP" /> |
| 32 | + </Exec> |
| 33 | + |
| 34 | + <PropertyGroup> |
| 35 | + <GitInfoBaseDir Condition="'$(GitInfoBaseDir)' == ''">$(MSBuildProjectDirectory)/$(GitCDUP)/.git</GitInfoBaseDir> |
| 36 | + </PropertyGroup> |
| 37 | + |
| 38 | + <Exec Command='$(GitExe) --git-dir="$(GitInfoBaseDir)" describe --abbrev=60 --long' ConsoleToMSBuild="true"> |
| 39 | + <Output TaskParameter="ConsoleOutput" PropertyName="PowerShellVersion" /> |
| 40 | + </Exec> |
| 41 | + |
| 42 | + <PropertyGroup> |
| 43 | + <RegexGitVersion>^v(.+)-(\d+)-g(.+)</RegexGitVersion> |
| 44 | + <PS6BuildVersion>$([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[1].Value)</PS6BuildVersion> |
| 45 | + <PS6AdditionalCommits>$([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[2].Value)</PS6AdditionalCommits> |
| 46 | + <PS6CommitSHA>$([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[3].Value)</PS6CommitSHA> |
| 47 | + |
| 48 | + <RegexSymVer>^(\d+).(\d+).(\d+)-(.+)</RegexSymVer> |
| 49 | + <PS6MajorVersion>$([System.Text.RegularExpressions.Regex]::Match($(PS6BuildVersion), $(RegexSymVer)).Groups[1].Value)</PS6MajorVersion> |
| 50 | + <PS6MinorVersion>$([System.Text.RegularExpressions.Regex]::Match($(PS6BuildVersion), $(RegexSymVer)).Groups[2].Value)</PS6MinorVersion> |
| 51 | + <PS6PatchVersion>$([System.Text.RegularExpressions.Regex]::Match($(PS6BuildVersion), $(RegexSymVer)).Groups[3].Value)</PS6PatchVersion> |
| 52 | + <PS6LabelVersion>$([System.Text.RegularExpressions.Regex]::Match($(PS6BuildVersion), $(RegexSymVer)).Groups[4].Value)</PS6LabelVersion> |
| 53 | + |
| 54 | + <PS6FormattedVersion Condition="'$(PS6AdditionalCommits)' == ''">$(PS6BuildVersion) SHA: $(PS6CommitSHA)</PS6FormattedVersion> |
| 55 | + <PS6FormattedVersion Condition="'$(PS6FormattedVersion)' == ''">$(PS6BuildVersion) Commits: $(PS6AdditionalCommits) SHA: $(PS6CommitSHA)</PS6FormattedVersion> |
| 56 | + |
| 57 | + <ProductVersion>$(PS6BuildVersion)</ProductVersion> |
| 58 | + <!-- PackageVersion>$(PS6BuildVersion)</PackageVersion --> |
| 59 | + <InformationalVersion>$(PS6FormattedVersion)</InformationalVersion> |
| 60 | + |
| 61 | + </PropertyGroup> |
| 62 | + |
| 63 | + <!-- WriteLinesToFile File="debugtargetfile.txt" |
| 64 | + Lines="PowerShellVersion=$(PowerShellVersion); |
| 65 | + PS6BuildVersion = $(PS6BuildVersion); |
| 66 | + PS6AdditionalCommits = $(PS6AdditionalCommits); |
| 67 | + PS6CommitSHA = $(PS6CommitSHA); |
| 68 | + PS6MajorVersion = $(PS6MajorVersion); |
| 69 | + PS6MinorVersion = $(PS6MinorVersion); |
| 70 | + PS6PatchVersion = $(PS6PatchVersion); |
| 71 | + PS6LabelVersion = $(PS6LabelVersion); |
| 72 | + GitCDUP = $(GitCDUP); |
| 73 | + RegexGitVersion = $(RegexGitVersion); |
| 74 | + PS6FormattedVersion = $(PS6FormattedVersion); |
| 75 | + ProductVersion = $(ProductVersion); |
| 76 | + InformationalVersion = $(InformationalVersion); |
| 77 | + " |
| 78 | + Overwrite="true"/ --> |
| 79 | + |
| 80 | + </Target> |
| 81 | + |
22 | 82 | </Project>
|
0 commit comments