update static manifests

This commit is contained in:
Leilei Zhang
2025-10-16 16:28:27 +08:00
parent e6ed0ff8bd
commit fd839eac98
6 changed files with 28 additions and 35 deletions

4
.gitignore vendored
View File

@@ -361,6 +361,4 @@ src/common/Telemetry/*.etl
/src/settings-ui/Settings.UI/Assets/Settings/search.index.json /src/settings-ui/Settings.UI/Assets/Settings/search.index.json
# PowerToysInstaller Build Temp Files # PowerToysInstaller Build Temp Files
installer/*/*.wxs.bk installer/*/*.wxs.bk
# Generated sparse manifest embedded into ImageResizer UI executable
src/modules/imageresizer/ui/ImageResizerUI.exe.manifest

View File

@@ -9,10 +9,10 @@
<!-- Target to generate sparse MSIX package --> <!-- Target to generate sparse MSIX package -->
<Target Name="GenerateSparsePackage" BeforeTargets="PrepareForBuild"> <Target Name="GenerateSparsePackage" BeforeTargets="PrepareForBuild">
<!-- Use NoSign for Debug builds or CI builds to avoid certificate issues --> <!-- Use NoSign only for CI builds to avoid certificate issues on hosted agents -->
<PropertyGroup> <PropertyGroup>
<NoSignParam Condition="'$(Configuration)' == 'Debug' OR '$(NoSignCI)' == 'true'">-NoSign</NoSignParam> <NoSignParam Condition="'$(NoSignCI)' == 'true'">-NoSign</NoSignParam>
<NoSignParam Condition="'$(Configuration)' != 'Debug' AND '$(NoSignCI)' != 'true'"></NoSignParam> <NoSignParam Condition="'$(NoSignCI)' != 'true'"></NoSignParam>
<CIBuildParam Condition="'$(CIBuild)' == 'true'">-CIBuild</CIBuildParam> <CIBuildParam Condition="'$(CIBuild)' == 'true'">-CIBuild</CIBuildParam>
<CIBuildParam Condition="'$(CIBuild)' != 'true'"></CIBuildParam> <CIBuildParam Condition="'$(CIBuild)' != 'true'"></CIBuildParam>
</PropertyGroup> </PropertyGroup>
@@ -47,6 +47,7 @@
<ProjectGuid>{E2A5A82E-1E5B-4C8D-9A4F-2B1A8F9E5C3D}</ProjectGuid> <ProjectGuid>{E2A5A82E-1E5B-4C8D-9A4F-2B1A8F9E5C3D}</ProjectGuid>
<RootNamespace>PackageIdentity</RootNamespace> <RootNamespace>PackageIdentity</RootNamespace>
<ProjectName>PackageIdentity</ProjectName> <ProjectName>PackageIdentity</ProjectName>
<UseFastUpToDateCheck>false</UseFastUpToDateCheck>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

View File

@@ -67,14 +67,14 @@ Get-AppxPackage -Name Microsoft.PowerToys.SparseApp | Remove-AppxPackage
## CI-specific guidance ## CI-specific guidance
- Pass `-CIBuild` to `BuildSparsePackage.ps1` (or build with `msbuild PackageIdentity.vcxproj /p:CIBuild=true`). This prevents the script from rewriting the manifest publisher to the local dev certificate subject. - Pass `-CIBuild` to `BuildSparsePackage.ps1` (or build with `msbuild PackageIdentity.vcxproj /p:CIBuild=true`). This prevents the script from rewriting the manifest publisher to the local dev certificate subject.
- The project automatically adds `-NoSign` when you build Debug or when `$(CIBuild)` is `true`. Provide your own signing step in CI if the package must be signed. - The project automatically adds `-NoSign` only when `$(CIBuild)` is `true`. Local Debug and Release builds are signed with the development certificate.
- Make sure the agent trusts whichever certificate signs the package. If the package remains unsigned (`-NoSign`) it cannot be installed on test machines until it is signed. - Make sure the agent trusts whichever certificate signs the package. If the package remains unsigned (`-NoSign`) it cannot be installed on test machines until it is signed.
## Consuming the identity from other components ## Consuming the identity from other components
1. Add a new `<Application>` entry inside `src/PackageIdentity/AppxManifest.xml`. Use a unique `Id` (for example `PowerToys.MyModuleUI`) and set `Executable` to the Win32 binary relative to the `-ExternalLocation` root. 1. Add a new `<Application>` entry inside `src/PackageIdentity/AppxManifest.xml`. Use a unique `Id` (for example `PowerToys.MyModuleUI`) and set `Executable` to the Win32 binary relative to the `-ExternalLocation` root.
2. Ensure the binary is copied into the platform/configuration output folder (`x64\Release`, `ARM64\Debug`, etc.) so the sparse package can locate it. 2. Ensure the binary is copied into the platform/configuration output folder (`x64\Release`, `ARM64\Debug`, etc.) so the sparse package can locate it.
3. Embed a sparse identity manifest in the Win32 binary so it binds to the MSIX identity at runtime. The manifest must declare an `<msix>` element with `packageName="Microsoft.PowerToys.SparseApp"`, `applicationId` matching the `<Application Id>`, and a `publisher` that matches the sparse package. Local builds can read the publisher from `src/PackageIdentity/.user/PowerToysSparse.publisher.txt` (emitted by `BuildSparsePackage.ps1`). See `src/modules/imageresizer/ui/ImageResizerUI.csproj` for an example MSBuild target (`GenerateSparseIdentityManifest`) that writes `ImageResizerUI.exe.manifest` and sets `ApplicationManifest` automatically. 3. Embed a sparse identity manifest in the Win32 binary so it binds to the MSIX identity at runtime. The manifest must declare an `<msix>` element with `packageName="Microsoft.PowerToys.SparseApp"`, `applicationId` matching the `<Application Id>`, and a `publisher` that matches the sparse package. Keep the manifests publisher in sync with `src/PackageIdentity/.user/PowerToysSparse.publisher.txt` (emitted by `BuildSparsePackage.ps1`). See `src/modules/imageresizer/ui/ImageResizerUI.csproj` for an example that points `ApplicationManifest` to `ImageResizerUI.dev.manifest` for local builds and switches to `ImageResizerUI.prod.manifest` when `$(CIBuild)` is `true`.
4. Register or re-register the sparse package so Windows learns about the new application Id. 4. Register or re-register the sparse package so Windows learns about the new application Id.
5. To launch the Win32 surface with identity, use the `shell:AppsFolder` activation form (for example: `shell:AppsFolder\Microsoft.PowerToys.SparseApp_<PackageFamilyName>!PowerToys.MyModuleUI`) or activate it via `IApplicationActivationManager::ActivateApplication` using the same AppUserModelID. 5. To launch the Win32 surface with identity, use the `shell:AppsFolder` activation form (for example: `shell:AppsFolder\Microsoft.PowerToys.SparseApp_<PackageFamilyName>!PowerToys.MyModuleUI`) or activate it via `IApplicationActivationManager::ActivateApplication` using the same AppUserModelID.

View File

@@ -25,10 +25,11 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SparsePackagePublisherDefault>CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US</SparsePackagePublisherDefault> <ApplicationManifest>ImageResizerUI.dev.manifest</ApplicationManifest>
<SparsePackageName>Microsoft.PowerToys.SparseApp</SparsePackageName> </PropertyGroup>
<SparseApplicationId>PowerToys.ImageResizerUI</SparseApplicationId>
<GeneratedSparseManifest>$(IntermediateOutputPath)ImageResizerUI.exe.manifest</GeneratedSparseManifest> <PropertyGroup Condition="'$(CIBuild)'=='true'">
<ApplicationManifest>ImageResizerUI.prod.manifest</ApplicationManifest>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -72,27 +73,4 @@
<Copy SourceFiles="@(ResourceFiles)" DestinationFolder="$(OutputPath)Resources" SkipUnchangedFiles="true" /> <Copy SourceFiles="@(ResourceFiles)" DestinationFolder="$(OutputPath)Resources" SkipUnchangedFiles="true" />
</Target> </Target>
<Target Name="GenerateSparseIdentityManifest" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<SparsePackagePublisher>$(SparsePackagePublisherDefault)</SparsePackagePublisher>
</PropertyGroup>
<ReadLinesFromFile File="$(MSBuildThisFileDirectory)..\..\..\PackageIdentity\.user\PowerToysSparse.publisher.txt" Condition="Exists('$(MSBuildThisFileDirectory)..\..\..\PackageIdentity\.user\PowerToysSparse.publisher.txt')">
<Output TaskParameter="Lines" PropertyName="SparsePackagePublisherFromFile" />
</ReadLinesFromFile>
<PropertyGroup Condition="'$(SparsePackagePublisherFromFile)' != ''">
<SparsePackagePublisher>$(SparsePackagePublisherFromFile)</SparsePackagePublisher>
</PropertyGroup>
<MakeDir Directories="$(IntermediateOutputPath)" />
<ItemGroup>
<SparseManifestLines Include="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;" />
<SparseManifestLines Include="&lt;assembly manifestVersion=&quot;1.0&quot; xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot;&gt;" />
<SparseManifestLines Include=" &lt;assemblyIdentity version=&quot;1.0.0.0&quot; name=&quot;PowerToys.ImageResizer.app&quot;/&gt;" />
<SparseManifestLines Include=" &lt;msix xmlns=&quot;urn:schemas-microsoft-com:msix.v1&quot; publisher=&quot;$(SparsePackagePublisher)&quot; packageName=&quot;$(SparsePackageName)&quot; applicationId=&quot;$(SparseApplicationId)&quot;/&gt;" />
<SparseManifestLines Include="&lt;/assembly&gt;" />
</ItemGroup>
<WriteLinesToFile File="$(GeneratedSparseManifest)" Lines="@(SparseManifestLines)" Overwrite="true" Encoding="UTF-8" />
<PropertyGroup>
<ApplicationManifest>$(GeneratedSparseManifest)</ApplicationManifest>
</PropertyGroup>
</Target>
</Project> </Project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="PowerToys.ImageResizer.app" />
<msix xmlns="urn:schemas-microsoft-com:msix.v1"
publisher="CN=PowerToys Dev, O=PowerToys, L=Redmond, S=Washington, C=US"
packageName="Microsoft.PowerToys.SparseApp"
applicationId="PowerToys.ImageResizerUI" />
</assembly>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="PowerToys.ImageResizer.app" />
<msix xmlns="urn:schemas-microsoft-com:msix.v1"
publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
packageName="Microsoft.PowerToys.SparseApp"
applicationId="PowerToys.ImageResizerUI" />
</assembly>