Update assemblyinfo.cs for a maintenance release

Function update_assemblyinfo_cs($path)
{
#[Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8
LogWrite “#####################################################”
LogWrite “### Update the assemblyinfo.cs files              ###”
LogWrite “#####################################################”

$stanzaToFind = “BUILD_TSM_V” + $global:version + $global:release + $global:level
$oldStanzaToFind = “BUILD_TSM_V” + $global:previousVersion + $global:previousRelease + $global:previousLevel

Get-ChildItem $path -Recurse -Filter “assemblyinfo.cs” | ForEach-Object {
$inFileName = $_.FullName
LogWrite “Looking for this stanza $stanzaToFind in $inFileName”

$tmpDir= Split-Path $inFileName
$tmpFile = “assemblyinfo_tmp.cs”
$tempOutFile = Join-Path $tmpDir $tmpFile

$stanzaFound = $false
$parseReleaseH = Get-Content $inFileName -encoding UTF8
for ($index = 0; $index -lt $parseReleaseH.count; $index++)
{
if ($parseReleaseH[$index] | Select-String -Pattern $stanzaToFind)
{
$stanzaFound = $true
LogWrite “New stanza $stanzaToFind already found. SKIP IT !!!”
break
}
}
if (-Not $stanzaFound) {
$oldStanzaFound = $False
for ($index = 0; $index -lt $parseReleaseH.count; $index++)
{
if ($parseReleaseH[$index] | Select-String -Pattern $oldStanzaToFind)
{
$parseReleaseH[$index] | Out-File $tempOutFile -Append -encoding UTF8
$oldStanzaFound = $True
LogWrite “Old stanza $stanzaToFind found”
}
elseif ( $oldStanzaFound -And ($parseReleaseH[$index] | Select-String -Pattern “#endif”) )
{
LogWrite “Adding the new stanza $stanzaToFind”
“#elif $stanzaToFind” | Out-File $tempOutFile -Append -encoding UTF8
”  [assembly: AssemblyVersion(“”$global:newIFixVer””)]” | Out-File $tempOutFile -Append -encoding UTF8
”  [assembly: AssemblyFileVersion(“”$global:newIFixVer””)]” | Out-File $tempOutFile -Append -encoding UTF8
“#endif” | Out-File $tempOutFile -Append -encoding UTF8
}
else {
$parseReleaseH[$index] | Out-File $tempOutFile -Append -encoding UTF8
}
}
## The temp file was udpated, now copy it over to original.
Move-Item -path $tempOutFile -destination $inFileName -force
}

update_content -filename $_.Name -path $tmpDir -searchfor “\s(.+)`”Copyright\s(.+)” -replacewith ” AssemblyCopyright(`”Copyright $([char]0x00A9) IBM $global:currentYear`”)]” -encoding UTF8
#    update_content -filename $_.Name -path $tmpDir -searchfor “\s(.+)$([char]0x00A0)\s(.+)” -replacewith “” -encoding UTF8

#     ## Suppress the BOM
#     $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($False)
#     $contents = Get-Content $inFileName -encoding UTF8
#     [System.IO.File]::WriteAllLines($inFileName, $contents, $Utf8NoBomEncoding)

#     & $global:rtcLSMC logout -r $global:rtcUrl
#     $output = (& $global:rtcLSMC login -r $global:rtcUrl -u $global:rtcUser -P $global:rtcPwd) | Out-String
#     LogWrite $output
#     $output = (& $global:rtcLSMC set property file.encoding UTF-8 $inFileName) | Out-String
#     LogWrite $output
}
}

Advertisements
This entry was posted in develop and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s