Allow setting the commit id using /p:LatestCommit
This is similar to how CommitCount is already supported. This lets consumers who are building outside a git repo, such as source-build, set a commit id which is displayed by `dotnet --info` and `strings dotnet | grep '@(#)'`. See: https://github.com/dotnet/source-build/issues/651 See: https://github.com/dotnet/cli/pull/5945
This commit is contained in:
Родитель
976dbf2a69
Коммит
e02ee86364
|
@ -17,7 +17,8 @@
|
||||||
<Exec Command="$(DotnetToolCommand) build $(MSBuildThisFileDirectory)tools-local/tasks/core-setup.tasks.csproj" />
|
<Exec Command="$(DotnetToolCommand) build $(MSBuildThisFileDirectory)tools-local/tasks/core-setup.tasks.csproj" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="GetLatestCommitHash">
|
<Target Name="GetLatestCommitHash"
|
||||||
|
Condition="'$(LatestCommit)' == ''">
|
||||||
<!-- Get the latest commit hash -->
|
<!-- Get the latest commit hash -->
|
||||||
<Exec Command="git rev-parse HEAD 2>&1" StandardOutputImportance="Low" IgnoreExitCode="true" IgnoreStandardErrorWarningFormat="true" ConsoleToMSBuild="true">
|
<Exec Command="git rev-parse HEAD 2>&1" StandardOutputImportance="Low" IgnoreExitCode="true" IgnoreStandardErrorWarningFormat="true" ConsoleToMSBuild="true">
|
||||||
<Output TaskParameter="ConsoleOutput" PropertyName="LatestCommit" />
|
<Output TaskParameter="ConsoleOutput" PropertyName="LatestCommit" />
|
||||||
|
@ -29,13 +30,13 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="GetCommitCount">
|
<Target Name="GetCommitCount"
|
||||||
|
Condition="'$(CommitCount)' == ''">
|
||||||
<Exec Command="git rev-list --count HEAD"
|
<Exec Command="git rev-list --count HEAD"
|
||||||
StandardOutputImportance="Low"
|
StandardOutputImportance="Low"
|
||||||
IgnoreExitCode="true"
|
IgnoreExitCode="true"
|
||||||
IgnoreStandardErrorWarningFormat="true"
|
IgnoreStandardErrorWarningFormat="true"
|
||||||
ConsoleToMSBuild="true"
|
ConsoleToMSBuild="true">
|
||||||
Condition="'$(CommitCount)' == ''">
|
|
||||||
<Output TaskParameter="ConsoleOutput" PropertyName="CommitCount" />
|
<Output TaskParameter="ConsoleOutput" PropertyName="CommitCount" />
|
||||||
<Output TaskParameter="ExitCode" PropertyName="CommitCountExitCode" />
|
<Output TaskParameter="ExitCode" PropertyName="CommitCountExitCode" />
|
||||||
</Exec>
|
</Exec>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче