Skip to content

Commit 16d1e17

Browse files
committed
fix uci installer deployment
1 parent 067811e commit 16d1e17

4 files changed

Lines changed: 27 additions & 24 deletions

File tree

IntelPresentMon/PMInstaller/PMInstaller.wixproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
<!-- Build the wixlib first -->
140140
<MSBuild Projects="..\PMInstallerLib\PMInstallerLib.wixproj"
141141
Targets="Build"
142-
Properties="Configuration=$(Configuration);Platform=$(Platform)" />
142+
Properties="Configuration=$(Configuration);Platform=$(Platform);PMON_UCI_SDK_DIR=$(PMON_UCI_SDK_DIR)" />
143143
<ItemGroup>
144144
<WixLibrary Include="$(SolutionDir)build\$(Configuration)\PMInstallerLib.wixlib"
145145
Condition="Exists('$(SolutionDir)build\$(Configuration)\PMInstallerLib.wixlib')" />

IntelPresentMon/PMInstallerLib/PMInstallerLib.wixproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</PropertyGroup>
1818
<ItemGroup>
1919
<Compile Include="Library.wxs" />
20-
<Compile Include="UciDist.wxs" />
20+
<Compile Include="$(IntermediateOutputPath)\UciDist.wxs" />
2121
</ItemGroup>
2222
<ItemGroup>
2323
<ProjectReference Include="..\PresentMonAPI2\PresentMonAPI2.vcxproj">
@@ -37,8 +37,9 @@
3737
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
3838
</ProjectReference>
3939
</ItemGroup>
40-
<Target Name="BeforeBuild">
41-
<Exec Command="powershell -NoProfile -ExecutionPolicy Bypass -File &quot;$(MSBuildProjectDirectory)\wix-uci-dist.ps1&quot;" />
40+
<Target Name="GenerateUciDistFragment" BeforeTargets="Compile">
41+
<MakeDir Directories="$(IntermediateOutputPath)" />
42+
<Exec Command="powershell -NoProfile -ExecutionPolicy Bypass -File &quot;$(MSBuildProjectDirectory)\wix-uci-dist.ps1&quot; -UciSdkDir &quot;$(UciSdkDir)&quot; -OutPath &quot;$(IntermediateOutputPath)\UciDist.wxs&quot;" />
4243
</Target>
4344
<Import Project="$(WixTargetsPath)" />
4445
</Project>

IntelPresentMon/PMInstallerLib/UciDist.wxs

Lines changed: 0 additions & 6 deletions
This file was deleted.

IntelPresentMon/PMInstallerLib/wix-uci-dist.ps1

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
[CmdletBinding()]
2-
param()
1+
[CmdletBinding()]
2+
param(
3+
[string]$UciSdkDir,
4+
[string]$OutPath = 'UciDist.wxs'
5+
)
36

47
function 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

6371
if (-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

7078
if ($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
99107
if ($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)
132140
try {
133141
$doc.Save($writer)
134142
}

0 commit comments

Comments
 (0)