functions/Update-AssemblyInfo.ps1
function Update-AssemblyInfo { [CmdletBinding()] param( [Parameter(mandatory=$true)][string]$AssemblyVersionPattern ,[Parameter(mandatory=$true)][string]$AssemblyFileVersionPattern ,[Parameter()][string]$VersionChar = "J" ,[Parameter()][string]$BuildChar = "B" ,[Parameter(mandatory=$true)][string]$AssemblyCompany ,[Parameter(mandatory=$true)][string]$AssemblyCopyright ,[Parameter(mandatory=$true)][string]$AssemblyProduct ,[Parameter(mandatory=$true)][string]$SourceDirectory ,[Parameter(mandatory=$true)][int]$BuildId ) begin { $j= "{0}{1}" -f (Get-Date -f "yy"), ("{0:000}" -f [int](Get-Date -uformat %j)) $version = (Get-Date -f $AssemblyVersionPattern).Replace(".$VersionChar.",".$j.").Replace(".$BuildChar",".$BuildId") $fileVersion = (Get-Date -f $AssemblyFileVersionPattern).Replace(".$VersionChar.",".$j.").Replace(".$BuildChar",".$BuildId") } process { Get-ChildItem -Path $SourceDirectory -Recurse -Filter "*AssemblyInfo.*" | ForEach-Object{ $file = $_.FullName $fileContent = "" $fileContent = Get-Content($file) attrib $file -r Write-Host "**Assembly Changes for - $file start" $fileContent = FindOrReplaceAttribute $fileContent "Company" $AssemblyCompany $fileContent = FindOrReplaceAttribute $fileContent "Copyright" $AssemblyCopyright $fileContent = FindOrReplaceAttribute $fileContent "Product" $AssemblyProduct $fileContent = FindOrReplaceAttribute $fileContent "Version" $version $fileContent = FindOrReplaceAttribute $fileContent "FileVersion" $fileVersion $fileContent | Out-File $file Write-Host "**Assembly Changes for - $file end" } } end {} } |