MicrosoftDocs / msix-docs

repository for msix content
Creative Commons Attribution 4.0 International
59 stars 114 forks source link

MSIX after installed on C:\Program Files\WindowsApp read\write from a installed nugget package #356

Open kaidoatgit opened 1 year ago

kaidoatgit commented 1 year ago

Hello,

Im currently trying to publish a desktop application that uses Microsoft Playwright to automate few task, however it seems that im missing something... So after creating a windows package project in visual studio to package my application (Publish > Create Package > ...) I ended up with an installer: image The application installs correctly and all other dependencies such as API and Database are working correctly but Playwright is not working for some reason.

For testing purpose I've created a Mock project that has a simple button that calls playwright:

try
{
    var exitCode = Microsoft.Playwright.Program.Main(new[] { "install" });
    if (exitCode != 0)
    {
        Console.WriteLine("Failed to install browsers");
    }

    using var playwright = await Playwright.CreateAsync();
    await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions() { Headless = false });
    await using var browserContext = await browser.NewContextAsync();
    var page = await browserContext.NewPageAsync();
    await page.GotoAsync("https://www.google.com");
    await page.WaitForTimeoutAsync(10000f);
}
catch (Exception exception)
{
    output.Text = exception.Message + Environment.NewLine + exception.StackTrace + Environment.NewLine;
}

The package installation details: .NET CORE 6 Playwright package version: 1.27.2 Windows 10 x64

After the package is installed I run the application that looks like this: image

When the Test button is pressed, the above code runs and this is the final output: image

Playwright fails to install and therefore the launching/creation not working which I believe the exception is pointing to.

.playwright folder exist after installing my package image

It seems I cant run/execute any kind of action in this folder C:\Program Files\WindowsApps ... which means that I cant install playwright, even if playwright is installed manually the app cant launch it... All MSIX (package installers generated by Visual studio) are installed in this particular folder with high security.

Any clue how to solve this problem without getting access to this folder? Clients shouldnt unsecure this folder

Thanks.