From 57ad2d57fd1655e0544e194fe4a53809b89bce99 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett (MSFT)" Date: Thu, 18 Jul 2019 11:23:34 -0700 Subject: [PATCH] Roll up dependencies through TerminalApp so the package is right (#2018) This commit includes a script and build step to make sure the MSIX doesn't continue to regress --- .../templates/build-console-steps.yml | 8 ++ build/scripts/Test-WindowsTerminalPackage.ps1 | 79 +++++++++++++++++++ .../CascadiaPackage/CascadiaPackage.wapproj | 18 ----- .../WindowsTerminal/WindowsTerminal.vcxproj | 46 ++--------- 4 files changed, 92 insertions(+), 59 deletions(-) create mode 100644 build/scripts/Test-WindowsTerminalPackage.ps1 diff --git a/build/pipelines/templates/build-console-steps.yml b/build/pipelines/templates/build-console-steps.yml index ec26880be4..61bc4a753b 100644 --- a/build/pipelines/templates/build-console-steps.yml +++ b/build/pipelines/templates/build-console-steps.yml @@ -46,6 +46,14 @@ steps: clean: true maximumCpuCount: true +- task: PowerShell@2 + displayName: 'Check MSIX for common regressions' + inputs: + targetType: inline + script: | + $Package = Get-ChildItem -Recurse -Filter "CascadiaPackage_*.msix" + .\build\scripts\Test-WindowsTerminalPackage.ps1 -Verbose -Path $Package.FullName + - task: VSTest@2 displayName: 'Run Unit Tests' inputs: diff --git a/build/scripts/Test-WindowsTerminalPackage.ps1 b/build/scripts/Test-WindowsTerminalPackage.ps1 new file mode 100644 index 0000000000..ca4d3df3d5 --- /dev/null +++ b/build/scripts/Test-WindowsTerminalPackage.ps1 @@ -0,0 +1,79 @@ +[CmdletBinding()] +Param( + [Parameter(Mandatory=$true, ValueFromPipeline=$true, + HelpMessage="Path to the .appx/.msix to validate")] + [string] + $Path, + + [Parameter(HelpMessage="Path to Windows Kit")] + [ValidateScript({Test-Path $_ -Type Leaf})] + [string] + $WindowsKitPath = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0" +) + +$ErrorActionPreference = "Stop" + +If ($null -Eq (Get-Item $WindowsKitPath -EA:SilentlyContinue)) { + Write-Error "Could not find a windows SDK at at `"$WindowsKitPath`".`nMake sure that WindowsKitPath points to a valid SDK." + Exit 1 +} + +$makeAppx = "$WindowsKitPath\x86\MakeAppx.exe" +$makePri = "$WindowsKitPath\x86\MakePri.exe" + +Function Expand-ApplicationPackage { + Param( + [Parameter(Mandatory, ValueFromPipeline)] + [string] + $Path + ) + + $sentinelFile = New-TemporaryFile + $directory = New-Item -Type Directory "$($sentinelFile.FullName)_Package" + Remove-Item $sentinelFile -Force -EA:Ignore + + & $makeAppx unpack /p $Path /d $directory /nv /o + + If ($LastExitCode -Ne 0) { + Throw "Failed to expand AppX" + } + + $directory +} + +Write-Verbose "Expanding $Path" +$AppxPackageRoot = Expand-ApplicationPackage $Path +$AppxPackageRootPath = $AppxPackageRoot.FullName + +Write-Verbose "Expanded to $AppxPackageRootPath" + +Try { + & $makePri dump /if "$AppxPackageRootPath\resources.pri" /of "$AppxPackageRootPath\resources.pri.xml" /o + If ($LastExitCode -Ne 0) { + Throw "Failed to dump PRI" + } + + $Manifest = [xml](Get-Content "$AppxPackageRootPath\AppxManifest.xml") + $PRIFile = [xml](Get-Content "$AppxPackageRootPath\resources.pri.xml") + + ### Check the activatable class entries for a few DLLs we need. + $inProcServers = $Manifest.Package.Extensions.Extension.InProcessServer.Path + $RequiredInProcServers = ("TerminalApp.dll", "TerminalControl.dll", "TerminalConnection.dll") + + Write-Verbose "InProc Servers: $inProcServers" + + ForEach ($req in $RequiredInProcServers) { + If ($req -NotIn $inProcServers) { + Throw "Failed to find $req in InProcServer list $inProcServers" + } + } + + ### Check that we have an App.xbf (which is a proxy for our resources having been merged) + $resourceXpath = '/PriInfo/ResourceMap/ResourceMapSubtree[@name="Files"]/NamedResource[@name="App.xbf"]' + $AppXbf = $PRIFile.SelectSingleNode($resourceXpath) + If ($null -eq $AppXbf) { + Throw "Failed to find App.xbf (TerminalApp project) in resources.pri" + } +} Finally { + Remove-Item -Recurse -Force $AppxPackageRootPath +} diff --git a/src/cascadia/CascadiaPackage/CascadiaPackage.wapproj b/src/cascadia/CascadiaPackage/CascadiaPackage.wapproj index f17debf7b3..52e3d3bcaa 100644 --- a/src/cascadia/CascadiaPackage/CascadiaPackage.wapproj +++ b/src/cascadia/CascadiaPackage/CascadiaPackage.wapproj @@ -260,24 +260,6 @@ - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - diff --git a/src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj b/src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj index 5b1cf5137e..750008054f 100644 --- a/src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj +++ b/src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj @@ -74,51 +74,15 @@ - - - true - PreserveNewest - - - - - true - PreserveNewest - - - + - + + + - - - - - - <_BinRoot Condition="'$(Platform)' != 'Win32'">$(OpenConsoleDir)$(Platform)\$(Configuration)\ - <_BinRoot Condition="'$(Platform)' == 'Win32'">$(OpenConsoleDir)$(Configuration)\ - - - - - - $(_BinRoot)\TerminalApp\TerminalApp.winmd - true - false - false - - -