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

5

16

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.)

Geoff answered 11/8, 2016 at 17:50 Comment(0)
F
11

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.

Fissionable answered 31/5, 2017 at 13:1 Comment(2)
Many thanks for this solution. Very easy and effective.Sibyl
I did all those, but seems when I use MakeAppx alone, it works - package can be created, but when I use MSBuild, it contains MakeAppx, same parameter, same paths, still complains cannot find the .exeFunicular
G
9

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.

Geoff answered 13/8, 2016 at 14:2 Comment(1)
I have followed your steps but still I couldn't deploy the application. If you still have deploy able solution. Could you please share online.Apart
H
4

Wrong path will cause the same error.
For me, my wrong code is

<Extensions>
    <desktop:Extension Category="windows.startupTask" EntryPoint="Windows.FullTrustApplication" Executable="ClipboardEx.exe">
      <desktop:StartupTask DisplayName="ClipboardEx" Enabled="true" TaskId="ClipboardExStartUpId"/>
    </desktop:Extension>
</Extensions>

my project dir like this:

bin
│  ├─x64
│  │  └─Release
│  │      ├─AppX
│  │      │  ├─ClipboardEx
|  |      |  |  └─ClipboardEx.exe
│  │      │  ├─Images
│  │      │  └─WinMetadata

So I changed Executable fromClipboardEx.exetoClipboardEx\ClipboardEx.exe, pack successfully.
It's kind of like what kibitzerCZ said. But i dont need to make a new dir, just make sure your path is correct

Hinrichs answered 31/5, 2020 at 3:56 Comment(1)
This was exactly my case. Appended the folder name (same name as exe), and it worked. The other workarounds worked but caused other issues.Killian
U
1

I dont know if its too late to weigh in on this, but I'm in the process of trying to do something similar. (Running an PowerShell.exe) from a UWP app. and this was a link refereed to me by someone else concerned Desktop Bridged apps.

In your case. I'm pointing you to the first paragraph of the MS Doc from the link...

Right Click on the Package.appxmanifest file and view the code. Once inside the XML file make sure you add the following Name Spaces to the Package Section

      <Package
      ...
      xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2"
      xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
      xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
      ...
      IgnorableNamespaces="uap uap2 uap3 mp rescap desktop">
Update answered 27/3, 2017 at 20:18 Comment(1)
Why we need this uap2 and uap3?Funicular
C
0

it might be I found an extremely simple solution. I had exactly same error: "The file name... declared for element... doesn't exist in the package".

It seemed to be a conflict between two 'Executable' entries. The first under Applications tag and the second under the new Extensions one. I deleted the second one and it worked.

I haven't released this version yet but all my tests so far passed. After the computer reboot the app is launched automatically. Could it be this 'shortcut' will hit me later on? Anyone else tried it? This solution seems to be too simple to be the right one...?

Contumelious answered 23/3, 2022 at 22:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.