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.
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:
(Updating UWP Tools did not seem to fix it.)
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.
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:
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
Edit the
desktop:Extension
element inPackage.appxmanifest
- add the folder to theExecutable
attribute value:<desktop:Extension Category="windows.fullTrustProcess" Executable="win32\BackgroundProcess.exe" />
Add the
BackgroundProcess.exe
binary from the newly created folder to your UWP project. In its properties set theBuildAction
attribute toContent
andCopy to Output Directory
toCopy 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.
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">
来源:https://stackoverflow.com/questions/38903012/error-while-creating-app-package-with-fulltrustprocess-pointing-to-a-executabl