Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while creating app package with "fullTrustProcess" pointing to a executable

I am trying to deploy the sample application for bridging AppServices with a UWP application. The sample runs and builds just fine but when I try to follow the guide to package the whole thing it gives me an error.

Link to the packaging guide

AppService Bridge Sample repository here.

Error message:

 Error Manifest validation error: Line 36, Column 64, Reason: The file name  "BackgroundProcess.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.

I've found the code-snippet generating the error, but I have haven't found a fix for it yet.

If I remove the following code from the file Package.appxmanifest, visual studio successfully builds the package:

<Extensions>
  <uap:Extension Category="windows.appService">
    <uap:AppService Name="CommunicationService" />
  </uap:Extension>
  <desktop:Extension Category="windows.fullTrustProcess" Executable="BackgroundProcess.exe" />
</Extensions>

But this will clearly also remove the bridging to the process which is the whole point of this exercise.

This seems to be somewhat related to this question but the difference is I have a .exe and that question seems to answer it for .dlls:

Error when building universal app for the store: "Manifest references file 'MyAppName.dll' which is not part of the payload."

(Updating UWP Tools did not seem to fix it.)

like image 751
Mattias Avatar asked Aug 11 '16 17:08

Mattias


2 Answers

I seem to get the package creation working. Being quite desperate already I tried to use C++ console instead of C#, as in AppServiceBridgeSample_C++ sample. I only had to add the Win32Process_CPP.exe file to UWP project and mark it as Content with Copy if newer flag. After that the Create App Packages operation succeeds. But just simple changing the C++ console back to a C# one resulted to failure again - quite strange!

As I have found, the main problem is known and described in docs:

If you prefer to use a C# project to package your app, you need to be aware of the following known issues:

Win32 Binaries stored in the root folder of the UWP project are removed in Release. If you don't use a folder to store your Win32 binaries, the .NET Native compiler will remove those from the final package, resulting in a manifest validation error since the executable entry point can't be found.

Solution to this issue was simple:

  1. Create a directory (e.g. win32) in UWP project root. This is the place where the console binary (BackgroundProcess.exe) has to be placed.

    So you get e.g. c:\test\AppServiceBridgeSample\cs\UWP\win32

  2. Edit the desktop:Extension element in Package.appxmanifest - add the folder to the Executable attribute value:

    <desktop:Extension Category="windows.fullTrustProcess" Executable="win32\BackgroundProcess.exe" />

  3. Add the BackgroundProcess.exe binary from the newly created folder to your UWP project. In its properties set the BuildAction attribute to Content and Copy to Output Directory to Copy if newer.

The package should now get created.

Note: If you run AppCertKit (WACK) with the created package, you may get failure due to using rescap namespace (which is reserved for Microsoft and its partner vendors only, see here). The BinaryAnalyzer.AppContainerCheck will probably fail as well, due to call of unprotected binary.

like image 129
kibitzerCZ Avatar answered Sep 30 '22 13:09

kibitzerCZ


I am posting here because I found my own answer after several hours of investigation. Hopefully, this will help others in the future!

So the problem is that the BackgroundProcess.exe is not included in the project when building the package. Which files to be included in the project is defined in the .csproj file. Open it in your preferred text editor (remember to close Visual Studio before)

Add where the assets are defined:

<ItemGroup>
  <Content Include="Properties\Default.rd.xml" />
  <Content Include="Assets\LockScreenLogo.scale-200.png" />
  <Content Include="Assets\SplashScreen.scale-200.png" />
  <Content Include="Assets\Square150x150Logo.scale-200.png" />
  <Content Include="Assets\Square44x44Logo.scale-200.png" />
  <Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
  <Content Include="Assets\StoreLogo.png" />
  <Content Include="Assets\Wide310x150Logo.scale-200.png" />
</ItemGroup>

To something like this:

<ItemGroup>
  <Content Include="Properties\Default.rd.xml" />
  <Content Include="Assets\LockScreenLogo.scale-200.png" />
  <Content Include="Assets\SplashScreen.scale-200.png" />
  <Content Include="Assets\Square150x150Logo.scale-200.png" />
  <Content Include="Assets\Square44x44Logo.scale-200.png" />
  <Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
  <Content Include="Assets\StoreLogo.png" />
  <Content Include="Assets\Wide310x150Logo.scale-200.png" />
  <Content Include="AppServiceBridgeSample.BackgroundProcess.exe">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </Content>
</ItemGroup>

Note that I have added AppServiceBridgeSample.BackgroundProcces.exe ass the namespace of the file. I don't know if this is completely necessary but this is how I fixed it. So to fix the namespace you have to add AppServiceBridgeSample before all the classes. And also in the properties of the BackgroundProcess project under Application > Assembly name & Default namespace add the extension.

Example class:

namespace AppServiceBridgeSample.BackgroundProcess
{
    class Program
    {
    ....
    }
}

And .xaml example:

<Page
  x:Class="AppServiceBridgeSample.UWP.MainPage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="using:AppServiceBridgeSample.UWP"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  x:Name="Main"
  mc:Ignorable="d">
  ...
</Page>

Also this does not automaticly fix the error I was having, you also have to add a Build Event, right click on BackgroundProcess (project in VS) > properties > Build Events > Under Post-Build events command line add:

xcopy /y /s "$(TargetPath)" "$(SolutionDir)UWP"

Build and Deploy the solution and the AppServiceBridgeSample.BackgroundProcess.exe file should be present in the UWP project root (visible in file explorer).

Also, I updated to Visual Studio 15 Enterprise Preview 3 during this investigation which maybe also helped somewhat if you would encounter other errors.

like image 43
Mattias Avatar answered Sep 30 '22 14:09

Mattias