From 69769cede79b87ea3ddea021799a9622ea6d5106 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 14 Jun 2016 16:48:20 -0700 Subject: [PATCH] Fix build.psm1 to account for LocalAccount dll --- build.psm1 | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/build.psm1 b/build.psm1 index 518d65709..a82565c9a 100644 --- a/build.psm1 +++ b/build.psm1 @@ -871,14 +871,26 @@ function Start-ResGen "Microsoft.PowerShell.Commands.Utility", "Microsoft.PowerShell.ConsoleHost", "Microsoft.PowerShell.CoreCLR.Eventing", +"Microsoft.PowerShell.LocalAccounts", "Microsoft.PowerShell.Security", "System.Management.Automation") | % { $module = $_ ls "$PSScriptRoot/src/$module/resources" | % { $className = $_.Name.Replace('.resx', '') $xml = [xml](cat -raw $_.FullName) - $genSource = Get-StronglyTypeCsFileForResx -xml $xml -ModuleName $module -ClassName $className - $outPath = "$PSScriptRoot/src/windows-build/gen/$module/$className.cs" + + $fileName = $className + $namespace = '' + + $lastIndexOfDot = $className.LastIndexOf(".") + if ($lastIndexOfDot -ne -1) + { + $namespace = $className.Substring(0, $lastIndexOfDot) + $className = $className.Substring($lastIndexOfDot + 1) + } + + $genSource = Get-StronglyTypeCsFileForResx -xml $xml -ModuleName $module -ClassName $className -NamespaceName $namespace + $outPath = "$PSScriptRoot/src/windows-build/gen/$module/$fileName.cs" log "ResGen for $outPath" mkdir -ErrorAction SilentlyContinue (Split-Path $outPath) > $null Set-Content -Encoding Ascii -Path $outPath -Value $genSource @@ -975,8 +987,9 @@ function script:Start-NativeExecution([scriptblock]$sb) function script:Get-StronglyTypeCsFileForResx { - param($xml, $ModuleName, $ClassName) -$body = @' + param($xml, $ModuleName, $ClassName, $NamespaceName = '') + +$banner = @' //------------------------------------------------------------------------------ // // This code was generated by a Start-ResGen funciton from build.psm1. @@ -987,6 +1000,16 @@ $body = @' // //------------------------------------------------------------------------------ +{0} +'@ + +$namespace = @' +namespace {0} {{ +{1} +}} +'@ + +$body = @' using System; using System.Reflection; @@ -1056,7 +1079,16 @@ internal class {0} {{ $entry -f $name,$val } } | Out-String - $resultCode = $body -f $ClassName,$ModuleName,$entries + + $bodyCode = $body -f $ClassName,$ModuleName,$entries + + if ($NamespaceName -ne '') + { + $bodyCode = $namespace -f $NamespaceName, $bodyCode + } + + $resultCode = $banner -f $bodyCode + return $resultCode -replace "`r`n?|`n","`r`n" }