none
Manually packaging desktop bridge app with share target support

    Question

  • Hi!

    We have an obfuscation tool require to obfuscate WPF application manually after building it.
    Recently we wish to publish our application to the store and support share target with it. I following the MSDN and can using Visual Studio's "windows application packaging project" to make a working side load package.
    However, I can't obfuscate my WPF application in this workflow.

    Can anyone guide me how to manually package with "MakePri.exe" and "MakeAppx.exe"? I try the following steps and the share target always crash. (I using Windows-Packaging-Samples as demo.)
    1. Clone code from "https://github.com/microsoft/Windows-Packaging-Samples"
    2. Using VS 2017 to open "ShareTarget.sln" solution
    3. Generate test certificate for WpfPhotoViewer.Package
    4. Select "Create App Packages"->"I want to create packages for sideloading", Disable "Enable automatic updates"
    5. Select Architecture: x86, Solution Configuration: Release (x86), click Create
    6. Copy files at "\ShareTarget\WpfPhotoViewer.Package\obj\x86\Release\PackageLayout" to "C:\Temp\""
    7. Copy "\ShareTarget\WpfPhotoViewer.Package\bin\x86\Release\AppxManifest.xml" to "C:\Temp\PackageLayout"
    8. Copy "\ShareTarget\WpfPhotoViewer.Package\WpfPhotoViewer.Package_TemporaryKey.pfx" to "C:\Temp\"
    9. Edit "C:\Temp\PackageLayout\AppxManifest.xml", remove "build" related namespace.
    11. Using tools to obfuscate binary "C:\Temp\PackageLayout\WpfPhotoViewer\WpfPhotoViewer.exe"
    12. Using following commands to create msix package.
    cd C:\Temp\PackageLayout
    MakePri.exe createconfig /cf "C:\Temp\priconfig.xml" /dq lang-en-US /o
    MakePri.exe new /pr "C:\Temp\PackageLayout" /cf "C:\Temp\priconfig.xml"
    MakeAppx.exe pack /v /h SHA256 /d "C:\Temp\PackageLayout" /p "C:\Temp\WpfPhotoViewer.Package_1.0.0.0_x86.msix"
    signtool.exe sign /debug /v /f "C:\Temp\WpfPhotoViewer.Package_TemporaryKey.pfx" -fd SHA256 /t http://timestamp.verisign.com/scripts/timestamp.dll "C:\Temp\WpfPhotoViewer.Package_1.0.0.0_x86.msix"
    After installing this package, on any photo and right click, select Share, choose "WPF Photo Viewer", and the SharedPhotoUI crashed.

    • Edited by Toml IOI Friday, May 17, 2019 1:18 PM
    Friday, May 17, 2019 8:01 AM

All replies

  • Hi,

    Well, it's hard to locate if the problem is related to the conversion process or the code itself. Could you please check the error log in the Event Viewer? Take a look at the error log might be help us.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 20, 2019 5:30 AM
    Moderator
  • Hi!

    Thanks for reply.
    By using the sample application, here are the events generated after failing:

    - <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    - <System>
      <Provider Name="Application Error" /> 
      <EventID Qualifiers="0">1000</EventID> 
      <Level>2</Level> 
      <Task>100</Task> 
      <Keywords>0x80000000000000</Keywords> 
      <TimeCreated SystemTime="2019-05-21T12:22:17.824964200Z" /> 
      <EventRecordID>2427</EventRecordID> 
      <Channel>Application</Channel> 
      <Computer>DESKTOP-LOS29GL</Computer> 
      <Security /> 
      </System>
    - <EventData>
      <Data>SharePhotoUI.exe</Data> 
      <Data>1.0.0.0</Data> 
      <Data>5cde5e38</Data> 
      <Data>Windows.UI.Xaml.dll</Data> 
      <Data>10.0.17763.404</Data> 
      <Data>5c3c199a</Data> 
      <Data>c000027b</Data> 
      <Data>008dc0f1</Data> 
      <Data>17bc</Data> 
      <Data>01d50fcfd47920c7</Data> 
      <Data>C:\Program Files\WindowsApps\WPFPhotoViewer_1.0.0.0_x86__60vbwtz0f2brm\SharePhotoUI.exe</Data> 
      <Data>C:\Windows\System32\Windows.UI.Xaml.dll</Data> 
      <Data>b73182fd-cbb9-468f-a54f-99f193b00299</Data> 
      <Data>WPFPhotoViewer_1.0.0.0_x86__60vbwtz0f2brm</Data> 
      <Data>App</Data> 
      </EventData>
      </Event>
    - <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    - <System>
      <Provider Name="Windows Error Reporting" /> 
      <EventID Qualifiers="0">1001</EventID> 
      <Level>4</Level> 
      <Task>0</Task> 
      <Keywords>0x80000000000000</Keywords> 
      <TimeCreated SystemTime="2019-05-21T12:22:21.340627500Z" /> 
      <EventRecordID>2428</EventRecordID> 
      <Channel>Application</Channel> 
      <Computer>DESKTOP-LOS29GL</Computer> 
      <Security /> 
      </System>
    - <EventData>
      <Data>1571124084959283464</Data> 
      <Data>5</Data> 
      <Data>MoAppCrash</Data> 
      <Data>Not available</Data> 
      <Data>0</Data> 
      <Data>WPFPhotoViewer_1.0.0.0_x86__60vbwtz0f2brm</Data> 
      <Data>praid:App</Data> 
      <Data>1.0.0.0</Data> 
      <Data>5cde5e38</Data> 
      <Data>combase.dll</Data> 
      <Data>10.0.17763.404</Data> 
      <Data>58b628b6</Data> 
      <Data>802b000a</Data> 
      <Data>000abe7a</Data> 
      <Data /> 
      <Data>\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER47F2.tmp.dmp \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER4AC2.tmp.WERInternalMetadata.xml \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER4AD2.tmp.xml \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER4AD0.tmp.csv \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER4AF1.tmp.txt</Data> 
      <Data>\\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_WPFPhotoViewer_1_d04fe68efea3d27d9b605bc9a661619595da257b_b60f874e_0c8e5466</Data> 
      <Data /> 
      <Data>0</Data> 
      <Data>b73182fd-cbb9-468f-a54f-99f193b00299</Data> 
      <Data>268435456</Data> 
      <Data>842afec5d6e7cb7365cdc107f60f0908</Data> 
      <Data>0</Data> 
      </EventData>
      </Event>

    Tuesday, May 21, 2019 12:31 PM
  • Hi,

    I'm asking the team to see if the obfuscation will effect the interaction between the UWP app the win32 app. But I do suspect the problem is inside the UWP app. 

    Well, the event log you given does not help a lot. I suggest that you could check the log from Applications and Service Logs->Microsoft->Windows->Apps->Microsoft-Windows-TWinUI/Operational . It should looks like this. 

    In the General tab, it will show you the exception message, and in the detail tab, using xml view, you could get xml list which should contain the error.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 22, 2019 9:44 AM
    Moderator
  • Hi!

    I checked with the "Microsoft-Windows-TWinUI/Operational", and found following Error log:

    - <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    - <System>
      <Provider Name="Microsoft-Windows-Immersive-Shell" Guid="{315a8872-923e-4ea2-9889-33cd4754bf64}" /> 
      <EventID>5961</EventID> 
      <Version>0</Version> 
      <Level>2</Level> 
      <Task>5961</Task> 
      <Opcode>0</Opcode> 
      <Keywords>0x4000000000000000</Keywords> 
      <TimeCreated SystemTime="2019-05-21T12:22:21.382325700Z" /> 
      <EventRecordID>28</EventRecordID> 
      <Correlation /> 
      <Execution ProcessID="5844" ThreadID="3940" /> 
      <Channel>Microsoft-Windows-TWinUI/Operational</Channel> 
      <Computer>DESKTOP-LOS29GL</Computer> 
      <Security UserID="S-1-5-21-1896672411-1092726196-3391148120-1001" /> 
      </System>
    - <EventData>
      <Data Name="AppId">WPFPhotoViewer_60vbwtz0f2brm!App</Data> 
      <Data Name="ErrorCode">-2147219196</Data> 
      <Data Name="PhaseFlags">33</Data> 
      </EventData>
      </Event>
    The obfuscation is not used at my reproduce step at first post. And our issue can be reproduce without obfuscation.
    So, yes, it should related with the UWP app. I put the package at following storage. Hope this file helped.

    https://ionew-my.sharepoint.com/:u:/g/personal/georgec_ionew_onmicrosoft_com/EcwRntffGIdEgUqYYRieYGMBpwryFqNF7f0gPtAs5WyenA?e=Ov5GfC
    Please let me known if you need more information.



    • Edited by Toml IOI Wednesday, May 22, 2019 12:58 PM
    Wednesday, May 22, 2019 12:53 PM
  • Hi,

    Well, it seems I missed something before. It seems that you installed these two apps separately, right? If so, definitely this will cause the problem. As you could check the official sample, in the WpfPhotoViewer.Package project, press F7 to open the Manifest file. You could see that there is a fullTrustProcess. This tells the UWP API FullTrustProcessLauncher Class which app he should load. But when you install them separately, the UWP API don't know where to launch the WPFPhotoViewer.exe and it gives the error. To solve this, one way is to use the Windows Application Package Project like the sample did. Another way is to include the .exe file inside your UWP app.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 23, 2019 6:52 AM
    Moderator
  • Hi!

    I don't understand what you mean "installed these two apps separately". I manually package these two apps into one package. So they should be installed at the same time.

    First of all, let me tell you the package layout that we used:

    ROOT
    |   AppxManifest.xml
    |   clrcompression.dll
    |   resources.pri
    |   resources.scale-125.pri
    |   resources.scale-150.pri
    |   resources.scale-200.pri
    |   resources.scale-400.pri
    |   SharePhotoUI.dll
    |   SharePhotoUI.exe
    |   
    +---Assets
    |       LargeTile.scale-100.png
    |       LargeTile.scale-125.png
    |       LargeTile.scale-150.png
    |       LargeTile.scale-200.png
    |       LargeTile.scale-400.png
    |       LockScreenLogo.scale-200.png
    |       SmallTile.scale-100.png
    |       SmallTile.scale-125.png
    |       SmallTile.scale-150.png
    |       SmallTile.scale-200.png
    |       SmallTile.scale-400.png
    |       SplashScreen.scale-100.png
    |       SplashScreen.scale-125.png
    |       SplashScreen.scale-150.png
    |       SplashScreen.scale-200.png
    |       SplashScreen.scale-400.png
    |       Square150x150Logo.scale-100.png
    |       Square150x150Logo.scale-125.png
    |       Square150x150Logo.scale-150.png
    |       Square150x150Logo.scale-200.png
    |       Square150x150Logo.scale-400.png
    |       Square44x44Logo.altform-unplated_targetsize-16.png
    |       Square44x44Logo.altform-unplated_targetsize-256.png
    |       Square44x44Logo.altform-unplated_targetsize-32.png
    |       Square44x44Logo.altform-unplated_targetsize-48.png
    |       Square44x44Logo.scale-100.png
    |       Square44x44Logo.scale-125.png
    |       Square44x44Logo.scale-150.png
    |       Square44x44Logo.scale-200.png
    |       Square44x44Logo.scale-400.png
    |       Square44x44Logo.targetsize-16.png
    |       Square44x44Logo.targetsize-24.png
    |       Square44x44Logo.targetsize-24_altform-unplated.png
    |       Square44x44Logo.targetsize-256.png
    |       Square44x44Logo.targetsize-32.png
    |       Square44x44Logo.targetsize-48.png
    |       StoreLogo.scale-100.png
    |       StoreLogo.scale-125.png
    |       StoreLogo.scale-150.png
    |       StoreLogo.scale-200.png
    |       StoreLogo.scale-400.png
    |       Wide310x150Logo.scale-100.png
    |       Wide310x150Logo.scale-125.png
    |       Wide310x150Logo.scale-150.png
    |       Wide310x150Logo.scale-200.png
    |       Wide310x150Logo.scale-400.png
    |       
    +---Images
    |       LargeTile.scale-100.png
    |       LargeTile.scale-125.png
    |       LargeTile.scale-150.png
    |       LargeTile.scale-200.png
    |       LargeTile.scale-400.png
    |       SmallTile.scale-100.png
    |       SmallTile.scale-125.png
    |       SmallTile.scale-150.png
    |       SmallTile.scale-200.png
    |       SmallTile.scale-400.png
    |       SplashScreen.scale-100.png
    |       SplashScreen.scale-125.png
    |       SplashScreen.scale-150.png
    |       SplashScreen.scale-200.png
    |       SplashScreen.scale-400.png
    |       Square150x150Logo.scale-100.png
    |       Square150x150Logo.scale-125.png
    |       Square150x150Logo.scale-150.png
    |       Square150x150Logo.scale-200.png
    |       Square150x150Logo.scale-400.png
    |       Square44x44Logo.altform-unplated_targetsize-16.png
    |       Square44x44Logo.altform-unplated_targetsize-24.png
    |       Square44x44Logo.altform-unplated_targetsize-256.png
    |       Square44x44Logo.altform-unplated_targetsize-32.png
    |       Square44x44Logo.altform-unplated_targetsize-48.png
    |       Square44x44Logo.scale-100.png
    |       Square44x44Logo.scale-125.png
    |       Square44x44Logo.scale-150.png
    |       Square44x44Logo.scale-200.png
    |       Square44x44Logo.scale-400.png
    |       Square44x44Logo.targetsize-16.png
    |       Square44x44Logo.targetsize-24.png
    |       Square44x44Logo.targetsize-256.png
    |       Square44x44Logo.targetsize-32.png
    |       Square44x44Logo.targetsize-48.png
    |       StoreLogo.scale-100.png
    |       StoreLogo.scale-125.png
    |       StoreLogo.scale-150.png
    |       StoreLogo.scale-200.png
    |       StoreLogo.scale-400.png
    |       Wide310x150Logo.scale-100.png
    |       Wide310x150Logo.scale-125.png
    |       Wide310x150Logo.scale-150.png
    |       Wide310x150Logo.scale-200.png
    |       Wide310x150Logo.scale-400.png
    |       
    +---WinMetadata
    |       Windows.winmd
    |       
    \---WpfPhotoViewer
            Microsoft.Win32.Primitives.dll
            netstandard.dll
            SingleInstance.dll
            System.AppContext.dll
            System.Collections.Concurrent.dll
            System.Collections.dll
            System.Collections.NonGeneric.dll
            System.Collections.Specialized.dll
            System.ComponentModel.dll
            System.ComponentModel.EventBasedAsync.dll
            System.ComponentModel.Primitives.dll
            System.ComponentModel.TypeConverter.dll
            System.Console.dll
            System.Data.Common.dll
            System.Diagnostics.Contracts.dll
            System.Diagnostics.Debug.dll
            System.Diagnostics.FileVersionInfo.dll
            System.Diagnostics.Process.dll
            System.Diagnostics.StackTrace.dll
            System.Diagnostics.TextWriterTraceListener.dll
            System.Diagnostics.Tools.dll
            System.Diagnostics.TraceSource.dll
            System.Diagnostics.Tracing.dll
            System.Drawing.Primitives.dll
            System.Dynamic.Runtime.dll
            System.Globalization.Calendars.dll
            System.Globalization.dll
            System.Globalization.Extensions.dll
            System.IO.Compression.dll
            System.IO.Compression.ZipFile.dll
            System.IO.dll
            System.IO.FileSystem.dll
            System.IO.FileSystem.DriveInfo.dll
            System.IO.FileSystem.Primitives.dll
            System.IO.FileSystem.Watcher.dll
            System.IO.IsolatedStorage.dll
            System.IO.MemoryMappedFiles.dll
            System.IO.Pipes.dll
            System.IO.UnmanagedMemoryStream.dll
            System.Linq.dll
            System.Linq.Expressions.dll
            System.Linq.Parallel.dll
            System.Linq.Queryable.dll
            System.Net.Http.dll
            System.Net.NameResolution.dll
            System.Net.NetworkInformation.dll
            System.Net.Ping.dll
            System.Net.Primitives.dll
            System.Net.Requests.dll
            System.Net.Security.dll
            System.Net.Sockets.dll
            System.Net.WebHeaderCollection.dll
            System.Net.WebSockets.Client.dll
            System.Net.WebSockets.dll
            System.ObjectModel.dll
            System.Reflection.dll
            System.Reflection.Extensions.dll
            System.Reflection.Primitives.dll
            System.Resources.Reader.dll
            System.Resources.ResourceManager.dll
            System.Resources.Writer.dll
            System.Runtime.CompilerServices.VisualC.dll
            System.Runtime.dll
            System.Runtime.Extensions.dll
            System.Runtime.Handles.dll
            System.Runtime.InteropServices.dll
            System.Runtime.InteropServices.RuntimeInformation.dll
            System.Runtime.Numerics.dll
            System.Runtime.Serialization.Formatters.dll
            System.Runtime.Serialization.Json.dll
            System.Runtime.Serialization.Primitives.dll
            System.Runtime.Serialization.Xml.dll
            System.Security.Claims.dll
            System.Security.Cryptography.Algorithms.dll
            System.Security.Cryptography.Csp.dll
            System.Security.Cryptography.Encoding.dll
            System.Security.Cryptography.Primitives.dll
            System.Security.Cryptography.X509Certificates.dll
            System.Security.Principal.dll
            System.Security.SecureString.dll
            System.Text.Encoding.dll
            System.Text.Encoding.Extensions.dll
            System.Text.RegularExpressions.dll
            System.Threading.dll
            System.Threading.Overlapped.dll
            System.Threading.Tasks.dll
            System.Threading.Tasks.Parallel.dll
            System.Threading.Thread.dll
            System.Threading.ThreadPool.dll
            System.Threading.Timer.dll
            System.ValueTuple.dll
            System.Xml.ReaderWriter.dll
            System.Xml.XDocument.dll
            System.Xml.XmlDocument.dll
            System.Xml.XmlSerializer.dll
            System.Xml.XPath.dll
            System.Xml.XPath.XDocument.dll
            WpfPhotoViewer.exe
            WpfPhotoViewer.exe.config
    

    Second, the "resources.*" is generated by MakePri.exe. Others are the files built by Visual Studio.
    Then I use "MakeAppx.exe" to package these files into "WpfPhotoViewer.Package_1.0.0.0_x86.msix".

    The "AppxManifest.xml" is written as following:

    <?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 rescap desktop">
      <Identity Name="WPFPhotoViewer" Publisher="CN=George Chang" Version="1.0.0.0" ProcessorArchitecture="x86" />
      <Properties>
        <DisplayName>WPF Photo Viewer</DisplayName>
        <PublisherDisplayName>DesktopBridgeDeveloper</PublisherDisplayName>
        <Logo>Assets\StoreLogo.png</Logo>
      </Properties>
      <Dependencies>
        <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17134.0" MaxVersionTested="10.0.17763.0" />
        <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17134.0" MaxVersionTested="10.0.17763.0" />
        <PackageDependency Name="Microsoft.NET.Native.Framework.2.2" MinVersion="2.2.27405.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
        <PackageDependency Name="Microsoft.NET.Native.Runtime.2.2" MinVersion="2.2.27328.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
        <PackageDependency Name="Microsoft.VCLibs.140.00" MinVersion="14.0.26706.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
      </Dependencies>
      <Resources>
        <Resource Language="EN-US" />
      </Resources>
      <Applications>
        <Application Id="App" Executable="WpfPhotoViewer\WpfPhotoViewer.exe" EntryPoint="Windows.FullTrustApplication">
          <uap:VisualElements DisplayName="WPF Photo Viewer" Description="WPF Photo Viewer with share contract" BackgroundColor="transparent" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">
            <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square310x310Logo="Assets\LargeTile.png" Square71x71Logo="Assets\SmallTile.png"></uap:DefaultTile>
            <uap:SplashScreen Image="Assets\SplashScreen.png" />
          </uap:VisualElements>
          <Extensions>
            <desktop:Extension Category="windows.fullTrustProcess" Executable="WPFPhotoViewer\WPFPhotoViewer.exe" />
            <uap:Extension Category="windows.shareTarget" Executable="SharePhotoUI.exe" EntryPoint="App">
              <uap:ShareTarget Description="Share Pictures with WPF">
                <uap:SupportedFileTypes>
                  <uap:SupportsAnyFileType />
                </uap:SupportedFileTypes>
                <uap:DataFormat>Bitmap</uap:DataFormat>
              </uap:ShareTarget>
            </uap:Extension>
          </Extensions>
        </Application>
      </Applications>
      <Capabilities>
        <Capability Name="internetClient" />
        <rescap:Capability Name="runFullTrust" />
      </Capabilities>
    </Package>
    The manual packaged app can be installed and can correct launch the "WPFPhotoViewer.exe". But "SharePhotoUI.exe" can't be launched by the shell. Which the result is different with the one packaged by "Windows Application Package Project".

    Can you point out how to properly package it manually?


    Thursday, May 23, 2019 4:31 PM
  • Hi,

    I do suspect if MakeAppx.exe could package both UWP and WPF apps into one package. I'm asking the team to confirm this. There might be some time delay. Thank you for your patience.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 27, 2019 7:40 AM
    Moderator