Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions eng/devices/windows.cake
Original file line number Diff line number Diff line change
Expand Up @@ -350,19 +350,33 @@ Task("testOnly")
var cerPath = cerPaths.First();
Information($"Found MSIX, installing: {msixPath}");

int InstallAppxPackage(FilePath path) {
var absPath = MakeAbsolute(path).FullPath;
Information("Installing MSIX: {0}", absPath);
// $ProgressPreference='SilentlyContinue' suppresses Add-AppxPackage's
// progress output which otherwise chokes cake's stdout pipe.
return StartProcess("powershell",
"-NoProfile -Command \"$ProgressPreference='SilentlyContinue'; Add-AppxPackage -Path '" + absPath + "'; if (-not $?) { exit 1 }\"");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Build & MSBuild / Windows Platform - This embeds the MSIX path directly into a PowerShell -Command string using single quotes and -Path. A checkout/build path containing an apostrophe (for example C:\Users\O'Brien\...) will break the PowerShell string, and -Path still treats wildcard characters such as [/] specially. Since this helper is meant to make MSIX install robust, pass the path out-of-band (for example via an environment variable) and call Add-AppxPackage -LiteralPath $env:MAUI_MSIX_PATH, or at minimum escape single quotes and use -LiteralPath.

}

// Install dependencies
var dependencies = GetFiles(projectDir.FullPath + "/**/AppPackages/**/Dependencies/x64/*.msix");
foreach (var dep in dependencies) {
Information("Installing Dependency MSIX: {0}", dep);
try {
StartProcess("powershell", "Add-AppxPackage -Path \"" + MakeAbsolute(dep).FullPath + "\"");
} catch {
var depExit = InstallAppxPackage(dep);
if (depExit != 0) {
Warning($"Failed to install dependency (exit code {depExit}): {dep}");
}
} catch {
Warning($"Failed to install dependency: {dep}");
}
}

// Install the DeviceTests app
StartProcess("powershell", "Add-AppxPackage -Path \"" + MakeAbsolute(msixPath).FullPath + "\"");
var installExit = InstallAppxPackage(msixPath);
if (installExit != 0) {
throw new Exception($"Failed to install app MSIX (exit code {installExit}): {msixPath}");
}

if (isControlsProjectTestRun)
{
Expand Down
Loading