Greg Thatcher
Greg Thatcher

Reputation: 1443

How to replace a .winmd in a customer's .appx, .msix, .msixbundle package?

Scenario : A customer is using my SDK (a .winmd file), and is reporting a problem. They have sent me their .appx file. I wish to replace the SDK in their .appx file with a debug version of my SDK, so that I can debug the customer's problem.

I have tried using a couple of installer packages (Advanced Installer and the Microsoft MSIX Packaging Tool. With these, I can replace the .winmd file. I then run the installer, and confirm that the new file has replaced the old file by checking c:\Program Files\WindowsApps<application directory> However, when I run the app again, I can see (from logs and from Fiddler) that the old SDK is being used. It seems like some Windows security mechanism is somehow deciding to load an old version of the file.

Here are the steps I have tried:

  1. Open the .appx file in a program like Advanced Installer.
  2. Set the digital signature to a certificate that my machine trusts.
  3. Change the "CN" to match that of my certificate.
  4. Update the version of the customer app
  5. Replace the old .winmd file with my new file.
  6. Create a new .msix package, and install.

Each time, I see that the old .winmd file is being used instead of the new file I have replaced it with.

If I rename the new .msix package to .zip, and extract contents, I see that the file is present, and that the AppxBlockMap.xml has been updated with info about my new .winmd file.

So, I can't figure out why I can't change this file in the .msix package, and have it install and run correctly.

I have also tried to do all the steps manually (without any "installer software"), updating the AppxBlockMap.xml myself, and manually replacing the file, but this also didn't work. I've also tried rebooting my machine (in case this some kind of caching issue), but that didn't help.

Can anyone give me instructions on how to modify a .appx file with a new library (.winmd) and have the app successfully run and use the new library?

Update: I believe I have found the problem, but I don't know how to fix it. Let's say you have a library called mysdk.winmd which you distribute to your customers. Also, let's say the customer has an app called "Customer". When you build a .appx (or .msix) package, the package will contain Customer.exe, Customer.dll, and mysdk.winmd. The contents of Customer.dll will also contain mysdk.winmd (mysdk.winmd is included in the package twice, once as a file, and once embedded inside Customer.dll) I have no idea why the mysdk.winmd gets included twice, but I've seen this in a number of installer files (.msixupload, .msix, .appx, etc.)

So, changing the mysdk.winmd will not cause my new library to be run, since the app is using the old mysdk.winmd which is contained in Customer.dll.

So, I guess my question is, how can I re-recreate Customer.dll which will now include my old mysdk.winmd file, but without the original source code (since I just want to replace the .winmd of my SDK so that I can debug a customer's problem after they have created their own installer.)

Upvotes: 1

Views: 228

Answers (0)

Related Questions