1- [CmdletBinding ()]
2- param ()
1+ [CmdletBinding ()]
2+ param (
3+ [string ]$UciSdkDir ,
4+ [string ]$OutPath = ' UciDist.wxs'
5+ )
36
47function Get-DeterministicGuid {
58 param (
@@ -33,7 +36,7 @@ function Write-EmptyUciDistFragment {
3336 $settings.NewLineChars = " `r`n "
3437 $settings.NewLineHandling = [System.Xml.NewLineHandling ]::Replace
3538
36- $writer = [System.Xml.XmlWriter ]::Create(( Join-Path $PSScriptRoot $ OutPath) , $settings )
39+ $writer = [System.Xml.XmlWriter ]::Create($ OutPath, $settings )
3740 try {
3841 $writer.WriteStartDocument ()
3942 $writer.WriteStartElement (' Wix' , ' http://schemas.microsoft.com/wix/2006/wi' )
@@ -50,27 +53,32 @@ function Write-EmptyUciDistFragment {
5053 }
5154}
5255
53- Push-Location $PSScriptRoot
56+ if ([string ]::IsNullOrWhiteSpace($UciSdkDir )) {
57+ $UciSdkDir = $env: PMON_UCI_SDK_DIR
58+ }
59+ if ([string ]::IsNullOrWhiteSpace($UciSdkDir )) {
60+ $UciSdkDir = Join-Path $PSScriptRoot ' ..\ControlLib\uci\external'
61+ }
5462
55- $uciSdkDir = $env: PMON_UCI_SDK_DIR
56- if ([string ]::IsNullOrWhiteSpace($uciSdkDir )) {
57- $uciSdkDir = ' ..\ControlLib\uci\external'
63+ $distPath = Join-Path $UciSdkDir ' bin'
64+ $outDir = Split-Path - Parent $OutPath
65+ if (-not [string ]::IsNullOrWhiteSpace($outDir ) -and -not (Test-Path $outDir - PathType Container)) {
66+ New-Item - Path $outDir - ItemType Directory - Force | Out-Null
5867}
5968
60- $distPath = Join-Path $uciSdkDir ' bin'
61- $outPath = ' UciDist.wxs'
69+ Push-Location $PSScriptRoot
6270
6371if (-not (Test-Path $distPath - PathType Container)) {
6472 Pop-Location
6573 Write-Warning " UCI dist directory '$distPath ' was not found. Skipping UCI payload files."
66- Write-EmptyUciDistFragment - OutPath $outPath
74+ Write-EmptyUciDistFragment - OutPath $OutPath
6775 exit 0
6876}
6977
7078if ($null -eq (Get-ChildItem - Path $distPath - Recurse - File - Force | Select-Object - First 1 )) {
7179 Pop-Location
7280 Write-Warning " UCI dist directory '$distPath ' contains no files. Skipping UCI payload files."
73- Write-EmptyUciDistFragment - OutPath $outPath
81+ Write-EmptyUciDistFragment - OutPath $OutPath
7482 exit 0
7583}
7684
@@ -93,7 +101,7 @@ if (-not (Test-Path $heatExe)) {
93101 - cg uci_dist_files `
94102 - var var .UciDistDir `
95103 - suid - g1 - ag `
96- - out $outPath
104+ - out $OutPath
97105
98106$code = $LASTEXITCODE
99107if ($code -ne 0 ) {
@@ -102,7 +110,7 @@ if ($code -ne 0) {
102110 exit $code
103111}
104112
105- [xml ]$doc = Get-Content $outPath
113+ [xml ]$doc = Get-Content $OutPath
106114$ns = New-Object System.Xml.XmlNamespaceManager($doc.NameTable )
107115$ns.AddNamespace (' w' , ' http://schemas.microsoft.com/wix/2006/wi' )
108116
@@ -128,7 +136,7 @@ $settings.IndentChars = ' '
128136$settings.NewLineChars = " `r`n "
129137$settings.NewLineHandling = [System.Xml.NewLineHandling ]::Replace
130138
131- $writer = [System.Xml.XmlWriter ]::Create((Resolve-Path $outPath ), $settings )
139+ $writer = [System.Xml.XmlWriter ]::Create((Resolve-Path $OutPath ), $settings )
132140try {
133141 $doc.Save ($writer )
134142}
0 commit comments