|
<Project> |
|
|
|
<PropertyGroup> |
|
<LangVersion>preview</LangVersion> |
|
<NullableContextOptions>enable</NullableContextOptions> |
|
<Deterministic>true</Deterministic> |
|
<VersionPrefix>0.0.0</VersionPrefix> |
|
<RepoRoot>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), '.reporoot'))\</RepoRoot> |
|
<SrcRoot>$([System.IO.Path]::GetFullPath('$(RepoRoot)src\'))</SrcRoot> |
|
<PathMap>$(SrcRoot)=.</PathMap> |
|
</PropertyGroup> |
|
|
|
<Target Name="Increment Build Number" BeforeTargets="Build"> |
|
|
|
<PropertyGroup> |
|
<BuildNumberPath>$(MSBuildProjectDirectory)\.build</BuildNumberPath> |
|
<PreviousBuildNumber>-1</PreviousBuildNumber> |
|
<PreviousBuildNumber Condition="Exists('$(BuildNumberPath)')">$([System.IO.File]::ReadAllText('$(BuildNumberPath)').Trim())</PreviousBuildNumber> |
|
<BuildNumber>$([MSBuild]::Add($(PreviousBuildNumber), 1))</BuildNumber> |
|
<Version>$(VersionPrefix).$(BuildNumber)</Version> |
|
<Version Condition="'$(VersionSuffix)' != ''">$(VersionPrefix).$(BuildNumber)-$(VersionSuffix)</Version> |
|
</PropertyGroup> |
|
|
|
<Message Text="Build Number = $(BuildNumber)" Importance="high" /> |
|
<Message Text="Version = $(Version)" Importance="high" /> |
|
|
|
<WriteLinesToFile File="$(BuildNumberPath)" Lines="$(BuildNumber)" Overwrite="true" /> |
|
|
|
</Target> |
|
|
|
<Choose> |
|
|
|
<When Condition="'$(Configuration)' == 'Release'"> |
|
|
|
<PropertyGroup> |
|
<DebugSymbols>false</DebugSymbols> |
|
<DebugType>none</DebugType> |
|
<Optimize>true</Optimize> |
|
<DefineConstants></DefineConstants> |
|
</PropertyGroup> |
|
|
|
</When> |
|
|
|
<Otherwise> |
|
|
|
<PropertyGroup> |
|
<DebugSymbols>true</DebugSymbols> |
|
<DebugType>full</DebugType> |
|
<Optimize>false</Optimize> |
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|
<DotGitRoot>$([System.IO.Path]::GetFullPath('$(RepoRoot).git\'))</DotGitRoot> |
|
<GitHeadFileContent Condition="Exists('$(DotGitRoot)HEAD')">$([System.IO.File]::ReadAllText('$(DotGitRoot)HEAD').Trim())</GitHeadFileContent> |
|
<GitRefPath Condition="$(GitHeadFileContent.StartsWith('ref: '))">$(DotGitRoot)$(GitHeadFileContent.Substring(5))</GitRefPath> |
|
<GitHeadSha>0000000000000000000000000000000000000000</GitHeadSha> |
|
<GitHeadSha Condition="'$(GitHeadFileContent)' != '' and '$(GitRefPath)' == ''">$(GitHeadFileContent)</GitHeadSha> |
|
<GitHeadSha Condition="'$(GitRefPath)' != '' and Exists('$(GitRefPath)')">$([System.IO.File]::ReadAllText('$(GitRefPath)').Trim())</GitHeadSha> |
|
<VersionSuffix Condition="'$(GitHeadSha)' != ''">git-$(GitHeadSha)</VersionSuffix> |
|
</PropertyGroup> |
|
|
|
</Otherwise> |
|
|
|
</Choose> |
|
|
|
</Project> |