修改.exe';s AssemblyInfo在TFS 2018构建中使用PowerShell
我想使用PowerShell更新应用程序的程序集信息,如TFS vNext build中的产品名称、文件描述。我想在构建定义中使用构建变量,并将其传递给脚本 我在this()的帮助下更新了版本号修改.exe';s AssemblyInfo在TFS 2018构建中使用PowerShell,powershell,tfs,build,assemblyinfo,Powershell,Tfs,Build,Assemblyinfo,我想使用PowerShell更新应用程序的程序集信息,如TFS vNext build中的产品名称、文件描述。我想在构建定义中使用构建变量,并将其传递给脚本 我在this()的帮助下更新了版本号 我需要脚本帮助以新值替换“Product Name”或“Description”值。您可以用小脚本替换名称和说明: Param( [string]$filePath, [string]$newProductName, [string]$newProductDesc ) $pat
我需要脚本帮助以新值替换“Product Name”或“Description”值。您可以用小脚本替换名称和说明:
Param(
[string]$filePath,
[string]$newProductName,
[string]$newProductDesc
)
$patternProductName = '\[assembly: AssemblyProduct\("(.*)"\)\]'
$patternProductDesc = '\[assembly: AssemblyDescription\("(.*)"\)\]'
(Get-Content $filePath) | ForEach-Object{
if($_ -match $patternProductName){
'[assembly: AssemblyProduct("{0}")]' -f $newProductName
}
elseif($_ -match $patternProductDesc){
'[assembly: AssemblyDescription("{0}")]' -f $newProductDesc
}
else{
$_
}
} | Set-Content $filePath
现在,在构建过程中,调用此脚本并在参数中发送3个参数:AssmeblyInfo文件路径、新产品名称和新产品说明。Small fix变量名称错误-$patternProductName='[assembly:AssemblyDescription((.*))]'应该是$patternProductDesc='[assembly:AssemblyDescription((.*))]',对于后代,我必须在Param部分的每个参数后面加逗号。@b.pell你说得对!我修好了。谢谢@ShaykiAbramczyk也感谢分享,这个PowerShell是一个非常节省时间的工具。