diff --git a/build.psm1 b/build.psm1 index 3207df83a0..9c359fb1d6 100644 --- a/build.psm1 +++ b/build.psm1 @@ -986,6 +986,37 @@ function Find-Dotnet() { } } +<# + This is one-time convertion. We use it for to turn GetEventResources.txt into GetEventResources.resx + + .EXAMPLE Convert-TxtResourceToXml -Path Microsoft.PowerShell.Commands.Diagnostics\resources +#> +function Convert-TxtResourceToXml +{ + param( + [string[]]$Path + ) + + process + { + $Path | % { + Get-ChildItem $_ -Filter "*.txt" | % { + $txtFile = $_.FullName + $resxFile = Join-Path (Split-Path $txtFile) "$($_.BaseName).resx" + $resourceHashtable = ConvertFrom-StringData (Get-Content -Raw $txtFile) + $resxContent = $resourceHashtable.GetEnumerator() | % { +@' + + {1} + +'@ -f $_.Key, $_.Value + } | Out-String + Set-Content -Path $resxFile -Value ($script:RESX_TEMPLATE -f $resxContent) + } + } + } +} + function Start-XamlGen { [CmdletBinding()] @@ -1557,3 +1588,128 @@ function New-AppxPackage return $appxPackagePath } + + +$script:RESX_TEMPLATE = @' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + +{0} + +'@ \ No newline at end of file