|
6 | 6 | <PropertyGroup> |
7 | 7 | <VersionCsFile>$(IntermediatePath)\$(AssemblyName).Version.cs</VersionCsFile> |
8 | 8 | <NoWarn>$(NoWarn);1607</NoWarn> |
| 9 | + |
| 10 | + <!-- PrereleaseVersion can be any alphanumeric identifier with a preceding hyphen, or blank. --> |
| 11 | + <PrereleaseVersion>-beta</PrereleaseVersion> |
9 | 12 | </PropertyGroup> |
10 | 13 |
|
11 | 14 | <UsingTask AssemblyFile="$(ProjectRoot)lib\MSBuild.Community.Tasks.dll" TaskName="AssemblyInfo"/> |
|
16 | 19 | GitRepoRoot="$(ProjectRoot)"> |
17 | 20 | <Output TaskParameter="Version" PropertyName="BuildVersion" /> |
18 | 21 | <Output TaskParameter="SimpleVersion" PropertyName="BuildVersionSimple" /> |
19 | | - <Output TaskParameter="GitCommitId" PropertyName="AssemblyInformationalVersion" /> |
| 22 | + <Output TaskParameter="GitCommitId" PropertyName="GitCommitId" /> |
| 23 | + <Output TaskParameter="BuildNumber" PropertyName="BuildNumber" /> |
20 | 24 | </GetBuildVersion> |
21 | 25 | <PropertyGroup> |
22 | 26 | <!-- In TeamCity, the build agent doesn't get the .git directory, but the commit id is available by other means. --> |
23 | | - <AssemblyInformationalVersion Condition=" '$(AssemblyInformationalVersion)' == '' ">$(BUILD_VCS_NUMBER)</AssemblyInformationalVersion> |
| 27 | + <GitCommitId Condition=" '$(GitCommitId)' == '' ">$(BUILD_VCS_NUMBER)</GitCommitId> |
| 28 | + |
| 29 | + <SemVerBuildSuffix>+build.$(BuildNumber).$(GitCommitId.Substring(0,10))</SemVerBuildSuffix> |
| 30 | + <AssemblyInformationalVersion>$(BuildVersionSimple)$(PrereleaseVersion)$(SemVerBuildSuffix)</AssemblyInformationalVersion> |
| 31 | + |
| 32 | + <!-- When NuGet supports SemVer 2.0, we can set NuGetPackageVersion to be the same as $(AssemblyInformationalVersion) --> |
| 33 | + <NuGetPackageVersion Condition=" '$(PrereleaseVersion)' == '' ">$(BuildVersion)</NuGetPackageVersion> |
| 34 | + <NuGetPackageVersion Condition=" '$(PrereleaseVersion)' != '' ">$(BuildVersionSimple)$(PrereleaseVersion)</NuGetPackageVersion> |
24 | 35 | </PropertyGroup> |
25 | 36 | <Warning Condition=" '$(AssemblyInformationalVersion)' == '' " Text="Unable to determine the git HEAD commit ID to use for informational version number." /> |
26 | | - <Message Condition=" '$(AssemblyInformationalVersion)' != '' " Text="Building version $(BuildVersion) from commit $(AssemblyInformationalVersion)"/> |
| 37 | + <Message Condition=" '$(AssemblyInformationalVersion)' != '' " Text="Building version $(BuildVersion) from commit $(GitCommitId)"/> |
27 | 38 | <Message Condition=" '$(AssemblyInformationalVersion)' == '' " Text="Building version $(BuildVersion)"/> |
| 39 | + <Message Importance="low" Text="AssemblyInformationalVersion: $(AssemblyInformationalVersion)" /> |
| 40 | + <Message Importance="low" Text="NuGetPackageVersion: $(NuGetPackageVersion)" /> |
28 | 41 | </Target> |
29 | 42 |
|
30 | 43 | <Target Name="BeforeBuild" DependsOnTargets="GetBuildVersion"> |
|
0 commit comments