[ci-fix] Needs review: deploy FileVersionInfo TestAssembly as Content on Apple NativeAOT (refs #130253)#130328
Conversation
FileVersionInfo_CustomManagedAssembly opens the companion System.Diagnostics.FileVersionInfo.TestAssembly.dll by file path to read its PE version metadata. On Apple mobile NativeAOT the test assembly was referenced via a plain ProjectReference, so it is compiled into the native image and no loadable .dll is deployed next to the app, causing the test to throw FileNotFoundException. Deploy the assembly as a Content data file on the Apple NativeAOT leg (as is already done for desktop), while keeping the plain project reference for Apple mobile Mono where the #46856 vfs-mapping workaround still applies. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Apple app bundler strips managed .dll files from NativeAOT app bundles, so the test asset deployed as Content reaches publish/ but not the app working directory, and FileVersionInfo_CustomManagedAssembly throws FileNotFoundException. Redeploy the read-only PE asset under a bundle-safe .exe name before bundling and read that name on Apple NativeAOT. Verified on the iossimulator-arm64 NativeAOT leg: the test now passes in the simulator. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
The workarounds for broken tooling (crossgen2, apple app builder, whatever is the problem on browser) are getting out of hand here. If we don't want to fix the tools not to consider random Content as code (which it looks like we don't), we should instead embed the project as a resource and write it out to TEMP. This test is already writing to TEMP. Something along the lines of: <ProjectReference Include="FileName.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<OutputItemType>EmbeddedResource</OutputItemType>
<LogicalName>Filename.dll</LogicalName>
</ProjectReference>will embed the assembly as Filename.dll in managed resources. Then it can be dumped to TEMP and inspected. And all the workarounds deleted, instead of adding yet another axis of workarounds. |
I agree, most of the mobile failures are infra related or caused by incorrect test packaging. I will try to keep the changes minimal and avoid introducing more complexity. Alternatively, I suggest disabling such tests. |
…g it Per review feedback, replace the per-platform Content and project-reference workarounds with a single embedded managed resource that FileVersionInfoTest writes to a temp file and inspects. This removes the Browser and Apple mobile special-casing for #46856, the ReadyToRun exclude, the Mono trimming descriptor, and the Apple NativeAOT .exe redeploy, since no loose managed .dll is deployed on any platform. Verified on the iossimulator-arm64 NativeAOT leg: FileVersionInfo_CustomManagedAssembly passes in the simulator. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
The test previously loaded the asset from a Content-deployed file, which failed on Apple mobile CoreCLR and was disabled via the issue #124344 ActiveIssue. The test now reads the assembly from an embedded resource and writes it to a temp file at run time, so the Apple mobile CoreCLR filter is no longer required. CI verifies the test passes on the Apple mobile legs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Replace the previous .exe redeploy workaround with the approach from dotnet#130328, extended to also cover FileVersionInfo_EmptyFVI. Embed the test assembly and Assembly1.cs as managed resources and write them to a temp file at run time, so the tests do not depend on those files being deployed next to the test app. On NativeAOT Apple mobile the app bundler strips managed .dll files from the .app bundle, which is why the loose files were missing. This removes the platform-specific Content, ProjectReference, ReadyToRun and trimming special-casing and drops the related [ActiveIssue] skips. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the System.Diagnostics.FileVersionInfo tests to stop relying on a companion managed test assembly being deployed as a loose .dll file, by embedding that assembly into the test binary and extracting it to a temp file at runtime (to support scenarios like Apple NativeAOT where the .dll may not exist on disk).
Changes:
- Embed
System.Diagnostics.FileVersionInfo.TestAssemblyoutput into the test assembly as anEmbeddedResource. - Update tests to write the embedded assembly bytes to a temp file and validate
FileVersionInfoagainst that path (including Unix symlink tests). - Remove the Apple Mono trimming descriptor file and related csproj wiring.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj | Switches the test-assembly project reference to produce an embedded resource instead of content/project-reference variants. |
| src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/FileVersionInfoTest.cs | Adds helper to extract embedded test assembly to a temp file; updates the custom-assembly test to use it. |
| src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/FileVersionInfoTest.Unix.cs | Updates symlink tests to use the extracted temp-file copy of the embedded test assembly. |
| src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/ILLink.Descriptors.xml | Removes the Apple Mono trimming descriptor that rooted the test assembly. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 2
|
/ba-g unrelated extra-platforms failures, no FileNotFoundException or missing assemblies |
Workflow artifact: ci-fix
Artifact kind: help
Linked KBE: #130253
Important
Help-wanted / needs-review draft. This is a best-effort candidate fix that I could not build-validate in the agent environment (no Apple NativeAOT cross-build is available here). It is a genuine, non-muting change — it does not disable, skip, or
[ActiveIssue]the test. Please validate on the Apple NativeAOT library-test legs before merging.Root cause
On the Apple NativeAOT library-test legs (
iossimulator/maccatalystAllSubsets_NativeAOT, e.g. build 1494308),System.Diagnostics.Tests.FileVersionInfoTest.FileVersionInfo_CustomManagedAssemblyfails with:The test opens its companion assembly by file path to read PE version metadata — it never loads or executes it (
FileVersionInfoTest.cs:25):In the test
.csproj, for Apple mobile the TestAssembly was included as a plain<ProjectReference>. Under NativeAOT that assembly is compiled into the native image, so no loose.dllis deployed next to the app andDirectory.GetCurrentDirectory()/...TestAssembly.dlldoes not exist →FileNotFoundException. Under Apple Mono the managed assembly is still deployed as a file, which is why the test passes there.The existing
[ActiveIssue(".../124344", IsAppleMobile && IsCoreCLR)]on this test does not apply here:PlatformDetection.IsCoreCLR => IsNotMonoRuntime && IsNotNativeAotisfalseunder NativeAOT, so the test genuinely runs (and fails) on the NativeAOT leg.These NativeAOT library tests on Apple mobile were newly enabled by #125437.
Candidate change
Deploy the TestAssembly as a Content data file on the Apple NativeAOT leg (exactly as already done for desktop), while keeping the plain project reference for Apple Mono, where the #46856 vfs-mapping workaround still applies:
TargetsAppleMobile && UseNativeAotRuntime→ Content copy (new).TargetsAppleMobile && !UseNativeAotRuntime(Mono) → plain reference (unchanged).Only the Apple-NativeAOT branch changes; the MSBuild conditions leave Mono Apple, browser, and desktop provably untouched, and never select both
<ProjectReference>items at once.What is unverified (why this is a draft)
.dllactually lands atDirectory.GetCurrentDirectory()inside the NativeAOT.appbundle, nor that the AppleAppBuilder NativeAOT library-mode path packages Content identically to Mono.NativeLibrary.dll,NativeConsoleApp.exe) are already deployed and found on Apple, and under NativeAOT there is no managed-assembly vfs mapping for [wasm][aot] build tries to cross compile unrelated dlls from the publish folder #46856 to collide with — but this needs a CI run to confirm.Validation
System.Diagnostics.FileVersionInfo.Testson theiossimulator/maccatalystAllSubsets_NativeAOTlegs and confirmFileVersionInfo_CustomManagedAssemblypasses with noidentical vfs mappingspackaging error.Suggested reviewers / area contacts
These tests were enabled on Apple NativeAOT by #125437 —
@kotlarmilos, could you (or the mobile/NativeAOT folks) confirm the Content asset is bundled at the app's working directory under NativeAOT library mode? Area owners:@dotnet/area-system-diagnostics.Note
This PR was generated by an AI/Copilot agent (
ci-failure-fix) as a best-effort, non-muting candidate fix. Please review carefully before merging.Note
🔒 Integrity filter blocked 17 items
The following items were blocked because they don't meet the GitHub integrity level.
search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".issue_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter: