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
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">
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 in Package.appxmanifest
- add the folder to the Executable
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 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.
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.exe
toClipboardEx\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
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.