terminal/tools/GenerateAppxFromManifest.ps1

75 lines
2.8 KiB
PowerShell
Raw Normal View History

Add a Local Test binary, to enable local TerminalApp testing (#2294) In #1164 we learned that our CI doesn't support WinRT testing. This made us all sad. Since that merged, we haven't really added any TerminalApp tests, because it's a little too hard. You'd have to uncomment the entire file, and if the list of types changed you'd have to manually update the sxs manifest and appxmanifest. Since that was all insane, I created a new Terminal App unittesting project without those problems. 1. The project is not named *Unit*Test*, so the CI won't run it, but it will run locally. 2. The project will auto-generate its SxS manifest, using the work from #1987. 3. We'll use the SxS manifest from step 2 to generate an AppxManifest for running packaged tests. * This is the start of me trying to enable local unittesting again * We've got a new unittests project that isn't named *unit*test* * We're manually generating the SxS manifest for it. B/C we need to use it at runtime, we need to manually combine it into one manifest file * the runas:UAP thing still doesn't work. We'll investigate. * This shockingly works but I'm still stuck with: ``` Summary of Errors Outside of Tests: Error: TAEF: [HRESULT: 0x80270254] Failed to create the test host process for out of process test execution. (The IApplicationActivationManager::ActivateApplication call failed while using a default host. TAEF's ETW logs which are gathered with the /enableEtwLogging switch should contain events from relevant providers that may help to diagnose the failure.) ``` * Cleaning this all up for review. Frankly just pushing to see if it'll work in CI * Couple things I noticed in the diff from master * Apply @dhowett-msft's suggestions from code review
2019-08-13 15:23:28 +02:00
# This script is used for taking all the activatable classes from a SxS manifest
# and adding them as Extensions to an Appxmanifest.xml.
# Params:
# - SxSManifest: The path to the SxS manifest to get the types from
# - AppxManifestPrototype: The path to an AppxManifest.xml-style XML document to add the Extensions to
# - SxSManifest: The path to write the updated XML doc to.
param (
[parameter(Mandatory=$true, Position=0)]
[string]$SxSManifest,
[parameter(Mandatory=$true, Position=1)]
[string]$AppxManifestPrototype,
[parameter(Mandatory=$true, Position=2)]
[string]$OutPath
)
# Load the xml files.
[xml]$manifestData = Get-Content $SxSManifest
[xml]$appxPrototypeData = Get-Content $AppxManifestPrototype
# You need to make sure each element we add is part of the same namespace as the
# Package, otherwise powershell will append a bunch of `xmlns=""` properties
# that will make the appx deployment reject the manifest.
$rootNS = $appxPrototypeData.Package.NamespaceURI
# Create an XML element for all the extensions we're adding.
$Extensions = $appxPrototypeData.CreateNode("element", "Extensions", $rootNS)
$assembly = $manifestData.assembly
$files = $assembly.file
$files | ForEach-Object {
$Extension = $appxPrototypeData.CreateNode("element", "Extension", $rootNS)
$Extension.SetAttribute("Category", "windows.activatableClass.inProcessServer")
$InProcessServer = $appxPrototypeData.CreateNode("element", "InProcessServer", $rootNS)
$Path = $appxPrototypeData.CreateNode("element", "Path", $rootNS)
# You need to stash the result here, otherwise a blank line will be echoed to
Add a Local Test binary, to enable local TerminalApp testing (#2294) In #1164 we learned that our CI doesn't support WinRT testing. This made us all sad. Since that merged, we haven't really added any TerminalApp tests, because it's a little too hard. You'd have to uncomment the entire file, and if the list of types changed you'd have to manually update the sxs manifest and appxmanifest. Since that was all insane, I created a new Terminal App unittesting project without those problems. 1. The project is not named *Unit*Test*, so the CI won't run it, but it will run locally. 2. The project will auto-generate its SxS manifest, using the work from #1987. 3. We'll use the SxS manifest from step 2 to generate an AppxManifest for running packaged tests. * This is the start of me trying to enable local unittesting again * We've got a new unittests project that isn't named *unit*test* * We're manually generating the SxS manifest for it. B/C we need to use it at runtime, we need to manually combine it into one manifest file * the runas:UAP thing still doesn't work. We'll investigate. * This shockingly works but I'm still stuck with: ``` Summary of Errors Outside of Tests: Error: TAEF: [HRESULT: 0x80270254] Failed to create the test host process for out of process test execution. (The IApplicationActivationManager::ActivateApplication call failed while using a default host. TAEF's ETW logs which are gathered with the /enableEtwLogging switch should contain events from relevant providers that may help to diagnose the failure.) ``` * Cleaning this all up for review. Frankly just pushing to see if it'll work in CI * Couple things I noticed in the diff from master * Apply @dhowett-msft's suggestions from code review
2019-08-13 15:23:28 +02:00
# the console.
$placeholder = $Path.InnerText = $_.name
$InProcessServer.AppendChild($Path)
$Extension.AppendChild($InProcessServer) | Out-Null
foreach($class in $_.activatableClass) {
$ActivatableClass = $appxPrototypeData.CreateNode("element", "ActivatableClass", $rootNS)
$ActivatableClass.SetAttribute("ActivatableClassId", $class.name)
$ActivatableClass.SetAttribute("ThreadingModel", $class.threadingModel)
$InProcessServer.AppendChild($ActivatableClass) | Out-Null
}
$Extensions.AppendChild($Extension) | Out-Null
}
# Add our fully constructed list of extensions to the original Appxmanifest prototype
$appxPrototypeData.Package.AppendChild($Extensions) | Out-Null
# Write the modified xml back out.
$appxPrototypeData.save($OutPath)
# Left as a helper for debugging:
# $StringWriter = New-Object System.IO.StringWriter;
# $XmlWriter = New-Object System.Xml.XmlTextWriter $StringWriter;
# $XmlWriter.Formatting = "indented";
# $appxPrototypeData.WriteTo($XmlWriter);
# $XmlWriter.Flush();
# $StringWriter.Flush();
# Write-Output $StringWriter.ToString();