Repository navigation
Conversation
Enrich platform-produced ApplicationArtifact items with MAUI application metadata via GetApplicationArtifactsDependsOn instead of introducing MAUI-specific artifact item groups. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 35973Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35973" |
Document that platform build/artifact-production steps populate ApplicationArtifact items before MAUI metadata enrichment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
kubaflo
left a comment
There was a problem hiding this comment.
Multi-Model Review — PR #35973
Verdict: ❌ NEEDS_CHANGES
Confidence: High (unanimous across all 4 models)
All 4 models independently identified issues that should be addressed before merging.
Model agreement: gemini (NEEDS_CHANGES/1), gpt-5.5 (NEEDS_CHANGES/1), opus-4.6 (NEEDS_CHANGES/1), opus-4.8 (NEEDS_CHANGES/2)
Findings: 4 unique issues identified.
| <ApplicationIdGuid>11111111-2222-3333-4444-555555555555</ApplicationIdGuid> | ||
| <ApplicationDisplayVersion>2.3</ApplicationDisplayVersion> | ||
| <ApplicationVersion>42</ApplicationVersion> | ||
| </PropertyGroup> |
There was a problem hiding this comment.
The relative path $(MSBuildThisFileDirectory)..\..\..\ assumes the test directory is located within the MAUI repository bin/ folder. However, on Azure Pipelines CI, TestDirectory is located under AGENT_TEMPDIRECTORY (e.g., .../test-dir/ApplicationArtifactsAreEnrichedWithMauiMetadata/). As a result, traversing up 3 directories points to AGENT_TEMPDIRECTORY/src/Workload/... instead of the repository, causing MSB4019 missing import errors and failing the integration tests.
| <ApplicationDisplayVersion>2.3</ApplicationDisplayVersion> | ||
| <ApplicationVersion>42</ApplicationVersion> | ||
| </PropertyGroup> | ||
| <Import Project="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\..\src\Workload\Microsoft.Maui.Sdk\Sdk\Microsoft.Maui.Sdk.After.targets'))" /> |
There was a problem hiding this comment.
This import is rooted at the generated test project's MSBuildThisFileDirectory and walks up three directories to find src/Workload. That happens to work for local fallback TestDirectory under the repo's bin/test-dir, but in Azure Pipelines TestEnvironment.GetTestDirectoryRoot() uses AGENT_TEMPDIRECTORY/test-dir, so ......\src does not point at the MAUI checkout and the new Build integration test cannot import Microsoft.Maui.Sdk.After.targets. The current CI failures in the Build integration lanes are consistent with this PR-introduced test path issue.
(found by: 5, 4)
| <Target Name="SeedApplicationArtifacts"> | ||
| <ItemGroup> | ||
| <ApplicationArtifact Include="$(MSBuildProjectDirectory)/artifacts/platform/android/MyArtifactApp-Signed.apk"> | ||
| <PackageFormat>apk</PackageFormat> |
There was a problem hiding this comment.
The explicit <Import Project="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\\..\\..\\src\\Workload\\...'))" /> assumes the project directory is 3 levels deep inside the repo root. Locally this resolves from <repo>/bin/test-dir/<testname>/ to <repo>/. In CI, TestDirectory is under $AGENT_TEMPDIRECTORY/test-dir/<testname>/, so 3 parent traversals land in the agent temp directory—not the repo. The targets file won't exist there, causing a build error. This is the likely cause of the CI 'Build integration tests' failures on both macOS and Windows.
| Lines="@(ApplicationArtifact->'%(Filename)%(Extension)|%(PackageFormat)|%(ApplicationTitle)|%(ApplicationName)|%(ApplicationId)|%(ApplicationIdGuid)|%(ApplicationDisplayVersion)|%(ApplicationVersion)|%(Signed)|%(PackageId)|%(PlatformName)|%(BundleIdentifier)')" | ||
| Overwrite="true" /> | ||
| </Target> | ||
| <Target Name="WritePublishApplicationArtifactsMetadata" DependsOnTargets="SeedApplicationArtifacts;_AddMauiApplicationArtifactMetadata"> |
There was a problem hiding this comment.
Both WriteGetApplicationArtifactsMetadata and WritePublishApplicationArtifactsMetadata depend directly on SeedApplicationArtifacts;_AddMauiApplicationArtifactMetadata, so they exercise the metadata target in isolation rather than through a real GetApplicationArtifacts/Publish invocation; the actual wiring is only checked indirectly by the string Assert.Contains on the depends-on file (line 178). The Publish variant therefore adds no coverage beyond the Get variant. This is understandable while the platform GetApplicationArtifacts target is unavailable in net11, but consider collapsing the duplicate target (or asserting the real wiring) once the platform producers land.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 2 findings
See inline comments for details.
| <ApplicationDisplayVersion>2.3</ApplicationDisplayVersion> | ||
| <ApplicationVersion>42</ApplicationVersion> | ||
| </PropertyGroup> | ||
| <Import Project="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\..\src\Workload\Microsoft.Maui.Sdk\Sdk\Microsoft.Maui.Sdk.After.targets'))" /> |
There was a problem hiding this comment.
[major] Build & MSBuild — This import is resolved relative to the generated test project. In CI TestDirectory is under
| </ApplicationArtifact> | ||
| </ItemGroup> | ||
| </Target> | ||
| <Target Name="WriteGetApplicationArtifactsMetadata" DependsOnTargets="SeedApplicationArtifacts;_AddMauiApplicationArtifactMetadata"> |
There was a problem hiding this comment.
[moderate] Regression Prevention — The test target depends on _AddMauiApplicationArtifactMetadata directly, so it validates the private target body rather than the GetApplicationArtifactsDependsOn extension path this PR adds. A regression where the hook is not actually invoked by GetApplicationArtifacts/Publish could still pass because lines 157 and 167 call the target manually. Seed the item, invoke the targets through $(GetApplicationArtifactsDependsOn)/the public artifacts target, and assert the metadata after that path runs.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 2 findings
See inline comments for details.
| <ApplicationDisplayVersion>2.3</ApplicationDisplayVersion> | ||
| <ApplicationVersion>42</ApplicationVersion> | ||
| </PropertyGroup> | ||
| <Import Project="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\..\src\Workload\Microsoft.Maui.Sdk\Sdk\Microsoft.Maui.Sdk.After.targets'))" /> |
There was a problem hiding this comment.
❌ Error — This import is resolved relative to the generated temp test project via $(MSBuildThisFileDirectory), not relative to the MAUI repo. In CI, TestDirectory is under AGENT_TEMPDIRECTORY, so ..\..\..\src\Workload\... points outside /home/vsts/work/1/s and the test fails before exercising the PR fix. Please build the import path from TestEnvironment.GetMauiDirectory() or otherwise pass an absolute repo-rooted path into the generated project.
| </ApplicationArtifact> | ||
| </ItemGroup> | ||
| </Target> | ||
| <Target Name="WriteGetApplicationArtifactsMetadata" DependsOnTargets="SeedApplicationArtifacts;_AddMauiApplicationArtifactMetadata"> |
There was a problem hiding this comment.
_AddMauiApplicationArtifactMetadata target directly, so it can pass even if the public $(GetApplicationArtifactsDependsOn) hook is not honored by GetApplicationArtifacts/Publish or runs in the wrong order. Please exercise the public target path, or make this target depend on $(GetApplicationArtifactsDependsOn), so the regression test covers the actual integration contract added in Microsoft.Maui.Sdk.After.targets.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 2 findings
See inline comments for details.
| <ApplicationDisplayVersion>2.3</ApplicationDisplayVersion> | ||
| <ApplicationVersion>42</ApplicationVersion> | ||
| </PropertyGroup> | ||
| <Import Project="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\..\src\Workload\Microsoft.Maui.Sdk\Sdk\Microsoft.Maui.Sdk.After.targets'))" /> |
There was a problem hiding this comment.
❌ Error — This import resolves from the generated temp project directory, not the MAUI repo root. In CI TestDirectory is under the agent temp/test-dir (and locally under bin/test-dir), so ..\\..\\..\\src\\Workload... points at a non-existent sibling src tree and the test will fail before exercising the target. Build the path from TestEnvironment.GetMauiDirectory() or pass the repo-root path as an MSBuild property instead.
| </ApplicationArtifact> | ||
| </ItemGroup> | ||
| </Target> | ||
| <Target Name="WriteGetApplicationArtifactsMetadata" DependsOnTargets="SeedApplicationArtifacts;_AddMauiApplicationArtifactMetadata"> |
There was a problem hiding this comment.
ApplicationArtifact items and directly invokes the private _AddMauiApplicationArtifactMetadata target, so it does not prove the public GetApplicationArtifacts/publish extension path actually returns enriched platform artifacts. A regression in target ordering or platform artifact production could still ship while this test passes; prefer invoking the real public targets or depending through $(GetApplicationArtifactsDependsOn) in the harness.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 5 findings
See inline comments for details.
| <ApplicationDisplayVersion>2.3</ApplicationDisplayVersion> | ||
| <ApplicationVersion>42</ApplicationVersion> | ||
| </PropertyGroup> | ||
| <Import Project="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\..\src\Workload\Microsoft.Maui.Sdk\Sdk\Microsoft.Maui.Sdk.After.targets'))" /> |
There was a problem hiding this comment.
❌ [critical] Build & MSBuild — Import path is broken on CI and on Linux/macOS
$(MSBuildThisFileDirectory) evaluates to the generated project directory under the integration-test temp root, not the MAUI repo root. On CI that makes ..\..\..\src\Workload\... resolve outside the checkout, and on Linux/macOS the backslashes are literal path characters rather than directory separators. The test can hard-fail before exercising the metadata target.
Resolve the targets file from C# using TestEnvironment.GetMauiDirectory() and inject/pass an absolute path with platform-correct separators.
| <ApplicationDisplayVersion>2.3</ApplicationDisplayVersion> | ||
| <ApplicationVersion>42</ApplicationVersion> | ||
| </PropertyGroup> | ||
| <Import Project="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\..\src\Workload\Microsoft.Maui.Sdk\Sdk\Microsoft.Maui.Sdk.After.targets'))" /> |
There was a problem hiding this comment.
The generated maui template project already imports Microsoft.Maui.Sdk.After.targets through the installed workload. The explicit source import can append _AddMauiApplicationArtifactMetadata a second time and makes the GetApplicationArtifactsDependsOn string assertion ambiguous. Prefer a minimal non-MAUI MSBuild project for this unit-style target test, or otherwise ensure the source targets are imported exactly once.
| </ApplicationArtifact> | ||
| </ItemGroup> | ||
| </Target> | ||
| <Target Name="WriteGetApplicationArtifactsMetadata" DependsOnTargets="SeedApplicationArtifacts;_AddMauiApplicationArtifactMetadata"> |
There was a problem hiding this comment.
WriteGetApplicationArtifactsMetadata and WritePublishApplicationArtifactsMetadata depend directly on _AddMauiApplicationArtifactMetadata, so the test would still pass if GetApplicationArtifactsDependsOn were removed, misspelled, or pointed at the wrong target. Invoke the public target/dependency chain and verify the enriched @(ApplicationArtifact) items are returned through that path.
| Assert.Contains("_AddMauiApplicationArtifactMetadata", File.ReadAllText(dependsOnFile), StringComparison.Ordinal); | ||
| AssertApplicationArtifactMetadata(File.ReadAllLines(getArtifactsFile)); | ||
|
|
||
| Assert.True(DotnetInternal.Build(projectFile, "Debug", target: "WritePublishApplicationArtifactsMetadata", framework: $"{DotNetCurrent}-android", properties: BuildProps, output: _output), |
There was a problem hiding this comment.
The publish assertion builds a custom target with the same direct dependency on _AddMauiApplicationArtifactMetadata, so it does not verify whether the real Publish path triggers artifact enrichment. Either document and test that Publish consumes the same GetApplicationArtifactsDependsOn extension path, or add the missing publish hook and verify it through the real publish target.
| </ItemGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <GetApplicationArtifactsDependsOn> |
There was a problem hiding this comment.
💡 [minor] Build & MSBuild — Consider guarding the dependency-chain extension
The property group appends _AddMauiApplicationArtifactMetadata for every project importing Microsoft.Maui.Sdk.After.targets, including configurations such as UseMauiEssentials=true that may never produce application artifacts. The target is a no-op when @(ApplicationArtifact) is empty, so this is likely harmless, but a UseMaui/artifact-intent condition or documentation would make the global extension explicit.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 2 findings
See inline comments for details.
| <ApplicationDisplayVersion>2.3</ApplicationDisplayVersion> | ||
| <ApplicationVersion>42</ApplicationVersion> | ||
| </PropertyGroup> | ||
| <Import Project="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\..\src\Workload\Microsoft.Maui.Sdk\Sdk\Microsoft.Maui.Sdk.After.targets'))" /> |
There was a problem hiding this comment.
[critical] Build & MSBuild — This import resolves from $(MSBuildThisFileDirectory), which is the generated temp test project directory, not the repo root. In CI the path walks up from the temp project and can miss src/Workload/Microsoft.Maui.Sdk/Sdk/Microsoft.Maui.Sdk.After.targets, causing MSB4019 before the regression test can run. Use the repo MAUI directory/test environment path instead of a project-relative path.
| </ApplicationArtifact> | ||
| </ItemGroup> | ||
| </Target> | ||
| <Target Name="WriteGetApplicationArtifactsMetadata" DependsOnTargets="SeedApplicationArtifacts;_AddMauiApplicationArtifactMetadata"> |
There was a problem hiding this comment.
[major] Regression Prevention/Test Coverage — The test directly depends on the private _AddMauiApplicationArtifactMetadata target here and again in WritePublishApplicationArtifactsMetadata, so it can pass even if the production GetApplicationArtifactsDependsOn hook is not actually used by GetApplicationArtifacts/Publish. Exercise the public depends-on path rather than invoking the private target directly.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 1 findings
See inline comments for details.
| <ApplicationDisplayVersion>2.3</ApplicationDisplayVersion> | ||
| <ApplicationVersion>42</ApplicationVersion> | ||
| </PropertyGroup> | ||
| <Import Project="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\..\src\Workload\Microsoft.Maui.Sdk\Sdk\Microsoft.Maui.Sdk.After.targets'))" /> |
There was a problem hiding this comment.
[major] Build & MSBuild / integration test correctness — This import resolves relative to the temporary test project directory, not the MAUI repo root. In CI TestDirectory is under AGENT_TEMPDIRECTORY/test-dir, and locally it is under bin/test-dir, so $(MSBuildThisFileDirectory)..\..\..\src\Workload\... points at a non-existent src sibling and the test will fail before exercising the metadata target. It can also double-import Microsoft.Maui.Sdk.After.targets when the SDK already imports it. Use TestEnvironment.GetMauiDirectory() to build an absolute path if the test must import source targets, or rely on the SDK import from the built workload.
Adversarial merge-safety reviewVerdict: not safe to merge yet. Reviewed head Evidence
Blocking concerns
Before merge: resolve conflicts, add a distinct packaged publish refresh, exercise |
|
could you please resolve conflicts |
This comment has been minimized.
This comment has been minimized.
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
| } | ||
|
|
||
| static string WithDirectorySeparator(string path) => | ||
| path.EndsWith(Path.DirectorySeparatorChar, StringComparison.Ordinal) ? path : path + Path.DirectorySeparatorChar; |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - Path.DirectorySeparatorChar is a char, but the two-argument string.EndsWith overload taking StringComparison requires a string. There is an EndsWith(char) overload, but no EndsWith(char, StringComparison) overload or matching extension in this project. Consequently the entire integration-test assembly fails to compile with CS1503 on every host, before platform guards or test filters can run. Use path.EndsWith(Path.DirectorySeparatorChar) or convert the separator to a string.
|
|
||
| internal static class Program | ||
| { | ||
| [STAThread] |
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - The generated standalone application's Program.cs uses [STAThread] without using System, while its hand-written SDK project does not enable ImplicitUsings. The copied template-test Directory.Build.props only configures warnings, and the test-root props prevent inheriting repository settings. The generated project therefore cannot resolve STAThreadAttribute, so this Windows test fails at Build before validating standalone package consumption or Publish. Qualify the attribute as [System.STAThread], add the using, or enable implicit usings in the generated project.
| Assert.True( | ||
| DotnetInternal.Run("msbuild", $"\"{projectFile}\" -t:WriteApplicationArtifacts -v:minimal", output: _output), | ||
| "Unable to execute the inert Windows ApplicationArtifact fixture."); | ||
| Assert.True(!File.Exists(artifactsFile) || new FileInfo(artifactsFile).Length == 0); |
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - This inert-project theory supplies neither TargetDir nor an existing executable, so an unpackaged collector produces no artifacts even if the activation, design-time, or BuildingProject guards are bypassed. The empty-output assertion therefore cannot detect those guards regressing for an application with existing build outputs. Seed an executable and TargetDir, verify that an otherwise-identical enabled case collects them, and assert that each disabled case remains empty.
PR Test Gate
🧪 Gate analysis — click to expand⚠ Inconclusive. The PR could not be merged with its target branch; no tests ran. No interpretable test-group summary was produced. No additional test execution is inferred. Setup did not capture a verified PR head; no commit is claimed as tested. No immutable without-fix baseline was prepared. |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Adds
ApplicationArtifactsupport for modern SDK-style Windows App SDK applications through a new targets-onlyMicrosoft.Maui.ApplicationArtifacts.Windowspackage.Artifact metadata is now owned by the platform that produces the final output instead of being inferred by MAUI from project inputs. Android and Apple expose authoritative common metadata in their platform follow-ups:
This PR supplies the missing Windows producer. It reads WinAppSDK's final output properties and item lists rather than searching output directories, de-duplicates normalized paths, excludes
objintermediates, and makes publish-path items available toAfterTargets="Publish"consumers.Package and consumption
Microsoft.Maui.ApplicationArtifacts.Windowsis a normal NuGet dependency package containing only a neutralbuildTransitivetarget. It has no MAUI runtime, Resizetizer, or MAUI build-task dependency.Microsoft.Maui.Corereferences it only for Windows target frameworks, and themaui-windowsworkload includes it. Non-MAUI WinUI, Uno, and other SDK-style Windows App SDK applications can also reference the package directly.The targets activate only for real, non-design-time Windows App SDK application builds with
ExeorWinExeoutput. SetEnableWindowsApplicationArtifacts=falseto opt out.Windows outputs
The producer supports unpackaged, MSIX, and sparse applications and classifies the final outputs WinAppSDK actually creates:
PrimaryPayloadDirectoryBundleStoreUploadDeploymentManifestSymbolsCertificateInstallScriptDependencyPackageLandingPageSupportEvery item carries common application identity/title/version metadata plus Windows metadata such as
PackageFormat,PackageType,PackageVersion,Architecture,RuntimeIdentifier,Signed,BundlePlatforms,EntryPoint,DeploymentDirectory,IsPrimary, andPrimaryArtifactwhen available.Packaged metadata comes from the final Appx manifest and preserves unresolved
ms-resource:references. Unpackaged metadata comes from the resolved application output.ApplicationIdGuidis emitted only when the effective Windows identity is a GUID.Classic
.wapprojpackaging is intentionally deferred because it uses a different packaging pipeline owned outside this repository.Testing
PackageReferencerestore ofMicrosoft.Maui.ApplicationArtifacts.Windowsis verified.GetApplicationArtifacts;Publishin one MSBuild invocation..appinstaller, then verifiesBundle,StoreUpload, andDeploymentManifestroles.Issues Fixed
N/A