Using Jenkins Version Environment Variable in the MSBuild step

后端 未结 4 822
情深已故
情深已故 2021-02-05 23:45

I\'m currently using the Jenkins \"Version Number Plug-In\" to set an Environment Variable for build version. This works fine within jenkins but i need a way to pass this to MSB

4条回答
  •  一向
    一向 (楼主)
    2021-02-06 00:20

    A very quick work around to this is to create a powershell task before your msbuild task. This is assuming you defined VERSION variable as above (without the %%). And you checked delete workspace before build starts.

    This is the code for the powershell task.

    gci -rec -Filter *AssemblyInfo* | ForEach { (Get-Content $_.FullName) | ForEach-Object {$_ -replace "1.0.0.0",$env:VERSION } | Set-Content $_.FullName}
    

提交回复
热议问题