问题
I have used the Desktop App Converter to convert my Win32 application to .appx
.
The converter failed to convert application icons correctly. Icon transparency was lost. While I have reported this (bug?) to Microsoft, meanwhile I'd like to try to convert the icons manually. And I want to generate the .appx
manually (using the makeappx
) in the end anyway. So I need to create the AppxManifest.xml
.
Problem is that the AppxManifest.xml
generated by the Desktop App Converter is not valid. All image paths point to non-existing files:
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10">
...
<Properties>
...
<Logo>Assets\AppStoreLogo.png</Logo>
</Properties>
<Resources>
<Resource Language="en-us" />
<Resource uap:Scale="100" />
<Resource uap:Scale="125" />
<Resource uap:Scale="150" />
<Resource uap:Scale="200" />
<Resource uap:Scale="400" />
</Resources>
...
<Applications>
<Application Id="WinSCP" Executable="WinSCP.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements DisplayName="WinSCP" Description="WinSCP" BackgroundColor="transparent" Square150x150Logo="Assets\AppMedTile.png" Square44x44Logo="Assets\AppList.png">
<uap:DefaultTile Wide310x150Logo="Assets\AppWideTile.png" Square310x310Logo="Assets\AppLargeTile.png" Square71x71Logo="Assets\AppSmallTile.png">
There are no files like AppStoreLogo.png
(etc) in the Assets
folders, there are files like:
AppStoreLogo.scale-100.png
AppStoreLogo.scale-125.png
AppStoreLogo.scale-150.png
AppStoreLogo.scale-200.png
AppStoreLogo.scale-400.png
So the makeappx
fails to generate the .appx
using the generated manifest.
While I can obviously fix the manifest by pointing the paths to the scale-100
variant of the images, I feel that this is not the correct way.
The scaled images are the for a reason, for sure.
I can see these image and scales related elements:
There's the
<Resources>
element in the manifest that lists all the scales.There are also
resources.*.pri
files, which reference the scaled images.resources.pri resources.scale-100.pri resources.scale-125.pri resources.scale-150.pri resources.scale-200.pri
But I do not understand how this all goes together. What paths should I use in the manifest to maintain the scaled images?
回答1:
All the icons are put together by a .PRI file that must be present into the package and generated for those assets. You can try to use makepri to dump the .PRI files into XML format and see their content.
回答2:
If you need to make manual edits to your resources and rebuild your resources.pri, please refer to this white paper and sample:
https://docs.microsoft.com/en-us/windows/uwp/globalizing/using-mrt-for-converted-desktop-apps-and-games
https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/DotNetSatelliteAssemblyDemo
However, the easiest way to manage the visual assets for your app package is to use the package manifest editor in Visual Studio 2017.
To use it for your converted app, create an empty UWP project and add the output of the conversion (incl. your appx manifest) in this project. Now you can use the editor to manage the visual assets, build your packages for store submission and much more. Here is a document that describes the process: https://docs.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-packaging-dot-net
Thanks, Stefan Wick - Windows Developer Platform
回答3:
It was probably some glitch in earlier versions of makeappx
.
When trying over a year later again, the makeappx
can now compile the AppxManifest.xml
generated by Desktop App Converter, even though it seems to be about the same as before.
(Desktop App Converter still fails to generate application icons correctly).
回答4:
I managed to convert the WinSCP installer to an AppX package using Advanced Installer.
From this link you can download the package, with the correct icons from what I noticed. Just extract the contents of the package and check out the paths in the manifest.
You can also install and test the app with this package, just install the self-signed certificate first, with which the app was signed. (in a VM of course)
Customizing your package resources:
I built a new appx package that contains more resources, for different sizes. You can download it from the link above, I updated the source.
To get the PRI content you need to run the command: makepri.exe dump
Here is the resources.pri.xml content from the new package:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PriInfo>
<ResourceMap name="MartinPrikryl.WinSCP" version="1.0" primary="true">
<Qualifiers>
<AlternateForm>UNPLATED</AlternateForm>
<Scale>100,125,150,200,400</Scale>
<TargetSize>256,48</TargetSize>
</Qualifiers>
<ResourceMapSubtree name="Files">
<ResourceMapSubtree name="Assets">
<NamedResource name="Store50x50Logo.png" uri="ms-resource://MartinPrikryl.WinSCP/Files/Assets/Store50x50Logo.png">
<Candidate qualifiers="Scale-400" isDefault="true" type="Path">
<Value>Assets\Store50x50Logo.scale-400.png</Value>
</Candidate>
<Candidate qualifiers="Scale-200" isDefault="true" type="Path">
<Value>Assets\Store50x50Logo.scale-200.png</Value>
</Candidate>
<Candidate qualifiers="Scale-150" isDefault="true" type="Path">
<Value>Assets\Store50x50Logo.scale-150.png</Value>
</Candidate>
<Candidate qualifiers="Scale-125" isDefault="true" type="Path">
<Value>Assets\Store50x50Logo.scale-125.png</Value>
</Candidate>
<Candidate qualifiers="Scale-100" isDefault="true" type="Path">
<Value>Assets\Store50x50Logo.scale-100.png</Value>
</Candidate>
</NamedResource>
<NamedResource name="WinSCPSquare150x150Logo.png" uri="ms-resource://MartinPrikryl.WinSCP/Files/Assets/WinSCPSquare150x150Logo.png">
<Candidate qualifiers="Scale-125" isDefault="true" type="Path">
<Value>Assets\WinSCPSquare150x150Logo.scale-125.png</Value>
</Candidate>
</NamedResource>
<NamedResource name="WinSCPSquare310x310Logo.png" uri="ms-resource://MartinPrikryl.WinSCP/Files/Assets/WinSCPSquare310x310Logo.png">
<Candidate qualifiers="Scale-100" isDefault="true" type="Path">
<Value>Assets\WinSCPSquare310x310Logo.scale-100.png</Value>
</Candidate>
</NamedResource>
<NamedResource name="WinSCPSquare44x44Logo.png" uri="ms-resource://MartinPrikryl.WinSCP/Files/Assets/WinSCPSquare44x44Logo.png">
<Candidate qualifiers="TargetSize-48" isDefault="true" type="Path">
<Value>Assets\WinSCPSquare44x44Logo.targetsize-48.png</Value>
</Candidate>
<Candidate qualifiers="TargetSize-256, AlternateForm-UNPLATED" type="Path">
<Value>Assets\WinSCPSquare44x44Logo.targetsize-256_altform-unplated.png</Value>
</Candidate>
</NamedResource>
<NamedResource name="WinSCPSquare71x71Logo.png" uri="ms-resource://MartinPrikryl.WinSCP/Files/Assets/WinSCPSquare71x71Logo.png">
<Candidate qualifiers="Scale-100" isDefault="true" type="Path">
<Value>Assets\WinSCPSquare71x71Logo.scale-100.png</Value>
</Candidate>
</NamedResource>
<NamedResource name="WinSCPWide310x150Logo.png" uri="ms-resource://MartinPrikryl.WinSCP/Files/Assets/WinSCPWide310x150Logo.png">
<Candidate qualifiers="Scale-100" isDefault="true" type="Path">
<Value>Assets\WinSCPWide310x150Logo.scale-100.png</Value>
</Candidate>
</NamedResource>
</ResourceMapSubtree>
</ResourceMapSubtree>
</ResourceMap>
</PriInfo>
Here is the manifest:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" IgnorableNamespaces="uap rescap" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities">
<Identity Name="MartinPrikryl.WinSCP" ProcessorArchitecture="x64" Publisher="CN=Caphyon-sha2, OU=AdvancedInstaller, O=Caphyon, E=support@caphyon.net" Version="5.9.3.7136"/>
<Applications>
<Application Id="WinSCP" Executable="VFS\ProgramFilesX86\WinSCP\WinSCP.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements DisplayName="WinSCP" Description="WinSCP" BackgroundColor="transparent" Square150x150Logo="Assets\WinSCPSquare150x150Logo.png" Square44x44Logo="Assets\WinSCPSquare44x44Logo.png">
<uap:InitialRotationPreference>
<uap:Rotation Preference="portrait"/>
<uap:Rotation Preference="landscape"/>
</uap:InitialRotationPreference>
<uap:DefaultTile Square310x310Logo="Assets\WinSCPSquare310x310Logo.png" Square71x71Logo="Assets\WinSCPSquare71x71Logo.png" Wide310x150Logo="Assets\WinSCPWide310x150Logo.png"/>
</uap:VisualElements>
</Application>
</Applications>
<Resources>
<Resource Language="en-US"/>
</Resources>
<Capabilities>
<rescap:Capability Name="runFullTrust"/>
</Capabilities>
<Properties>
<DisplayName>WinSCP</DisplayName>
<PublisherDisplayName>Martin Prikryl</PublisherDisplayName>
<Logo>Assets\Store50x50Logo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0"/>
</Dependencies>
</Package>
来源:https://stackoverflow.com/questions/42162466/fixing-scaled-images-in-appx-manifest-generated-by-destop-app-converter