Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Fix encoding of nuspec (utf-8 no bom) and ps1 (utf-8 bom) files #60

Merged
merged 1 commit into from
Dec 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions AU/Private/AUPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ class AUPackage {
$nu.Load($NuspecPath)
return $nu
}

SaveNuspec(){
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($False)
[System.IO.File]::WriteAllText($this.NuspecPath, $this.NuspecXml.InnerXml, $Utf8NoBomEncoding)
}
}
7 changes: 3 additions & 4 deletions AU/Public/Update-Package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -232,23 +232,22 @@ function Update-Package {
$msg | result

$package.NuspecXml.package.metadata.version = $package.RemoteVersion.ToString()
$package.NuspecXml.Save($package.NuspecPath)
$package.SaveNuspec()
}

$sr = au_SearchReplace
$sr.Keys | % {
$fileName = $_
" $fileName" | result

$fileContent = gc $fileName -Encoding UTF8
$fileContent = gc $fileName
$sr[ $fileName ].GetEnumerator() | % {
(' {0} = {1} ' -f $_.name, $_.value) | result
if (!($fileContent -match $_.name)) { throw "Search pattern not found: '$($_.name)'" }
$fileContent = $fileContent -replace $_.name, $_.value
}

$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($False)
[System.IO.File]::WriteAllLines((gi $fileName).FullName, $fileContent, $Utf8NoBomEncoding)
$fileContent | Out-File -Encoding UTF8 $fileName
}
}

Expand Down