xenadmin/Directory.Build.targets
Michael J. Manley b56e07f5eb Converted from old MSBuild Style to .NET SDK Style Projects to prepare for .NET Core Upgrade in future.
Removed EOL notice and added future Mantainership notice.
2024-02-08 11:31:35 -08:00

94 lines
4.3 KiB
XML

<Project>
<Target Name="SetSourceRevisionId" BeforeTargets="InitializeSourceControlInformation">
<Exec Command="git describe --long --always --dirty --exclude=* --abbrev=8" ConsoleToMSBuild="True"
IgnoreExitCode="False" ContinueOnError="True">
<Output PropertyName="SourceRevisionIdOutput" TaskParameter="ConsoleOutput" />
<Output PropertyName="SourceRevisionIdErrorCode" TaskParameter="ExitCode" />
</Exec>
<Exec Command="git rev-parse HEAD" ConsoleToMSBuild="True" IgnoreExitCode="False" ContinueOnError="True">
<Output PropertyName="SourceRevisionIdFullOutput" TaskParameter="ConsoleOutput" />
<Output PropertyName="SourceRevisionIdFullErrorCode" TaskParameter="ExitCode" />
</Exec>
<Exec Command="git rev-parse --abbrev-ref HEAD" ConsoleToMSBuild="True" IgnoreExitCode="False"
ContinueOnError="True">
<Output PropertyName="SourceBranchOutput" TaskParameter="ConsoleOutput" />
<Output PropertyName="SourceBranchErrorCode" TaskParameter="ExitCode" />
</Exec>
<PropertyGroup>
<GitRepo>false</GitRepo>
<SourceRevisionId></SourceRevisionId>
<SourceRevisionIdFull></SourceRevisionIdFull>
<SourceBranch></SourceBranch>
</PropertyGroup>
<PropertyGroup Condition="'$(SourceRevisionIdErrorCode)' == '0'">
<GitRepo>true</GitRepo>
<SourceRevisionId>$(SourceRevisionIdOutput)</SourceRevisionId>
</PropertyGroup>
<PropertyGroup Condition="'$(SourceRevisionIdFullErrorCode)' == '0'">
<SourceRevisionIdFull>$(SourceRevisionIdFullOutput)</SourceRevisionIdFull>
</PropertyGroup>
<PropertyGroup Condition="'$(SourceBranchErrorCode)' == '0'">
<SourceBranch>$(SourceBranchOutput)</SourceBranch>
</PropertyGroup>
<PropertyGroup>
<GitData>
<![CDATA[
using System%3B
internal partial class ThisAssembly
{
internal class Git {
internal const bool IsGitRepo = $(GitRepo)%3B
internal const string SourceRevisionId = "$(SourceRevisionId)"%3B
internal const string SourceRevisionIdFull = "$(SourceRevisionIdFull)"%3B
internal const string SourceBranch = "$(SourceBranch)"%3B
}
}
]]>
</GitData>
<InformationalData>
<![CDATA[
using System%3B
internal partial class ThisAssembly
{
internal class InformationalData {
internal const string Version = "$(Version)"%3B
internal const string Codename = "$(Codename)"%3B
internal const string LabId = "$(Lab)"%3B
internal const string BuildDateTime = "$([System.DateTime]::Now.ToString("yyyyMMdd_HHmmss"))"%3B
internal const string BuildStage = "$(Configuration)"%3B
}
}
]]>
</InformationalData>
</PropertyGroup>
<PropertyGroup>
<GitGeneratedFilePath>$(IntermediateOutputPath)GitAssemblyInformation.g.cs</GitGeneratedFilePath>
<InformationalGeneratedFilePath>$(IntermediateOutputPath)InformationalAssemblyInformation.g.cs</InformationalGeneratedFilePath>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(GitGeneratedFilePath)" />
<FileWrites Include="$(GitGeneratedFilePath)" />
<Compile Include="$(InformationalGeneratedFilePath)" />
<FileWrites Include="$(InformationalGeneratedFilePath)" />
</ItemGroup>
<WriteLinesToFile Lines="$(GitData)" File="$(GitGeneratedFilePath)" WriteOnlyWhenDifferent="true" Overwrite="true" />
<WriteLinesToFile Lines="$(InformationalData)" File="$(InformationalGeneratedFilePath)"
WriteOnlyWhenDifferent="true" Overwrite="true" />
</Target>
<PropertyGroup>
<AssemblyTitle>$(Title)</AssemblyTitle>
<AssemblyDescription>$(Description)</AssemblyDescription>
<Copyright>Copyright © XCP-ng</Copyright>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/xcp-ng/xenadmin</RepositoryUrl>
<RevisionNumber>$([System.DateTime]::Now.ToString("yy"))$([System.DateTime]::Now.DayOfYear.ToString("D3"))</RevisionNumber>
<Authors>XCP-ng</Authors>
<Product>XCP-ng Center</Product>
<Version>0.0.0.$(RevisionNumber)</Version>
<FileVersion>0.0.0.$(RevisionNumber)</FileVersion>
<Codename>Medicine Hat</Codename>
<Lab>xcpngcenter_main</Lab>
</PropertyGroup>
</Project>