Browse Source

Optimize update-assemblyinfo.ps1 build step

pull/2119/head
Siegfried Pammer 5 years ago
parent
commit
7eef6f2bfe
  1. 6
      BuildTools/update-assemblyinfo.ps1
  2. 14
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

6
BuildTools/update-assemblyinfo.ps1

@ -53,7 +53,7 @@ function gitCommitHash() { @@ -53,7 +53,7 @@ function gitCommitHash() {
if (No-Git) {
return "0000000000000000000000000000000000000000";
}
return (git rev-list "$baseCommit..HEAD") | Select -First 1;
return (git rev-list --max-count 1 HEAD);
}
function gitBranch() {
@ -150,7 +150,7 @@ try { @@ -150,7 +150,7 @@ try {
$out = $out.Replace('$INSERTVERSIONNAMEPOSTFIX$', $postfixVersionName);
$out = $out.Replace('$INSERTBUILDCONFIG$', $buildConfig);
if (((Get-Content $file.Input) -Join [System.Environment]::NewLine) -ne $out) {
if (((Get-Content $file.Output) -Join [System.Environment]::NewLine) -ne $out) {
$out | Out-File -Encoding utf8 $file.Output;
}
}
@ -174,7 +174,7 @@ try { @@ -174,7 +174,7 @@ try {
$out = $out.Replace('$INSERTVERSIONNAMEPOSTFIX$', $postfixVersionName);
$out = $out.Replace('$INSERTBUILDCONFIG$', $buildConfig);
if (((Get-Content $file.Input) -Join [System.Environment]::NewLine) -ne $out) {
if (((Get-Content $file.Output) -Join [System.Environment]::NewLine) -ne $out) {
$out | Out-File -Encoding utf8 $file.Output;
}
}

14
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -640,13 +640,25 @@ @@ -640,13 +640,25 @@
</ItemGroup>
<Target Name="ILSpyUpdateAssemblyInfo" BeforeTargets="BeforeBuild">
<ItemGroup>
<UpdateAssemblyInfoStamp Include="obj\update-assemblyinfo-last-commit-hash.txt" />
</ItemGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<UpdateAssemblyInfo>powershell -NoProfile -ExecutionPolicy Bypass -File BuildTools/update-assemblyinfo.ps1 $(Configuration)</UpdateAssemblyInfo>
<GitRevParse>git rev-parse HEAD^^{commit}</GitRevParse>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
<UpdateAssemblyInfo>pwsh -NoProfile -ExecutionPolicy Bypass -File BuildTools/update-assemblyinfo.ps1 $(Configuration)</UpdateAssemblyInfo>
<GitRevParse>git rev-parse HEAD^{commit}</GitRevParse>
</PropertyGroup>
<Exec WorkingDirectory=".." Command="$(UpdateAssemblyInfo)" Timeout="60000" />
<ReadLinesFromFile ContinueOnError="true" File="@(UpdateAssemblyInfoStamp)">
<Output TaskParameter="Lines" PropertyName="LastCommitHash" />
</ReadLinesFromFile>
<Exec ContinueOnError="true" WorkingDirectory=".." Command="$(GitRevParse)" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="CommitHash" />
</Exec>
<Exec WorkingDirectory=".." Command="$(UpdateAssemblyInfo)" Timeout="60000" Condition="'$(CommitHash)'!='$(LastCommitHash)'" />
<WriteLinesToFile Lines="$(CommitHash)" File="@(UpdateAssemblyInfoStamp)" Overwrite="true" Condition="'$(CommitHash)'!='$(LastCommitHash)'" />
</Target>
</Project>
Loading…
Cancel
Save