GoRoS had the right idea, but it only works correctly for the first time.
To avoid this problem, you need to run this code or similar code in another AppDomain from the build agent, Powershell and InvokeProcessActivity to solve our problem.
GetAssemblyVersionNumber.ps1:
$error.clear() if ($args.length -ne 1) { Write-Error "Usage: GetAssemblyVersionNumber.ps1 <Assembly>" exit 1 }
The following is added to the assembly process template.
InvokeProcessActivity Name: Call Powershell Version Script Filename: "powershell.exe" Arguments: "-NonInteractive -NoProfile -Command " _ + "c:\Builds\GetAssemblyVersionNumber.ps1" _ + " '" + BuildDirectory + "\Binaries\Foobar.dll'" Handle Standard Output (stdOutput) AssignActivity To: VersionInfo Value: stdOutput
source share