I would just run a PowerShell task with something like the below example:
<div class="code">
</div>
a=b+c
$oldValue = 'default-value'
$newValue = '$(Build.BuildId)'
$filePath='path-to-your-file/filename.txt'
(Get-Content $filePath) -replace $oldValue , $newValue | Set-Content $filePath