Search code examples
c#uwpdesktop-bridgeappxmanifest

Package Personal Windows Universal App windows.fullTrustProcess


It's the first time I make a Windows Universal application and I was not able to make everything in my UWP app (for example it's impossible to start a command line Process). Since this is a personal app (I don't want to put it on the store) I used windows.fullTrustProcess to start a WPF win32 application to make what I was not able to do in my main application. I was also forced use UWP because I need a WebView able to play fullscreen html5 videos.

When I try to use my application inside Visual Studio 2017 everything work, but when I try to make a package I get this error:

"Manifest validation error: Line 28, Column 64, Reason: The file name "Backend-Mini-Browser.exe" declared for element "[local-name()='Applications']/[local-name()='Application']/[local-name()='Extensions']/[local-name()='Extension' and @Category='windows.fullTrustProcess']" doesn't exist in the package."

But my "Backend-Mini-Browser.exe" it's in the "..\bin\x64\Debug\AppX" folder and everything work inside Visual Studio 2017.

Here my appxmanifest:

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" IgnorableNamespaces="uap mp desktop rescap">
  <Identity Name="2579cda2-1e8c-48ee-829a-b1d276066cfe" Publisher="CN=Certimeter" Version="1.0.3.0" />
  <mp:PhoneIdentity PhoneProductId="2579cda2-1e8c-48ee-829a-b1d276066cfe" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
  <Properties>
    <DisplayName>Mini-browser</DisplayName>
    <PublisherDisplayName>Certimeter</PublisherDisplayName>
    <Logo>Assets\StoreLogo.png</Logo>
  </Properties>
  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
  </Dependencies>
  <Resources>
    <Resource Language="x-generate" />
  </Resources>
  <Applications>
    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="Mini_browser.App">
    <uap:VisualElements DisplayName="Mini-browser" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="Mini-browser" BackgroundColor="transparent">
    <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
    </uap:DefaultTile>
    <uap:SplashScreen Image="Assets\SplashScreen.png" />
  </uap:VisualElements>
  <Extensions>
    <desktop:Extension Category="windows.fullTrustProcess" Executable="Backend-Mini-Browser.exe" />
  </Extensions>
</Application>
 </Applications>
<Capabilities>
  <Capability Name="internetClient" />
  <uap:Capability Name="picturesLibrary" />
  <rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

Here:

<rescap:Capability Name="runFullTrust" />

I have a warning: The element "Capabilities" in the namespace "http://schemas.microsoft.com/appx/manifest/foundation/windows10" has a not valid child "Capability" in the namespace "http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities". List of possible: "CapabilityChoice" in the namespace "http://schemas.microsoft.com/appx/manifest/foundation/windows10" and "Capability" in the namespace "http://schemas.microsoft.com/appx/manifest/uap/windows10" and "Capability" in the namespace "http://schemas.microsoft.com/appx/manifest/foundation/windows10" and "Capability" in the namespace "http://schemas.microsoft.com/appx/manifest/uap/windows10/4" and "Capability" in the namespace "http://schemas.microsoft.com/appx/manifest/uap/windows10/3" and "Capability" in the namespace "http://schemas.microsoft.com/appx/manifest/uap/windows10/2" and "CustomCapabilityChoice" in the namespace "http://schemas.microsoft.com/appx/manifest/foundation/windows10" and "CustomCapability" in the namespace "http://schemas.microsoft.com/appx/manifest/uap/windows10/4" and "DeviceCapability" in the namespace "http://schemas.microsoft.com/appx/manifest/foundation/windows10".

(this warning is traslated in english by me, but I don't think this is the main problem).


Solution

  • Two things you need to do:

    1) place the full trust EXE in a subfolder of the package, not the package root

    2) explicitly include the .EXE file in the UWP project

    For #2, select "Show all files" in the solution explorer, then right click on the .EXE file and select "Include in project".

    Here is an example you can compare with: https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/UWP%20Systray

    EDIT Updating my answer since the VS support has become much better for this type of scenario since I first answered this. I have produced a couple of blog posts and samples to further clarify how this can be done now with the latest updates to VS 2017:

    https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/